def get_rack_vthunder_create_listener_flow(self, project_id): """Create a flow to create a rack listener""" create_listener_flow = linear_flow.Flow(constants.CREATE_LISTENER_FLOW) create_listener_flow.add(lifecycle_tasks.ListenerToErrorOnRevertTask( requires=[constants.LISTENER])) create_listener_flow.add(a10_database_tasks.GetVThunderByLoadBalancer( requires=constants.LOADBALANCER, provides=a10constants.VTHUNDER)) create_listener_flow.add(self.handle_ssl_cert_flow(flow_type='create')) create_listener_flow.add(a10_database_tasks.GetFlavorData( rebind={a10constants.LB_RESOURCE: constants.LISTENER}, provides=constants.FLAVOR_DATA)) create_listener_flow.add(nat_pool_tasks.NatPoolCreate( requires=(constants.LOADBALANCER, a10constants.VTHUNDER, constants.FLAVOR_DATA))) create_listener_flow.add(virtual_port_tasks.ListenerCreate( requires=[constants.LOADBALANCER, constants.LISTENER, a10constants.VTHUNDER, constants.FLAVOR_DATA])) create_listener_flow.add(a10_database_tasks. MarkLBAndListenerActiveInDB( requires=[constants.LOADBALANCER, constants.LISTENER])) create_listener_flow.add(vthunder_tasks.WriteMemory( requires=a10constants.VTHUNDER)) create_listener_flow.add(a10_database_tasks.SetThunderUpdatedAt( requires=a10constants.VTHUNDER)) return create_listener_flow
def test_create_nat_pool_with_nat_pool_not_exists_with_nat_pool_list_flavor(self): vthunder = copy.deepcopy(VTHUNDER) mock_nat_pool_task = task.NatPoolCreate() mock_nat_pool_task.axapi_client = self.client_mock self.client_mock.nat.pool.exists.return_value = False self.client_mock.nat.pool.try_get.return_value = None mock_nat_pool_task.execute(LB, vthunder, flavor_data=NAT_POOL_FLAVOR2) args, kwargs = self.client_mock.nat.pool.create.call_args self.assertEqual(kwargs['pool_name'], 'pooln2') self.assertEqual(kwargs['gateway'], '172.16.3.1')
def get_create_rack_vthunder_load_balancer_flow(self, vthunder_conf, topology, listeners=None): """Flow to create rack load balancer""" f_name = constants.CREATE_LOADBALANCER_FLOW lb_create_flow = linear_flow.Flow(f_name) lb_create_flow.add( lifecycle_tasks.LoadBalancerIDToErrorOnRevertTask( requires=constants.LOADBALANCER_ID)) lb_create_flow.add( database_tasks.ReloadLoadBalancer( requires=constants.LOADBALANCER_ID, provides=constants.LOADBALANCER)) lb_create_flow.add( a10_database_tasks.CheckExistingProjectToThunderMappedEntries( inject={a10constants.VTHUNDER_CONFIG: vthunder_conf}, requires=(constants.LOADBALANCER, a10constants.VTHUNDER_CONFIG), provides=a10constants.VTHUNDER_CONFIG)) lb_create_flow.add( a10_database_tasks.CheckExistingThunderToProjectMappedEntries( requires=(constants.LOADBALANCER, a10constants.VTHUNDER_CONFIG))) lb_create_flow.add( self.vthunder_flows.get_rack_vthunder_for_lb_subflow( vthunder_conf=a10constants.VTHUNDER_CONFIG, prefix=constants.ROLE_STANDALONE, role=constants.ROLE_STANDALONE)) post_amp_prefix = constants.POST_LB_AMP_ASSOCIATION_SUBFLOW lb_create_flow.add( self.get_post_lb_rack_vthunder_association_flow( post_amp_prefix, topology, mark_active=(not listeners))) lb_create_flow.add( a10_database_tasks.GetFlavorData( rebind={a10constants.LB_RESOURCE: constants.LOADBALANCER}, provides=constants.FLAVOR_DATA)) lb_create_flow.add( nat_pool_tasks.NatPoolCreate(requires=(constants.LOADBALANCER, a10constants.VTHUNDER, constants.FLAVOR_DATA))) lb_create_flow.add( virtual_server_tasks.CreateVirtualServerTask( requires=(constants.LOADBALANCER, a10constants.VTHUNDER, constants.FLAVOR_DATA), provides=a10constants.STATUS)) lb_create_flow.add( vthunder_tasks.WriteMemory(requires=a10constants.VTHUNDER)) lb_create_flow.add( a10_database_tasks.SetThunderUpdatedAt( requires=a10constants.VTHUNDER)) return lb_create_flow
def test_create_nat_pool_with_nat_pool_exists_with_nat_pool_list_flavor(self): device_pool = {u'pool': {u'uuid': u'eef8b1ea-48dc-11eb-b050-5254000780f9', u'start-address': u'172.16.2.101', u'port-overload': 0, u'a10-url': u'/axapi/v3/ip/nat/pool/pooln1', u'netmask': u'/24', u'end-address': u'172.16.2.102', u'ip-rr': 0, u'gateway': u'172.16.2.1', u'pool-name': u'pooln1'}} vthunder = copy.deepcopy(VTHUNDER) mock_nat_pool_task = task.NatPoolCreate() mock_nat_pool_task.axapi_client = self.client_mock self.client_mock.nat.pool.exists.return_value = True self.client_mock.nat.pool.try_get.return_value = device_pool mock_nat_pool_task.execute(LB, vthunder, flavor_data=NAT_POOL_FLAVOR2) self.client_mock.nat.pool.create.not_called()
def get_create_listener_flow(self, topology): """Flow to create a listener""" create_listener_flow = linear_flow.Flow(constants.CREATE_LISTENER_FLOW) create_listener_flow.add( lifecycle_tasks.ListenerToErrorOnRevertTask( requires=[constants.LISTENER])) create_listener_flow.add( vthunder_tasks.VthunderInstanceBusy( requires=a10constants.COMPUTE_BUSY)) create_listener_flow.add( a10_database_tasks.GetVThunderByLoadBalancer( requires=constants.LOADBALANCER, provides=a10constants.VTHUNDER)) if topology == constants.TOPOLOGY_ACTIVE_STANDBY: create_listener_flow.add( vthunder_tasks.GetMasterVThunder( name=a10constants.GET_MASTER_VTHUNDER, requires=a10constants.VTHUNDER, provides=a10constants.VTHUNDER)) create_listener_flow.add(self.handle_ssl_cert_flow(flow_type='create')) create_listener_flow.add( a10_database_tasks.GetFlavorData( rebind={a10constants.LB_RESOURCE: constants.LISTENER}, provides=constants.FLAVOR_DATA)) create_listener_flow.add( nat_pool_tasks.NatPoolCreate(requires=(constants.LOADBALANCER, a10constants.VTHUNDER, constants.FLAVOR_DATA))) create_listener_flow.add( virtual_port_tasks.ListenerCreate(requires=[ constants.LOADBALANCER, constants.LISTENER, a10constants.VTHUNDER, constants.FLAVOR_DATA ])) create_listener_flow.add( a10_network_tasks.UpdateVIP(requires=constants.LOADBALANCER)) create_listener_flow.add( a10_database_tasks.MarkLBAndListenerActiveInDB( requires=[constants.LOADBALANCER, constants.LISTENER])) create_listener_flow.add( vthunder_tasks.WriteMemory(requires=a10constants.VTHUNDER)) create_listener_flow.add( a10_database_tasks.SetThunderUpdatedAt( requires=a10constants.VTHUNDER)) return create_listener_flow
def get_create_load_balancer_flow(self, topology, listeners=None): """Flow to create a load balancer""" f_name = constants.CREATE_LOADBALANCER_FLOW lb_create_flow = linear_flow.Flow(f_name) lb_create_flow.add( lifecycle_tasks.LoadBalancerIDToErrorOnRevertTask( requires=constants.LOADBALANCER_ID)) # Attaching vThunder to LB in database if topology == constants.TOPOLOGY_ACTIVE_STANDBY: lb_create_flow.add(*self._create_active_standby_topology()) LOG.info("TOPOLOGY ===" + str(topology)) elif topology == constants.TOPOLOGY_SINGLE: lb_create_flow.add(*self._create_single_topology()) LOG.info("TOPOLOGY ===" + str(topology)) else: LOG.error("Unknown topology: %s. Unable to build load balancer.", topology) raise exceptions.InvalidTopology(topology=topology) # IMP: Now creating vThunder config here post_amp_prefix = constants.POST_LB_AMP_ASSOCIATION_SUBFLOW lb_create_flow.add( self.get_post_lb_vthunder_association_flow( post_amp_prefix, topology, mark_active=(not listeners))) lb_create_flow.add( a10_database_tasks.GetFlavorData( rebind={a10constants.LB_RESOURCE: constants.LOADBALANCER}, provides=constants.FLAVOR_DATA)) lb_create_flow.add( nat_pool_tasks.NatPoolCreate(requires=(constants.LOADBALANCER, a10constants.VTHUNDER, constants.FLAVOR_DATA))) lb_create_flow.add( virtual_server_tasks.CreateVirtualServerTask( requires=(constants.LOADBALANCER, a10constants.VTHUNDER, constants.FLAVOR_DATA))) lb_create_flow.add( vthunder_tasks.WriteMemory(requires=a10constants.VTHUNDER)) lb_create_flow.add( a10_database_tasks.SetThunderUpdatedAt( requires=a10constants.VTHUNDER)) return lb_create_flow