def get_new_LB_networking_subflow(self): """Create a sub-flow to setup networking. :returns: The flow to setup networking for a new amphora """ new_LB_net_subflow = linear_flow.Flow(constants. LOADBALANCER_NETWORKING_SUBFLOW) new_LB_net_subflow.add(network_tasks.AllocateVIP( requires=constants.LOADBALANCER, provides=constants.VIP)) new_LB_net_subflow.add(database_tasks.UpdateVIPAfterAllocation( requires=(constants.LOADBALANCER_ID, constants.VIP), provides=constants.LOADBALANCER)) new_LB_net_subflow.add(network_tasks.PlugVIP( requires=constants.LOADBALANCER, provides=constants.AMPS_DATA)) new_LB_net_subflow.add(network_tasks.ApplyQos( requires=(constants.LOADBALANCER, constants.AMPS_DATA, constants.UPDATE_DICT))) new_LB_net_subflow.add(database_tasks.UpdateAmphoraeVIPData( requires=constants.AMPS_DATA)) new_LB_net_subflow.add(database_tasks.ReloadLoadBalancer( name=constants.RELOAD_LB_AFTER_PLUG_VIP, requires=constants.LOADBALANCER_ID, provides=constants.LOADBALANCER)) new_LB_net_subflow.add(network_tasks.GetAmphoraeNetworkConfigs( requires=constants.LOADBALANCER, provides=constants.AMPHORAE_NETWORK_CONFIG)) new_LB_net_subflow.add(amphora_driver_tasks.AmphoraePostVIPPlug( requires=(constants.LOADBALANCER, constants.AMPHORAE_NETWORK_CONFIG))) return new_LB_net_subflow
def test_plug_vip(self, mock_get_session, mock_get_lb, mock_get_net_driver): mock_driver = mock.MagicMock() mock_get_net_driver.return_value = mock_driver LB.amphorae = AMPS_DATA mock_get_lb.return_value = LB LB.amphorae = AMPS_DATA net = network_tasks.PlugVIP() amp = mock.MagicMock() amp.to_dict.return_value = 'vip' mock_driver.plug_vip.return_value = [amp] data = net.execute(self.load_balancer_mock) mock_driver.plug_vip.assert_called_once_with(LB, LB.vip) self.assertEqual(["vip"], data) # revert net.revert([o_data_models.Amphora().to_dict()], self.load_balancer_mock) mock_driver.unplug_vip.assert_called_once_with(LB, LB.vip) # revert with exception mock_driver.reset_mock() mock_driver.unplug_vip.side_effect = Exception('UnplugVipException') net.revert([o_data_models.Amphora().to_dict()], self.load_balancer_mock) mock_driver.unplug_vip.assert_called_once_with(LB, LB.vip)
def get_new_LB_networking_subflow(self): """Create a sub-flow to setup networking. :returns: The flow to setup networking for a new amphora """ LOG.info("Inside network subflow") new_LB_net_subflow = linear_flow.Flow( constants.LOADBALANCER_NETWORKING_SUBFLOW) new_LB_net_subflow.add( network_tasks.AllocateVIP(requires=constants.LOADBALANCER, provides=constants.VIP)) new_LB_net_subflow.add( database_tasks.UpdateVIPAfterAllocation( requires=(constants.LOADBALANCER_ID, constants.VIP), provides=constants.LOADBALANCER)) new_LB_net_subflow.add( network_tasks.PlugVIP(requires=constants.LOADBALANCER, provides=constants.AMPS_DATA)) LOG.info("After plugging the VIP") new_LB_net_subflow.add( network_tasks.ApplyQos(requires=(constants.LOADBALANCER, constants.AMPS_DATA, constants.UPDATE_DICT))) new_LB_net_subflow.add( database_tasks.UpdateAmphoraVIPData(requires=constants.AMPS_DATA)) new_LB_net_subflow.add( database_tasks.ReloadLoadBalancer( name=constants.RELOAD_LB_AFTER_PLUG_VIP, requires=constants.LOADBALANCER_ID, provides=constants.LOADBALANCER)) new_LB_net_subflow.add( network_tasks.GetAmphoraeNetworkConfigs( requires=constants.LOADBALANCER, provides=constants.AMPHORAE_NETWORK_CONFIG)) new_LB_net_subflow.add( database_tasks.GetAmphoraeFromLoadbalancer( requires=constants.LOADBALANCER, provides=constants.AMPHORA)) #new_LB_net_subflow.add(amphora_driver_tasks.AmphoraePostVIPPlug( # requires=(constants.LOADBALANCER, # constants.AMPHORAE_NETWORK_CONFIG))) # Get VThunder details from database #new_LB_net_subflow.add(a10_database_tasks.GetVThunderByLoadBalancer( # requires=constants.LOADBALANCER, # provides=a10constants.VTHUNDER)) new_LB_net_subflow.add( vthunder_tasks.AmphoraePostVIPPlug( requires=(constants.LOADBALANCER, a10constants.VTHUNDER))) new_LB_net_subflow.add( vthunder_tasks.VThunderComputeConnectivityWait( requires=(a10constants.VTHUNDER, constants.AMPHORA))) new_LB_net_subflow.add( vthunder_tasks.EnableInterface(requires=a10constants.VTHUNDER)) LOG.info("AT the end of subflow") return new_LB_net_subflow
def test_plug_vip(self, mock_get_net_driver): mock_driver = mock.MagicMock() mock_get_net_driver.return_value = mock_driver net = network_tasks.PlugVIP() mock_driver.plug_vip.return_value = ["vip"] data = net.execute(LB) mock_driver.plug_vip.assert_called_once_with(LB, LB.vip) self.assertEqual(["vip"], data) # revert net.revert(["vip"], LB) mock_driver.unplug_vip.assert_called_once_with(LB, LB.vip) # revert with exception mock_driver.reset_mock() mock_driver.unplug_vip.side_effect = Exception('UnplugVipException') net.revert(["vip"], LB) mock_driver.unplug_vip.assert_called_once_with(LB, LB.vip)