forked from openstack/kuryr-kubernetes
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tox.ini contains a bunch of excludes, that are unnecessary. Some are leftovers from neutron. Some are already fixed and there is no point in excluding them and some are easy to fix. This commit does not fix E128 as it is the only serious exclusion with (currently 166 lines to be changed) Change-Id: I48cb6cd2258b2d8ed5b8dfdd3ceac7d8d573be81
- Loading branch information
Showing
6 changed files
with
95 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,74 +1,74 @@ | ||
# All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); you may | ||
# not use this file except in compliance with the License. You may obtain | ||
# a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
# License for the specific language governing permissions and limitations | ||
# under the License. | ||
|
||
import abc | ||
import six | ||
|
||
from kuryr.lib._i18n import _ | ||
from kuryr.lib import exceptions as kl_exc | ||
from neutronclient.common import exceptions as n_exc | ||
from oslo_config import cfg as oslo_cfg | ||
from oslo_log import log as logging | ||
|
||
from kuryr_kubernetes.controller.drivers import neutron_vif | ||
|
||
|
||
LOG = logging.getLogger(__name__) | ||
|
||
|
||
# Moved out from neutron_defaults group | ||
nested_vif_driver_opts = [ | ||
oslo_cfg.StrOpt('worker_nodes_subnet', | ||
help=_("Neutron subnet ID for k8s worker node vms.")), | ||
] | ||
|
||
oslo_cfg.CONF.register_opts(nested_vif_driver_opts, "pod_vif_nested") | ||
|
||
|
||
@six.add_metaclass(abc.ABCMeta) | ||
class NestedPodVIFDriver(neutron_vif.NeutronPodVIFDriver): | ||
"""Skeletal handler driver for VIFs for Nested Pods.""" | ||
|
||
def _get_parent_port(self, neutron, pod): | ||
node_subnet_id = oslo_cfg.CONF.pod_vif_nested.worker_nodes_subnet | ||
if not node_subnet_id: | ||
raise oslo_cfg.RequiredOptError('worker_nodes_subnet', | ||
oslo_cfg.OptGroup('pod_vif_nested')) | ||
|
||
try: | ||
# REVISIT(vikasc): Assumption is being made that hostIP is the IP | ||
# of trunk interface on the node(vm). | ||
node_fixed_ip = pod['status']['hostIP'] | ||
except KeyError: | ||
if pod['status']['conditions'][0]['type'] != "Initialized": | ||
LOG.debug("Pod condition type is not 'Initialized'") | ||
|
||
LOG.error("Failed to get parent vm port ip") | ||
raise | ||
|
||
try: | ||
fixed_ips = ['subnet_id=%s' % str(node_subnet_id), | ||
'ip_address=%s' % str(node_fixed_ip)] | ||
ports = neutron.list_ports(fixed_ips=fixed_ips) | ||
except n_exc.NeutronClientException as ex: | ||
LOG.error("Parent vm port with fixed ips %s not found!", | ||
fixed_ips) | ||
raise ex | ||
|
||
if ports['ports']: | ||
return ports['ports'][0] | ||
else: | ||
LOG.error("Neutron port for vm port with fixed ips %s" | ||
" not found!", fixed_ips) | ||
raise kl_exc.NoResourceException | ||
# All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); you may | ||
# not use this file except in compliance with the License. You may obtain | ||
# a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
# License for the specific language governing permissions and limitations | ||
# under the License. | ||
|
||
import abc | ||
import six | ||
|
||
from kuryr.lib._i18n import _ | ||
from kuryr.lib import exceptions as kl_exc | ||
from neutronclient.common import exceptions as n_exc | ||
from oslo_config import cfg as oslo_cfg | ||
from oslo_log import log as logging | ||
|
||
from kuryr_kubernetes.controller.drivers import neutron_vif | ||
|
||
|
||
LOG = logging.getLogger(__name__) | ||
|
||
|
||
# Moved out from neutron_defaults group | ||
nested_vif_driver_opts = [ | ||
oslo_cfg.StrOpt('worker_nodes_subnet', | ||
help=_("Neutron subnet ID for k8s worker node vms.")), | ||
] | ||
|
||
oslo_cfg.CONF.register_opts(nested_vif_driver_opts, "pod_vif_nested") | ||
|
||
|
||
@six.add_metaclass(abc.ABCMeta) | ||
class NestedPodVIFDriver(neutron_vif.NeutronPodVIFDriver): | ||
"""Skeletal handler driver for VIFs for Nested Pods.""" | ||
|
||
def _get_parent_port(self, neutron, pod): | ||
node_subnet_id = oslo_cfg.CONF.pod_vif_nested.worker_nodes_subnet | ||
if not node_subnet_id: | ||
raise oslo_cfg.RequiredOptError('worker_nodes_subnet', | ||
oslo_cfg.OptGroup('pod_vif_nested')) | ||
|
||
try: | ||
# REVISIT(vikasc): Assumption is being made that hostIP is the IP | ||
# of trunk interface on the node(vm). | ||
node_fixed_ip = pod['status']['hostIP'] | ||
except KeyError: | ||
if pod['status']['conditions'][0]['type'] != "Initialized": | ||
LOG.debug("Pod condition type is not 'Initialized'") | ||
|
||
LOG.error("Failed to get parent vm port ip") | ||
raise | ||
|
||
try: | ||
fixed_ips = ['subnet_id=%s' % str(node_subnet_id), | ||
'ip_address=%s' % str(node_fixed_ip)] | ||
ports = neutron.list_ports(fixed_ips=fixed_ips) | ||
except n_exc.NeutronClientException as ex: | ||
LOG.error("Parent vm port with fixed ips %s not found!", | ||
fixed_ips) | ||
raise ex | ||
|
||
if ports['ports']: | ||
return ports['ports'][0] | ||
else: | ||
LOG.error("Neutron port for vm port with fixed ips %s" | ||
" not found!", fixed_ips) | ||
raise kl_exc.NoResourceException |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters