From 6bca6bef1b6a17571ae90c98df174e477d89db6b Mon Sep 17 00:00:00 2001 From: Ann Kamyshnikova Date: Tue, 25 Feb 2020 15:33:27 +0400 Subject: [PATCH] [Amphorav2] Fix noop driver case Fix amphora creation with amphora_noop_driver and network_noop_driver. Change-Id: I5d3c4d5280916916e95120cfba6fc076a1650cf4 Story: 2005072 --- octavia/amphorae/drivers/driver_base.py | 9 ++++++++- octavia/amphorae/drivers/noop_driver/driver.py | 9 ++++++--- .../controller/worker/v2/tasks/amphora_driver_tasks.py | 10 +++++++--- octavia/network/drivers/noop_driver/driver.py | 5 ++++- 4 files changed, 25 insertions(+), 8 deletions(-) diff --git a/octavia/amphorae/drivers/driver_base.py b/octavia/amphorae/drivers/driver_base.py index 215b95ef2a..e5909c6cc8 100644 --- a/octavia/amphorae/drivers/driver_base.py +++ b/octavia/amphorae/drivers/driver_base.py @@ -130,7 +130,8 @@ class AmphoraLoadBalancerDriver(object): an offline pool after this call. """ - def post_vip_plug(self, amphora, load_balancer, amphorae_network_config): + def post_vip_plug(self, amphora, load_balancer, amphorae_network_config, + vrrp_port=None, vip_subnet=None): """Called after network driver has allocated and plugged the VIP :param amphora: @@ -141,6 +142,12 @@ class AmphoraLoadBalancerDriver(object): :param amphorae_network_config: A data model containing information about the subnets and ports that an amphorae owns. + :param vrrp_port: VRRP port associated with the load balancer + :type vrrp_port: octavia.network.data_models.Port + + :param vip_subnet: VIP subnet associated with the load balancer + :type vip_subnet: octavia.network.data_models.Subnet + :type vip_network: octavia.network.data_models.AmphoraNetworkConfig :returns: None diff --git a/octavia/amphorae/drivers/noop_driver/driver.py b/octavia/amphorae/drivers/noop_driver/driver.py index 6ce3de70bf..89cebe7516 100644 --- a/octavia/amphorae/drivers/noop_driver/driver.py +++ b/octavia/amphorae/drivers/noop_driver/driver.py @@ -94,7 +94,8 @@ class NoopManager(object): self.amphoraconfig[amphora.id, port.id] = (amphora.id, port.id, 'post_network_plug') - def post_vip_plug(self, amphora, load_balancer, amphorae_network_config): + def post_vip_plug(self, amphora, load_balancer, amphorae_network_config, + vrrp_port=None, vip_subnet=None): LOG.debug("Amphora %s no-op, post vip plug load balancer %s", self.__class__.__name__, load_balancer.id) self.amphoraconfig[(load_balancer.id, id(amphorae_network_config))] = ( @@ -155,10 +156,12 @@ class NoopAmphoraLoadBalancerDriver( self.driver.post_network_plug(amphora, port) - def post_vip_plug(self, amphora, load_balancer, amphorae_network_config): + def post_vip_plug(self, amphora, load_balancer, amphorae_network_config, + vrrp_port=None, vip_subnet=None): self.driver.post_vip_plug(amphora, - load_balancer, amphorae_network_config) + load_balancer, amphorae_network_config, + vrrp_port=vrrp_port, vip_subnet=vip_subnet) def upload_cert_amp(self, amphora, pem_file): diff --git a/octavia/controller/worker/v2/tasks/amphora_driver_tasks.py b/octavia/controller/worker/v2/tasks/amphora_driver_tasks.py index 8dab884153..de57ad4708 100644 --- a/octavia/controller/worker/v2/tasks/amphora_driver_tasks.py +++ b/octavia/controller/worker/v2/tasks/amphora_driver_tasks.py @@ -275,9 +275,13 @@ class AmphoraPostVIPPlug(BaseAmphoraTask): vrrp_port = data_models.Port( **amphorae_network_config[ amphora.get(constants.ID)][constants.VRRP_PORT]) - vip_subnet = data_models.Subnet( - **amphorae_network_config[ - amphora.get(constants.ID)][constants.VIP_SUBNET]) + # Required for noop-case + vip_arg = amphorae_network_config[amphora.get( + constants.ID)][constants.VIP_SUBNET] + if vip_arg: + vip_subnet = data_models.Subnet(**vip_arg) + else: + vip_subnet = data_models.Subnet() self.amphora_driver.post_vip_plug( db_amp, db_lb, amphorae_network_config, vrrp_port=vrrp_port, vip_subnet=vip_subnet) diff --git a/octavia/network/drivers/noop_driver/driver.py b/octavia/network/drivers/noop_driver/driver.py index 3d686aa03c..ebac2e21f4 100644 --- a/octavia/network/drivers/noop_driver/driver.py +++ b/octavia/network/drivers/noop_driver/driver.py @@ -151,7 +151,10 @@ class NoopManager(object): self.networkconfigconfig[network_id] = (network_id, 'get_network') network = network_models.Network(id=uuidutils.generate_uuid()) - class ItIsInsideMe(object): + class ItIsInsideMe(network_models.Subnet): + def to_dict(self, **kwargs): + return [{}] + def __contains__(self, item): return True