Esempio n. 1
0
    def get_update_l7policy_flow(self):
        """Create a flow to update an L7 policy

        :returns: The flow for updating an L7 policy
        """
        update_l7policy_flow = linear_flow.Flow(constants.UPDATE_L7POLICY_FLOW)
        update_l7policy_flow.add(
            lifecycle_tasks.L7PolicyToErrorOnRevertTask(requires=[
                constants.L7POLICY, constants.LISTENERS, constants.LOADBALANCER
            ]))
        update_l7policy_flow.add(
            database_tasks.MarkL7PolicyPendingUpdateInDB(
                requires=constants.L7POLICY))
        update_l7policy_flow.add(
            amphora_driver_tasks.ListenersUpdate(
                requires=[constants.LOADBALANCER, constants.LISTENERS]))
        update_l7policy_flow.add(
            database_tasks.UpdateL7PolicyInDB(
                requires=[constants.L7POLICY, constants.UPDATE_DICT]))
        update_l7policy_flow.add(
            database_tasks.MarkL7PolicyActiveInDB(requires=constants.L7POLICY))
        update_l7policy_flow.add(
            database_tasks.MarkLBAndListenersActiveInDB(
                requires=[constants.LOADBALANCER, constants.LISTENERS]))

        return update_l7policy_flow
Esempio n. 2
0
    def get_create_l7rule_flow(self):
        """Create a flow to create an L7 rule

        :returns: The flow for creating an L7 rule
        """
        create_l7rule_flow = linear_flow.Flow(constants.CREATE_L7RULE_FLOW)
        create_l7rule_flow.add(
            lifecycle_tasks.L7RuleToErrorOnRevertTask(requires=[
                constants.L7RULE, constants.LISTENERS, constants.LOADBALANCER
            ]))
        create_l7rule_flow.add(
            database_tasks.MarkL7RulePendingCreateInDB(
                requires=constants.L7RULE))
        create_l7rule_flow.add(
            amphora_driver_tasks.ListenersUpdate(
                requires=[constants.LOADBALANCER, constants.LISTENERS]))
        create_l7rule_flow.add(
            database_tasks.MarkL7RuleActiveInDB(requires=constants.L7RULE))
        create_l7rule_flow.add(
            database_tasks.MarkL7PolicyActiveInDB(requires=constants.L7POLICY))
        create_l7rule_flow.add(
            database_tasks.MarkLBAndListenersActiveInDB(
                requires=[constants.LOADBALANCER, constants.LISTENERS]))

        return create_l7rule_flow
Esempio n. 3
0
    def get_update_health_monitor_flow(self):
        """Create a flow to update a health monitor

        :returns: The flow for updating a health monitor
        """
        update_hm_flow = linear_flow.Flow(constants.UPDATE_HEALTH_MONITOR_FLOW)
        update_hm_flow.add(
            lifecycle_tasks.HealthMonitorToErrorOnRevertTask(requires=[
                constants.HEALTH_MON, constants.LISTENERS,
                constants.LOADBALANCER
            ]))
        update_hm_flow.add(
            database_tasks.MarkHealthMonitorPendingUpdateInDB(
                requires=constants.HEALTH_MON))
        update_hm_flow.add(
            amphora_driver_tasks.ListenersUpdate(
                requires=[constants.LOADBALANCER, constants.LISTENERS]))
        update_hm_flow.add(
            database_tasks.UpdateHealthMonInDB(
                requires=[constants.HEALTH_MON, constants.UPDATE_DICT]))
        update_hm_flow.add(
            database_tasks.MarkHealthMonitorActiveInDB(
                requires=constants.HEALTH_MON))
        update_hm_flow.add(
            database_tasks.MarkPoolActiveInDB(requires=constants.POOL))
        update_hm_flow.add(
            database_tasks.MarkLBAndListenersActiveInDB(
                requires=[constants.LOADBALANCER, constants.LISTENERS]))

        return update_hm_flow
    def get_delete_health_monitor_flow(self, topology):
        """Create a flow to delete a health monitor

        :returns: The flow for deleting a health monitor
        """
        delete_hm_flow = linear_flow.Flow(constants.DELETE_HEALTH_MONITOR_FLOW)
        delete_hm_flow.add(
            lifecycle_tasks.HealthMonitorToErrorOnRevertTask(requires=[
                constants.HEALTH_MON, constants.LISTENERS,
                constants.LOADBALANCER
            ]))
        delete_hm_flow.add(
            vthunder_tasks.VthunderInstanceBusy(
                requires=a10constants.COMPUTE_BUSY))

        delete_hm_flow.add(
            database_tasks.MarkHealthMonitorPendingDeleteInDB(
                requires=constants.HEALTH_MON))
        delete_hm_flow.add(
            model_tasks.DeleteModelObject(
                rebind={constants.OBJECT: constants.HEALTH_MON}))
        delete_hm_flow.add(
            a10_database_tasks.GetVThunderByLoadBalancer(
                requires=constants.LOADBALANCER,
                provides=a10constants.VTHUNDER))
        if topology == constants.TOPOLOGY_ACTIVE_STANDBY:
            delete_hm_flow.add(
                vthunder_tasks.GetMasterVThunder(
                    name=a10constants.GET_MASTER_VTHUNDER,
                    requires=a10constants.VTHUNDER,
                    provides=a10constants.VTHUNDER))
        delete_hm_flow.add(self.get_delete_health_monitor_vthunder_subflow())
        delete_hm_flow.add(
            database_tasks.DeleteHealthMonitorInDB(
                requires=constants.HEALTH_MON))
        delete_hm_flow.add(
            database_tasks.DecrementHealthMonitorQuota(
                requires=constants.HEALTH_MON))
        delete_hm_flow.add(
            database_tasks.UpdatePoolMembersOperatingStatusInDB(
                requires=constants.POOL,
                inject={constants.OPERATING_STATUS: constants.NO_MONITOR}))
        delete_hm_flow.add(
            database_tasks.MarkPoolActiveInDB(requires=constants.POOL))
        delete_hm_flow.add(
            database_tasks.MarkLBAndListenersActiveInDB(
                requires=[constants.LOADBALANCER, constants.LISTENERS]))
        delete_hm_flow.add(
            vthunder_tasks.WriteMemory(
                name=a10constants.WRITE_MEM_FOR_LOCAL_PARTITION,
                requires=(a10constants.VTHUNDER)))
        delete_hm_flow.add(
            vthunder_tasks.WriteMemory(
                name=a10constants.WRITE_MEM_FOR_SHARED_PARTITION,
                requires=(a10constants.VTHUNDER,
                          a10constants.WRITE_MEM_SHARED_PART)))
        delete_hm_flow.add(
            a10_database_tasks.SetThunderUpdatedAt(
                requires=(a10constants.VTHUNDER)))
        return delete_hm_flow
Esempio n. 5
0
    def get_delete_l7policy_flow(self):
        """Create a flow to delete an L7 policy

        :returns: The flow for deleting an L7 policy
        """
        delete_l7policy_flow = linear_flow.Flow(constants.DELETE_L7POLICY_FLOW)
        delete_l7policy_flow.add(
            lifecycle_tasks.L7PolicyToErrorOnRevertTask(requires=[
                constants.L7POLICY, constants.LISTENERS, constants.LOADBALANCER
            ]))
        delete_l7policy_flow.add(
            database_tasks.MarkL7PolicyPendingDeleteInDB(
                requires=constants.L7POLICY))
        delete_l7policy_flow.add(
            model_tasks.DeleteModelObject(
                rebind={constants.OBJECT: constants.L7POLICY}))
        delete_l7policy_flow.add(
            amphora_driver_tasks.ListenersUpdate(
                requires=[constants.LOADBALANCER, constants.LISTENERS]))
        delete_l7policy_flow.add(
            database_tasks.DeleteL7PolicyInDB(requires=constants.L7POLICY))
        delete_l7policy_flow.add(
            database_tasks.MarkLBAndListenersActiveInDB(
                requires=[constants.LOADBALANCER, constants.LISTENERS]))

        return delete_l7policy_flow
Esempio n. 6
0
    def get_create_member_flow(self):
        """Create a flow to create a member

        :returns: The flow for creating a member
        """
        create_member_flow = linear_flow.Flow(constants.CREATE_MEMBER_FLOW)
        create_member_flow.add(
            lifecycle_tasks.MemberToErrorOnRevertTask(requires=[
                constants.MEMBER, constants.LISTENERS, constants.LOADBALANCER,
                constants.POOL
            ]))
        create_member_flow.add(
            database_tasks.MarkMemberPendingCreateInDB(
                requires=constants.MEMBER))
        create_member_flow.add(
            network_tasks.CalculateDelta(requires=constants.LOADBALANCER,
                                         provides=constants.DELTAS))
        create_member_flow.add(
            network_tasks.HandleNetworkDeltas(requires=constants.DELTAS,
                                              provides=constants.ADDED_PORTS))
        create_member_flow.add(
            amphora_driver_tasks.AmphoraePostNetworkPlug(
                requires=(constants.LOADBALANCER, constants.ADDED_PORTS)))
        create_member_flow.add(
            amphora_driver_tasks.ListenersUpdate(
                requires=(constants.LOADBALANCER, constants.LISTENERS)))
        create_member_flow.add(
            database_tasks.MarkMemberActiveInDB(requires=constants.MEMBER))
        create_member_flow.add(
            database_tasks.MarkPoolActiveInDB(requires=constants.POOL))
        create_member_flow.add(
            database_tasks.MarkLBAndListenersActiveInDB(
                requires=(constants.LOADBALANCER, constants.LISTENERS)))

        return create_member_flow
Esempio n. 7
0
    def get_delete_member_flow(self):
        """Create a flow to delete a member

        :returns: The flow for deleting a member
        """
        delete_member_flow = linear_flow.Flow(constants.DELETE_MEMBER_FLOW)
        delete_member_flow.add(
            lifecycle_tasks.MemberToErrorOnRevertTask(requires=[
                constants.MEMBER, constants.LISTENERS, constants.LOADBALANCER,
                constants.POOL
            ]))
        delete_member_flow.add(
            database_tasks.MarkMemberPendingDeleteInDB(
                requires=constants.MEMBER))
        delete_member_flow.add(
            model_tasks.DeleteModelObject(
                rebind={constants.OBJECT: constants.MEMBER}))
        delete_member_flow.add(
            database_tasks.DeleteMemberInDB(requires=constants.MEMBER))
        delete_member_flow.add(
            amphora_driver_tasks.ListenersUpdate(
                requires=[constants.LOADBALANCER, constants.LISTENERS]))
        delete_member_flow.add(
            database_tasks.DecrementMemberQuota(requires=constants.MEMBER))
        delete_member_flow.add(
            database_tasks.MarkPoolActiveInDB(requires=constants.POOL))
        delete_member_flow.add(
            database_tasks.MarkLBAndListenersActiveInDB(
                requires=[constants.LOADBALANCER, constants.LISTENERS]))

        return delete_member_flow
Esempio n. 8
0
    def get_update_member_flow(self):
        """Create a flow to update a member

        :returns: The flow for updating a member
        """
        update_member_flow = linear_flow.Flow(constants.UPDATE_MEMBER_FLOW)
        update_member_flow.add(
            lifecycle_tasks.MemberToErrorOnRevertTask(requires=[
                constants.MEMBER, constants.LISTENERS, constants.LOADBALANCER,
                constants.POOL
            ]))
        update_member_flow.add(
            database_tasks.MarkMemberPendingUpdateInDB(
                requires=constants.MEMBER))
        update_member_flow.add(
            amphora_driver_tasks.ListenersUpdate(
                requires=[constants.LOADBALANCER, constants.LISTENERS]))
        update_member_flow.add(
            database_tasks.UpdateMemberInDB(
                requires=[constants.MEMBER, constants.UPDATE_DICT]))
        update_member_flow.add(
            database_tasks.MarkMemberActiveInDB(requires=constants.MEMBER))
        update_member_flow.add(
            database_tasks.MarkPoolActiveInDB(requires=constants.POOL))
        update_member_flow.add(
            database_tasks.MarkLBAndListenersActiveInDB(
                requires=[constants.LOADBALANCER, constants.LISTENERS]))

        return update_member_flow
Esempio n. 9
0
    def get_delete_pool_flow(self):
        """Create a flow to delete a pool

        :returns: The flow for deleting a pool
        """
        delete_pool_flow = linear_flow.Flow(constants.DELETE_POOL_FLOW)
        delete_pool_flow.add(lifecycle_tasks.PoolToErrorOnRevertTask(
            requires=[constants.POOL,
                      constants.LISTENERS,
                      constants.LOADBALANCER]))
        delete_pool_flow.add(database_tasks.MarkPoolPendingDeleteInDB(
            requires=constants.POOL))
        delete_pool_flow.add(database_tasks.CountPoolChildrenForQuota(
            requires=constants.POOL, provides=constants.POOL_CHILD_COUNT))
        delete_pool_flow.add(model_tasks.DeleteModelObject(
            rebind={constants.OBJECT: constants.POOL}))
        delete_pool_flow.add(amphora_driver_tasks.ListenersUpdate(
            requires=[constants.LOADBALANCER, constants.LISTENERS]))
        delete_pool_flow.add(database_tasks.DeletePoolInDB(
            requires=constants.POOL))
        delete_pool_flow.add(database_tasks.DecrementPoolQuota(
            requires=[constants.POOL, constants.POOL_CHILD_COUNT]))
        delete_pool_flow.add(database_tasks.MarkLBAndListenersActiveInDB(
            requires=[constants.LOADBALANCER, constants.LISTENERS]))

        return delete_pool_flow
Esempio n. 10
0
    def get_create_health_monitor_flow(self, topology):
        """Create a flow to create a health monitor

        :returns: The flow for creating a health monitor
        """
        create_hm_flow = linear_flow.Flow(constants.CREATE_HEALTH_MONITOR_FLOW)
        create_hm_flow.add(
            lifecycle_tasks.HealthMonitorToErrorOnRevertTask(requires=[
                constants.HEALTH_MON, constants.LISTENERS,
                constants.LOADBALANCER
            ]))
        create_hm_flow.add(
            vthunder_tasks.VthunderInstanceBusy(
                requires=a10constants.COMPUTE_BUSY))

        create_hm_flow.add(
            database_tasks.MarkHealthMonitorPendingCreateInDB(
                requires=constants.HEALTH_MON))
        create_hm_flow.add(
            a10_database_tasks.GetVThunderByLoadBalancer(
                requires=constants.LOADBALANCER,
                provides=a10constants.VTHUNDER))
        if topology == constants.TOPOLOGY_ACTIVE_STANDBY:
            create_hm_flow.add(
                vthunder_tasks.GetMasterVThunder(
                    name=a10constants.GET_MASTER_VTHUNDER,
                    requires=a10constants.VTHUNDER,
                    provides=a10constants.VTHUNDER))
        create_hm_flow.add(
            a10_database_tasks.GetFlavorData(
                rebind={a10constants.LB_RESOURCE: constants.LOADBALANCER},
                provides=constants.FLAVOR))
        create_hm_flow.add(
            health_monitor_tasks.CreateAndAssociateHealthMonitor(requires=[
                constants.LISTENERS, constants.HEALTH_MON,
                a10constants.VTHUNDER, constants.FLAVOR
            ]))
        create_hm_flow.add(
            database_tasks.MarkHealthMonitorActiveInDB(
                requires=constants.HEALTH_MON))
        create_hm_flow.add(
            database_tasks.MarkPoolActiveInDB(requires=constants.POOL))
        create_hm_flow.add(
            database_tasks.MarkLBAndListenersActiveInDB(
                requires=[constants.LOADBALANCER, constants.LISTENERS]))
        create_hm_flow.add(
            vthunder_tasks.WriteMemory(
                name=a10constants.WRITE_MEM_FOR_LOCAL_PARTITION,
                requires=(a10constants.VTHUNDER)))
        create_hm_flow.add(
            vthunder_tasks.WriteMemory(
                name=a10constants.WRITE_MEM_FOR_SHARED_PARTITION,
                requires=(a10constants.VTHUNDER,
                          a10constants.WRITE_MEM_SHARED_PART)))
        create_hm_flow.add(
            a10_database_tasks.SetThunderUpdatedAt(
                requires=(a10constants.VTHUNDER)))
        return create_hm_flow
Esempio n. 11
0
    def get_delete_pool_rack_flow(self, members, health_mon, store):
        """Create a flow to delete a pool rack

        :returns: The flow for deleting a pool
        """
        delete_pool_flow = linear_flow.Flow(constants.DELETE_POOL_FLOW)
        delete_pool_flow.add(lifecycle_tasks.PoolToErrorOnRevertTask(
            requires=[constants.POOL,
                      constants.LISTENERS,
                      constants.LOADBALANCER]))
        delete_pool_flow.add(database_tasks.MarkPoolPendingDeleteInDB(
            requires=constants.POOL))
        delete_pool_flow.add(database_tasks.CountPoolChildrenForQuota(
            requires=constants.POOL, provides=constants.POOL_CHILD_COUNT))
        delete_pool_flow.add(model_tasks.DeleteModelObject(
            rebind={constants.OBJECT: constants.POOL}))
        # Get VThunder details from database
        delete_pool_flow.add(a10_database_tasks.GetVThunderByLoadBalancer(
            requires=constants.LOADBALANCER,
            provides=a10constants.VTHUNDER))
        delete_pool_flow.add(virtual_port_tasks.ListenerUpdateForPool(
            requires=[constants.LOADBALANCER, constants.LISTENER, a10constants.VTHUNDER]))
        delete_pool_flow.add(persist_tasks.DeleteSessionPersistence(
            requires=[a10constants.VTHUNDER, constants.POOL]))
        delete_pool_flow.add(vthunder_tasks.SetupDeviceNetworkMap(
            requires=a10constants.VTHUNDER,
            provides=a10constants.VTHUNDER))

        # Device Flavor
        delete_pool_flow.add(a10_database_tasks.GetFlavorData(
            rebind={a10constants.LB_RESOURCE: constants.LOADBALANCER},
            provides=constants.FLAVOR))
        delete_pool_flow.add(vthunder_tasks.GetVthunderConfByFlavor(
            requires=(constants.LOADBALANCER, a10constants.VTHUNDER_CONFIG,
                      a10constants.DEVICE_CONFIG_DICT),
            rebind={constants.FLAVOR_DATA: constants.FLAVOR},
            provides=(a10constants.VTHUNDER_CONFIG, a10constants.USE_DEVICE_FLAVOR)))
        delete_pool_flow.add(a10_network_tasks.GetPoolsOnThunder(
            requires=[a10constants.VTHUNDER, a10constants.USE_DEVICE_FLAVOR],
            provides=a10constants.POOLS))

        # Delete pool children
        delete_pool_flow.add(self._get_delete_health_monitor_vthunder_subflow(health_mon))
        delete_pool_flow.add(self._get_delete_member_vthunder_subflow(members, store))
        delete_pool_flow.add(service_group_tasks.PoolDelete(
            requires=[constants.POOL, a10constants.VTHUNDER]))
        delete_pool_flow.add(database_tasks.DeletePoolInDB(
            requires=constants.POOL))
        delete_pool_flow.add(database_tasks.DecrementPoolQuota(
            requires=[constants.POOL, constants.POOL_CHILD_COUNT]))
        delete_pool_flow.add(database_tasks.MarkLBAndListenersActiveInDB(
            requires=[constants.LOADBALANCER, constants.LISTENERS]))
        delete_pool_flow.add(vthunder_tasks.WriteMemory(
            requires=a10constants.VTHUNDER))
        delete_pool_flow.add(a10_database_tasks.SetThunderUpdatedAt(
            requires=a10constants.VTHUNDER))

        return delete_pool_flow
Esempio n. 12
0
    def get_update_pool_flow(self, topology):
        """Create a flow to update a pool

        :returns: The flow for updating a pool
        """
        update_pool_flow = linear_flow.Flow(constants.UPDATE_POOL_FLOW)
        update_pool_flow.add(
            lifecycle_tasks.PoolToErrorOnRevertTask(requires=[
                constants.POOL, constants.LISTENERS, constants.LOADBALANCER
            ]))
        update_pool_flow.add(
            vthunder_tasks.VthunderInstanceBusy(
                requires=a10constants.COMPUTE_BUSY))

        update_pool_flow.add(
            database_tasks.MarkPoolPendingUpdateInDB(requires=constants.POOL))
        update_pool_flow.add(
            a10_database_tasks.GetVThunderByLoadBalancer(
                requires=constants.LOADBALANCER,
                provides=a10constants.VTHUNDER))
        if topology == constants.TOPOLOGY_ACTIVE_STANDBY:
            update_pool_flow.add(
                vthunder_tasks.GetMasterVThunder(
                    name=a10constants.GET_MASTER_VTHUNDER,
                    requires=a10constants.VTHUNDER,
                    provides=a10constants.VTHUNDER))
        update_pool_flow.add(
            a10_database_tasks.GetFlavorData(
                rebind={a10constants.LB_RESOURCE: constants.POOL},
                provides=constants.FLAVOR))
        update_pool = service_group_tasks.PoolUpdate(requires=[
            constants.POOL, a10constants.VTHUNDER, constants.UPDATE_DICT,
            constants.FLAVOR
        ],
                                                     provides=constants.POOL)
        update_pool_flow.add(*self._get_sess_pers_subflow(update_pool))
        update_pool_flow.add(
            virtual_port_tasks.ListenerUpdateForPool(requires=[
                constants.LOADBALANCER, constants.LISTENER,
                a10constants.VTHUNDER
            ]))
        update_pool_flow.add(
            database_tasks.UpdatePoolInDB(
                requires=[constants.POOL, constants.UPDATE_DICT]))
        update_pool_flow.add(
            database_tasks.MarkPoolActiveInDB(requires=constants.POOL))
        update_pool_flow.add(
            database_tasks.MarkLBAndListenersActiveInDB(
                requires=[constants.LOADBALANCER, constants.LISTENERS]))
        update_pool_flow.add(
            vthunder_tasks.WriteMemory(requires=a10constants.VTHUNDER))
        update_pool_flow.add(
            a10_database_tasks.SetThunderUpdatedAt(
                requires=a10constants.VTHUNDER))

        return update_pool_flow
    def get_update_member_flow(self, topology):
        """Flow to update a member

        :returns: The flow for updating a member
        """
        update_member_flow = linear_flow.Flow(constants.UPDATE_MEMBER_FLOW)
        update_member_flow.add(
            lifecycle_tasks.MemberToErrorOnRevertTask(requires=[
                constants.MEMBER, constants.LISTENERS, constants.LOADBALANCER,
                constants.POOL
            ]))
        update_member_flow.add(
            vthunder_tasks.VthunderInstanceBusy(
                requires=a10constants.COMPUTE_BUSY))

        update_member_flow.add(
            database_tasks.MarkMemberPendingUpdateInDB(
                requires=constants.MEMBER))
        update_member_flow.add(
            a10_database_tasks.GetVThunderByLoadBalancer(
                requires=constants.LOADBALANCER,
                provides=a10constants.VTHUNDER))
        if topology == constants.TOPOLOGY_ACTIVE_STANDBY:
            update_member_flow.add(
                vthunder_tasks.GetMasterVThunder(
                    name=a10constants.GET_MASTER_VTHUNDER,
                    requires=a10constants.VTHUNDER,
                    provides=a10constants.VTHUNDER))
        update_member_flow.add(self.handle_vrid_for_member_subflow())
        update_member_flow.add(
            a10_database_tasks.GetFlavorData(
                rebind={a10constants.LB_RESOURCE: constants.LOADBALANCER},
                provides=constants.FLAVOR))
        update_member_flow.add(
            server_tasks.MemberUpdate(requires=(constants.MEMBER,
                                                a10constants.VTHUNDER,
                                                constants.POOL,
                                                constants.FLAVOR,
                                                constants.UPDATE_DICT)))
        update_member_flow.add(
            database_tasks.UpdateMemberInDB(
                requires=[constants.MEMBER, constants.UPDATE_DICT]))
        update_member_flow.add(
            database_tasks.MarkMemberActiveInDB(requires=constants.MEMBER))
        update_member_flow.add(
            database_tasks.MarkPoolActiveInDB(requires=constants.POOL))
        update_member_flow.add(
            database_tasks.MarkLBAndListenersActiveInDB(
                requires=[constants.LOADBALANCER, constants.LISTENERS]))
        update_member_flow.add(
            vthunder_tasks.WriteMemory(requires=a10constants.VTHUNDER))
        update_member_flow.add(
            a10_database_tasks.SetThunderUpdatedAt(
                requires=a10constants.VTHUNDER))
        return update_member_flow
Esempio n. 14
0
    def get_update_l7rule_flow(self, topology):
        """Create a flow to update an L7 rule
        :returns: The flow for updating an L7 rule
        """
        update_l7rule_flow = linear_flow.Flow(constants.UPDATE_L7RULE_FLOW)
        update_l7rule_flow.add(
            lifecycle_tasks.L7RuleToErrorOnRevertTask(requires=[
                constants.L7RULE, constants.LISTENERS, constants.LOADBALANCER
            ]))
        update_l7rule_flow.add(
            vthunder_tasks.VthunderInstanceBusy(
                requires=a10constants.COMPUTE_BUSY))

        update_l7rule_flow.add(
            database_tasks.MarkL7RulePendingUpdateInDB(
                requires=constants.L7RULE))
        update_l7rule_flow.add(
            a10_database_tasks.GetVThunderByLoadBalancer(
                requires=constants.LOADBALANCER,
                provides=a10constants.VTHUNDER))
        if topology == constants.TOPOLOGY_ACTIVE_STANDBY:
            update_l7rule_flow.add(
                vthunder_tasks.GetMasterVThunder(
                    requires=a10constants.VTHUNDER,
                    provides=a10constants.VTHUNDER))
        update_l7rule_flow.add(
            l7rule_tasks.UpdateL7Rule(requires=[
                constants.L7RULE, constants.LISTENERS, a10constants.VTHUNDER,
                constants.UPDATE_DICT
            ]))
        update_l7rule_flow.add(
            database_tasks.UpdateL7RuleInDB(
                requires=[constants.L7RULE, constants.UPDATE_DICT]))
        update_l7rule_flow.add(
            database_tasks.MarkL7RuleActiveInDB(requires=constants.L7RULE))
        update_l7rule_flow.add(
            database_tasks.MarkL7PolicyActiveInDB(requires=constants.L7POLICY))
        update_l7rule_flow.add(
            database_tasks.MarkLBAndListenersActiveInDB(
                requires=[constants.LOADBALANCER, constants.LISTENERS]))
        update_l7rule_flow.add(
            vthunder_tasks.WriteMemory(requires=a10constants.VTHUNDER))
        update_l7rule_flow.add(
            a10_database_tasks.SetThunderUpdatedAt(
                requires=a10constants.VTHUNDER))
        return update_l7rule_flow
Esempio n. 15
0
    def get_delete_l7rule_flow(self, topology):
        """Create a flow to delete an L7 rule
        :returns: The flow for deleting an L7 rule
        """
        delete_l7rule_flow = linear_flow.Flow(constants.DELETE_L7RULE_FLOW)
        delete_l7rule_flow.add(
            lifecycle_tasks.L7RuleToErrorOnRevertTask(requires=[
                constants.L7RULE, constants.LISTENERS, constants.LOADBALANCER
            ]))
        delete_l7rule_flow.add(
            vthunder_tasks.VthunderInstanceBusy(
                requires=a10constants.COMPUTE_BUSY))

        delete_l7rule_flow.add(
            database_tasks.MarkL7RulePendingDeleteInDB(
                requires=constants.L7RULE))
        delete_l7rule_flow.add(
            model_tasks.DeleteModelObject(
                rebind={constants.OBJECT: constants.L7RULE}))
        delete_l7rule_flow.add(
            a10_database_tasks.GetVThunderByLoadBalancer(
                requires=constants.LOADBALANCER,
                provides=a10constants.VTHUNDER))
        if topology == constants.TOPOLOGY_ACTIVE_STANDBY:
            delete_l7rule_flow.add(
                vthunder_tasks.GetMasterVThunder(
                    name=a10constants.GET_MASTER_VTHUNDER,
                    requires=a10constants.VTHUNDER,
                    provides=a10constants.VTHUNDER))
        delete_l7rule_flow.add(
            l7rule_tasks.DeleteL7Rule(requires=[
                constants.L7RULE, constants.LISTENERS, a10constants.VTHUNDER
            ]))
        delete_l7rule_flow.add(
            database_tasks.DeleteL7RuleInDB(requires=constants.L7RULE))
        delete_l7rule_flow.add(
            database_tasks.MarkL7PolicyActiveInDB(requires=constants.L7POLICY))
        delete_l7rule_flow.add(
            database_tasks.MarkLBAndListenersActiveInDB(
                requires=[constants.LOADBALANCER, constants.LISTENERS]))
        delete_l7rule_flow.add(
            vthunder_tasks.WriteMemory(requires=a10constants.VTHUNDER))
        delete_l7rule_flow.add(
            a10_database_tasks.SetThunderUpdatedAt(
                requires=a10constants.VTHUNDER))
        return delete_l7rule_flow
Esempio n. 16
0
    def get_create_listener_flow(self):
        """Create a flow to create a listener

        :returns: The flow for creating a listener
        """
        create_listener_flow = linear_flow.Flow(constants.CREATE_LISTENER_FLOW)
        create_listener_flow.add(
            lifecycle_tasks.ListenersToErrorOnRevertTask(
                requires=[constants.LOADBALANCER, constants.LISTENERS]))
        create_listener_flow.add(
            amphora_driver_tasks.ListenersUpdate(
                requires=constants.LOADBALANCER))
        create_listener_flow.add(
            network_tasks.UpdateVIP(requires=constants.LOADBALANCER))
        create_listener_flow.add(
            database_tasks.MarkLBAndListenersActiveInDB(
                requires=[constants.LOADBALANCER, constants.LISTENERS]))
        return create_listener_flow
Esempio n. 17
0
    def get_create_l7policy_flow(self, topology):
        """Create a flow to create an L7 policy

        :returns: The flow for creating an L7 policy
        """
        create_l7policy_flow = linear_flow.Flow(constants.CREATE_L7POLICY_FLOW)
        create_l7policy_flow.add(
            lifecycle_tasks.L7PolicyToErrorOnRevertTask(requires=[
                constants.L7POLICY, constants.LISTENERS, constants.LOADBALANCER
            ]))
        create_l7policy_flow.add(
            vthunder_tasks.VthunderInstanceBusy(
                requires=a10constants.COMPUTE_BUSY))

        create_l7policy_flow.add(
            database_tasks.MarkL7PolicyPendingCreateInDB(
                requires=constants.L7POLICY))
        create_l7policy_flow.add(
            a10_database_tasks.GetVThunderByLoadBalancer(
                requires=constants.LOADBALANCER,
                provides=a10constants.VTHUNDER))
        if topology == constants.TOPOLOGY_ACTIVE_STANDBY:
            create_l7policy_flow.add(
                vthunder_tasks.GetMasterVThunder(
                    name=a10constants.GET_MASTER_VTHUNDER,
                    requires=a10constants.VTHUNDER,
                    provides=a10constants.VTHUNDER))
        create_l7policy_flow.add(
            l7policy_tasks.CreateL7Policy(requires=[
                constants.L7POLICY, constants.LISTENERS, a10constants.VTHUNDER
            ]))
        create_l7policy_flow.add(
            database_tasks.MarkL7PolicyActiveInDB(requires=constants.L7POLICY))
        create_l7policy_flow.add(
            database_tasks.MarkLBAndListenersActiveInDB(
                requires=[constants.LOADBALANCER, constants.LISTENERS]))
        create_l7policy_flow.add(
            vthunder_tasks.WriteMemory(requires=a10constants.VTHUNDER))
        create_l7policy_flow.add(
            a10_database_tasks.SetThunderUpdatedAt(
                requires=a10constants.VTHUNDER))
        return create_l7policy_flow
Esempio n. 18
0
    def get_create_pool_flow(self):
        """Create a flow to create a pool

        :returns: The flow for creating a pool
        """
        create_pool_flow = linear_flow.Flow(constants.CREATE_POOL_FLOW)
        create_pool_flow.add(lifecycle_tasks.PoolToErrorOnRevertTask(
            requires=[constants.POOL,
                      constants.LISTENERS,
                      constants.LOADBALANCER]))
        create_pool_flow.add(database_tasks.MarkPoolPendingCreateInDB(
            requires=constants.POOL))
        create_pool_flow.add(amphora_driver_tasks.ListenersUpdate(
            requires=[constants.LOADBALANCER, constants.LISTENERS]))
        create_pool_flow.add(database_tasks.MarkPoolActiveInDB(
            requires=constants.POOL))
        create_pool_flow.add(database_tasks.MarkLBAndListenersActiveInDB(
            requires=[constants.LOADBALANCER, constants.LISTENERS]))

        return create_pool_flow
Esempio n. 19
0
    def get_delete_health_monitor_flow(self):
        """Create a flow to delete a health monitor

        :returns: The flow for deleting a health monitor
        """
        delete_hm_flow = linear_flow.Flow(constants.DELETE_HEALTH_MONITOR_FLOW)
        delete_hm_flow.add(
            lifecycle_tasks.HealthMonitorToErrorOnRevertTask(requires=[
                constants.HEALTH_MON, constants.LISTENERS,
                constants.LOADBALANCER
            ]))
        delete_hm_flow.add(
            database_tasks.MarkHealthMonitorPendingDeleteInDB(
                requires=constants.HEALTH_MON))
        delete_hm_flow.add(
            model_tasks.DeleteModelObject(
                rebind={constants.OBJECT: constants.HEALTH_MON}))
        delete_hm_flow.add(
            amphora_driver_tasks.ListenersUpdate(
                requires=[constants.LOADBALANCER, constants.LISTENERS]))
        delete_hm_flow.add(
            database_tasks.DeleteHealthMonitorInDB(
                requires=constants.HEALTH_MON))
        delete_hm_flow.add(
            database_tasks.DecrementHealthMonitorQuota(
                requires=constants.HEALTH_MON))
        delete_hm_flow.add(
            database_tasks.UpdatePoolMembersOperatingStatusInDB(
                requires=constants.POOL,
                inject={constants.OPERATING_STATUS: constants.NO_MONITOR}))
        delete_hm_flow.add(
            database_tasks.MarkPoolActiveInDB(requires=constants.POOL))
        delete_hm_flow.add(
            database_tasks.MarkLBAndListenersActiveInDB(
                requires=[constants.LOADBALANCER, constants.LISTENERS]))

        return delete_hm_flow
    def get_delete_member_flow(self, topology):
        """Flow to delete a member on VThunder

        :returns: The flow for deleting a member
        """
        delete_member_flow = linear_flow.Flow(constants.DELETE_MEMBER_FLOW)
        delete_member_flow.add(
            lifecycle_tasks.MemberToErrorOnRevertTask(requires=[
                constants.MEMBER, constants.LISTENERS, constants.LOADBALANCER,
                constants.POOL
            ]))
        delete_member_flow.add(
            vthunder_tasks.VthunderInstanceBusy(
                requires=a10constants.COMPUTE_BUSY))

        delete_member_flow.add(
            database_tasks.MarkMemberPendingDeleteInDB(
                requires=constants.MEMBER))
        delete_member_flow.add(
            model_tasks.DeleteModelObject(
                rebind={constants.OBJECT: constants.MEMBER}))
        delete_member_flow.add(
            database_tasks.GetAmphoraeFromLoadbalancer(
                requires=constants.LOADBALANCER_ID,
                provides=constants.AMPHORA))
        delete_member_flow.add(
            a10_database_tasks.GetVThunderByLoadBalancer(
                requires=constants.LOADBALANCER,
                provides=a10constants.VTHUNDER))
        delete_member_flow.add(
            a10_database_tasks.CountMembersWithIP(
                requires=constants.MEMBER,
                provides=a10constants.MEMBER_COUNT_IP))
        delete_member_flow.add(
            a10_database_tasks.CountMembersWithIPPortProtocol(
                requires=(constants.MEMBER, constants.POOL),
                provides=a10constants.MEMBER_COUNT_IP_PORT_PROTOCOL))
        delete_member_flow.add(
            a10_database_tasks.GetFlavorData(
                rebind={a10constants.LB_RESOURCE: constants.LOADBALANCER},
                provides=constants.FLAVOR))
        delete_member_flow.add(
            a10_database_tasks.GetLoadBalancerListByProjectID(
                requires=a10constants.VTHUNDER,
                provides=a10constants.LOADBALANCERS_LIST))
        delete_member_flow.add(
            a10_database_tasks.GetMemberListByProjectID(
                requires=a10constants.VTHUNDER,
                provides=a10constants.MEMBER_LIST))
        delete_member_flow.add(
            a10_network_tasks.CalculateDelta(
                requires=(constants.LOADBALANCER,
                          a10constants.LOADBALANCERS_LIST,
                          a10constants.MEMBER_LIST),
                provides=constants.DELTAS))
        delete_member_flow.add(
            a10_network_tasks.HandleNetworkDeltas(
                requires=constants.DELTAS, provides=constants.ADDED_PORTS))
        if topology == constants.TOPOLOGY_ACTIVE_STANDBY:
            delete_member_flow.add(
                vthunder_tasks.VCSSyncWait(name=a10constants.VCS_SYNC_WAIT,
                                           requires=a10constants.VTHUNDER))
            delete_member_flow.add(
                vthunder_tasks.GetMasterVThunder(
                    name=a10constants.GET_MASTER_VTHUNDER,
                    requires=a10constants.VTHUNDER,
                    provides=a10constants.VTHUNDER))
        delete_member_flow.add(
            vthunder_tasks.AmphoraePostNetworkUnplug(
                requires=(constants.LOADBALANCER, constants.ADDED_PORTS,
                          a10constants.VTHUNDER)))
        delete_member_flow.add(
            vthunder_tasks.VThunderComputeConnectivityWait(
                name=a10constants.VTHUNDER_CONNECTIVITY_WAIT,
                requires=(a10constants.VTHUNDER, constants.AMPHORA)))
        if topology == constants.TOPOLOGY_ACTIVE_STANDBY:
            delete_member_flow.add(
                a10_database_tasks.GetBackupVThunderByLoadBalancer(
                    name=a10constants.GET_BACKUP_VTHUNDER_BY_LB,
                    requires=(constants.LOADBALANCER, a10constants.VTHUNDER),
                    provides=a10constants.BACKUP_VTHUNDER))
            delete_member_flow.add(
                vthunder_tasks.VThunderComputeConnectivityWait(
                    name=a10constants.BACKUP_CONNECTIVITY_WAIT +
                    "-before-unplug",
                    requires=constants.AMPHORA,
                    rebind={
                        a10constants.VTHUNDER: a10constants.BACKUP_VTHUNDER
                    }))
            delete_member_flow.add(
                vthunder_tasks.VCSSyncWait(name='member-unplug-' +
                                           a10constants.VCS_SYNC_WAIT,
                                           requires=a10constants.VTHUNDER))
            delete_member_flow.add(
                vthunder_tasks.GetMasterVThunder(
                    name=a10constants.GET_VTHUNDER_MASTER,
                    requires=a10constants.VTHUNDER,
                    provides=a10constants.VTHUNDER))
        delete_member_flow.add(
            server_tasks.MemberFindNatPool(requires=[
                constants.MEMBER, a10constants.VTHUNDER, constants.POOL,
                constants.FLAVOR
            ],
                                           provides=a10constants.NAT_FLAVOR))
        delete_member_flow.add(
            a10_database_tasks.GetNatPoolEntry(
                requires=[constants.MEMBER, a10constants.NAT_FLAVOR],
                provides=a10constants.NAT_POOL))
        delete_member_flow.add(
            a10_network_tasks.ReleaseSubnetAddressForMember(requires=[
                constants.MEMBER, a10constants.NAT_FLAVOR,
                a10constants.NAT_POOL
            ]))
        delete_member_flow.add(
            a10_database_tasks.DeleteNatPoolEntry(
                requires=a10constants.NAT_POOL))
        delete_member_flow.add(
            server_tasks.MemberDelete(
                requires=(constants.MEMBER, a10constants.VTHUNDER,
                          constants.POOL, a10constants.MEMBER_COUNT_IP,
                          a10constants.MEMBER_COUNT_IP_PORT_PROTOCOL)))
        delete_member_flow.add(self.get_delete_member_vrid_subflow())
        delete_member_flow.add(
            database_tasks.DeleteMemberInDB(requires=constants.MEMBER))
        delete_member_flow.add(
            database_tasks.DecrementMemberQuota(requires=constants.MEMBER))
        delete_member_flow.add(
            database_tasks.MarkPoolActiveInDB(requires=constants.POOL))
        delete_member_flow.add(
            database_tasks.MarkLBAndListenersActiveInDB(
                requires=[constants.LOADBALANCER, constants.LISTENERS]))
        delete_member_flow.add(
            vthunder_tasks.WriteMemory(requires=a10constants.VTHUNDER))
        delete_member_flow.add(
            a10_database_tasks.SetThunderUpdatedAt(
                requires=a10constants.VTHUNDER))
        return delete_member_flow
    def get_rack_vthunder_delete_member_flow(self, vthunder_conf, device_dict):
        """Flow to delete a member in Thunder devices

        :returns: The flow for deleting a member
        """
        delete_member_flow = linear_flow.Flow(constants.DELETE_MEMBER_FLOW)
        delete_member_flow.add(
            lifecycle_tasks.MemberToErrorOnRevertTask(requires=[
                constants.MEMBER, constants.LISTENERS, constants.LOADBALANCER,
                constants.POOL
            ]))
        delete_member_flow.add(
            database_tasks.MarkMemberPendingDeleteInDB(
                requires=constants.MEMBER))
        delete_member_flow.add(
            model_tasks.DeleteModelObject(
                rebind={constants.OBJECT: constants.MEMBER}))
        delete_member_flow.add(
            a10_database_tasks.GetVThunderByLoadBalancer(
                requires=constants.LOADBALANCER,
                provides=a10constants.VTHUNDER))
        delete_member_flow.add(
            vthunder_tasks.SetupDeviceNetworkMap(
                requires=a10constants.VTHUNDER,
                provides=a10constants.VTHUNDER))
        delete_member_flow.add(
            a10_database_tasks.CountMembersWithIP(
                requires=constants.MEMBER,
                provides=a10constants.MEMBER_COUNT_IP))
        delete_member_flow.add(
            a10_database_tasks.CountMembersWithIPPortProtocol(
                requires=(constants.MEMBER, constants.POOL),
                provides=a10constants.MEMBER_COUNT_IP_PORT_PROTOCOL))
        delete_member_flow.add(
            a10_database_tasks.GetFlavorData(
                rebind={a10constants.LB_RESOURCE: constants.LOADBALANCER},
                provides=constants.FLAVOR))
        delete_member_flow.add(
            vthunder_tasks.GetVthunderConfByFlavor(
                inject={
                    a10constants.VTHUNDER_CONFIG: vthunder_conf,
                    a10constants.DEVICE_CONFIG_DICT: device_dict
                },
                requires=(constants.LOADBALANCER, a10constants.VTHUNDER_CONFIG,
                          a10constants.DEVICE_CONFIG_DICT),
                rebind={constants.FLAVOR_DATA: constants.FLAVOR},
                provides=(a10constants.VTHUNDER_CONFIG,
                          a10constants.USE_DEVICE_FLAVOR)))
        delete_member_flow.add(
            a10_network_tasks.GetLBResourceSubnet(
                name=a10constants.GET_LB_RESOURCE_SUBNET,
                rebind={a10constants.LB_RESOURCE: constants.MEMBER},
                provides=constants.SUBNET))
        delete_member_flow.add(
            a10_network_tasks.GetMembersOnThunder(
                requires=[
                    a10constants.VTHUNDER, a10constants.USE_DEVICE_FLAVOR
                ],
                provides=a10constants.MEMBERS))
        delete_member_flow.add(
            a10_database_tasks.CountMembersOnThunderBySubnet(
                requires=[
                    constants.SUBNET, a10constants.USE_DEVICE_FLAVOR,
                    a10constants.MEMBERS
                ],
                provides=a10constants.MEMBER_COUNT_THUNDER))
        delete_member_flow.add(
            server_tasks.MemberFindNatPool(requires=[
                constants.MEMBER, a10constants.VTHUNDER, constants.POOL,
                constants.FLAVOR
            ],
                                           provides=a10constants.NAT_FLAVOR))
        delete_member_flow.add(
            a10_database_tasks.GetNatPoolEntry(
                requires=[constants.MEMBER, a10constants.NAT_FLAVOR],
                provides=a10constants.NAT_POOL))
        delete_member_flow.add(
            a10_network_tasks.ReleaseSubnetAddressForMember(requires=[
                constants.MEMBER, a10constants.NAT_FLAVOR,
                a10constants.NAT_POOL
            ]))
        delete_member_flow.add(
            a10_database_tasks.DeleteNatPoolEntry(
                requires=a10constants.NAT_POOL))
        delete_member_flow.add(
            server_tasks.MemberDelete(
                requires=(constants.MEMBER, a10constants.VTHUNDER,
                          constants.POOL, a10constants.MEMBER_COUNT_IP,
                          a10constants.MEMBER_COUNT_IP_PORT_PROTOCOL)))
        if CONF.a10_global.network_type == 'vlan':
            delete_member_flow.add(
                vthunder_tasks.DeleteInterfaceTagIfNotInUseForMember(
                    requires=[constants.MEMBER, a10constants.VTHUNDER]))
        # Handle VRID setting
        delete_member_flow.add(self.get_delete_member_vrid_subflow())
        delete_member_flow.add(
            database_tasks.DeleteMemberInDB(requires=constants.MEMBER))
        delete_member_flow.add(
            database_tasks.DecrementMemberQuota(requires=constants.MEMBER))
        delete_member_flow.add(
            database_tasks.MarkPoolActiveInDB(requires=constants.POOL))
        delete_member_flow.add(
            database_tasks.MarkLBAndListenersActiveInDB(
                requires=[constants.LOADBALANCER, constants.LISTENERS]))
        delete_member_flow.add(
            vthunder_tasks.WriteMemory(requires=a10constants.VTHUNDER))
        delete_member_flow.add(
            a10_database_tasks.SetThunderUpdatedAt(
                requires=a10constants.VTHUNDER))
        return delete_member_flow
    def get_create_member_flow(self, topology):
        """Create a flow to create a member

        :returns: The flow for creating a member
        """
        create_member_flow = linear_flow.Flow(constants.CREATE_MEMBER_FLOW)
        create_member_flow.add(
            lifecycle_tasks.MemberToErrorOnRevertTask(requires=[
                constants.MEMBER, constants.LISTENERS, constants.LOADBALANCER,
                constants.POOL
            ]))
        create_member_flow.add(
            vthunder_tasks.VthunderInstanceBusy(
                requires=a10constants.COMPUTE_BUSY))

        create_member_flow.add(
            database_tasks.MarkMemberPendingCreateInDB(
                requires=constants.MEMBER))
        create_member_flow.add(
            a10_database_tasks.GetVThunderByLoadBalancer(
                requires=constants.LOADBALANCER,
                provides=a10constants.VTHUNDER))
        create_member_flow.add(
            a10_database_tasks.GetLoadBalancerListByProjectID(
                requires=a10constants.VTHUNDER,
                provides=a10constants.LOADBALANCERS_LIST))
        create_member_flow.add(
            database_tasks.GetAmphoraeFromLoadbalancer(
                requires=constants.LOADBALANCER_ID,
                provides=constants.AMPHORA))
        create_member_flow.add(
            a10_database_tasks.GetMemberListByProjectID(
                requires=a10constants.VTHUNDER,
                provides=a10constants.MEMBER_LIST))
        create_member_flow.add(
            a10_network_tasks.CalculateDelta(
                requires=(constants.LOADBALANCER,
                          a10constants.LOADBALANCERS_LIST,
                          a10constants.MEMBER_LIST),
                provides=constants.DELTAS))
        create_member_flow.add(
            a10_network_tasks.HandleNetworkDeltas(
                requires=constants.DELTAS, provides=constants.ADDED_PORTS))
        if topology == constants.TOPOLOGY_ACTIVE_STANDBY:
            create_member_flow.add(
                vthunder_tasks.VCSSyncWait(
                    name="vcs_sync_wait_before_probe_device",
                    requires=a10constants.VTHUNDER))
            create_member_flow.add(
                vthunder_tasks.GetMasterVThunder(
                    name=a10constants.GET_VTHUNDER_MASTER,
                    requires=a10constants.VTHUNDER,
                    provides=a10constants.VTHUNDER))
        # managing interface additions here
        create_member_flow.add(
            vthunder_tasks.AmphoraePostMemberNetworkPlug(
                requires=(constants.LOADBALANCER, constants.ADDED_PORTS,
                          a10constants.VTHUNDER)))
        create_member_flow.add(
            vthunder_tasks.VThunderComputeConnectivityWait(
                name=a10constants.VTHUNDER_CONNECTIVITY_WAIT,
                requires=(a10constants.VTHUNDER, constants.AMPHORA)))
        if topology == constants.TOPOLOGY_ACTIVE_STANDBY:
            create_member_flow.add(
                a10_database_tasks.GetBackupVThunderByLoadBalancer(
                    name="get_backup_vThunder",
                    requires=(constants.LOADBALANCER, a10constants.VTHUNDER),
                    provides=a10constants.BACKUP_VTHUNDER))
            create_member_flow.add(
                vthunder_tasks.VThunderComputeConnectivityWait(
                    name="backup_compute_conn_wait_before_probe_device",
                    requires=constants.AMPHORA,
                    rebind={
                        a10constants.VTHUNDER: a10constants.BACKUP_VTHUNDER
                    }))
            create_member_flow.add(
                vthunder_tasks.VCSSyncWait(name="backup-plug-wait-vcs-ready",
                                           requires=a10constants.VTHUNDER))
            create_member_flow.add(
                vthunder_tasks.GetMasterVThunder(
                    name=a10constants.GET_MASTER_VTHUNDER,
                    requires=a10constants.VTHUNDER,
                    provides=a10constants.VTHUNDER))
        create_member_flow.add(
            vthunder_tasks.EnableInterfaceForMembers(requires=[
                constants.ADDED_PORTS, constants.LOADBALANCER,
                a10constants.VTHUNDER
            ]))
        create_member_flow.add(self.handle_vrid_for_member_subflow())
        create_member_flow.add(
            a10_database_tasks.CountMembersWithIP(
                requires=constants.MEMBER,
                provides=a10constants.MEMBER_COUNT_IP))
        create_member_flow.add(
            vthunder_tasks.AllowLoadbalancerForwardWithAnySource(
                name=a10constants.ALLOW_NO_SNAT,
                requires=(constants.MEMBER, constants.AMPHORA)))
        create_member_flow.add(
            a10_database_tasks.GetFlavorData(
                rebind={a10constants.LB_RESOURCE: constants.LOADBALANCER},
                provides=constants.FLAVOR))
        create_member_flow.add(self.get_create_member_snat_pool_subflow())
        create_member_flow.add(
            server_tasks.MemberCreate(requires=(constants.MEMBER,
                                                a10constants.VTHUNDER,
                                                constants.POOL,
                                                a10constants.MEMBER_COUNT_IP,
                                                constants.FLAVOR)))
        create_member_flow.add(
            database_tasks.MarkMemberActiveInDB(requires=constants.MEMBER))
        create_member_flow.add(
            database_tasks.MarkPoolActiveInDB(requires=constants.POOL))
        create_member_flow.add(
            database_tasks.MarkLBAndListenersActiveInDB(
                requires=(constants.LOADBALANCER, constants.LISTENERS)))
        create_member_flow.add(
            vthunder_tasks.WriteMemory(requires=a10constants.VTHUNDER))
        create_member_flow.add(
            a10_database_tasks.SetThunderUpdatedAt(
                requires=a10constants.VTHUNDER))
        return create_member_flow
Esempio n. 23
0
    def get_batch_update_members_flow(self, old_members, new_members,
                                      updated_members):
        """Create a flow to batch update members

        :returns: The flow for batch updating members
        """
        batch_update_members_flow = linear_flow.Flow(
            constants.BATCH_UPDATE_MEMBERS_FLOW)
        unordered_members_flow = unordered_flow.Flow(
            constants.UNORDERED_MEMBER_UPDATES_FLOW)
        unordered_members_active_flow = unordered_flow.Flow(
            constants.UNORDERED_MEMBER_ACTIVE_FLOW)

        # Delete old members
        unordered_members_flow.add(
            lifecycle_tasks.MembersToErrorOnRevertTask(
                inject={constants.MEMBERS: old_members},
                name='{flow}-deleted'.format(
                    flow=constants.MEMBER_TO_ERROR_ON_REVERT_FLOW)))
        for m in old_members:
            unordered_members_flow.add(
                model_tasks.DeleteModelObject(
                    inject={constants.OBJECT: m},
                    name='{flow}-{id}'.format(
                        id=m.id, flow=constants.DELETE_MODEL_OBJECT_FLOW)))
            unordered_members_flow.add(
                database_tasks.DeleteMemberInDB(
                    inject={constants.MEMBER: m},
                    name='{flow}-{id}'.format(
                        id=m.id, flow=constants.DELETE_MEMBER_INDB)))
            unordered_members_flow.add(
                database_tasks.DecrementMemberQuota(
                    inject={constants.MEMBER: m},
                    name='{flow}-{id}'.format(
                        id=m.id, flow=constants.DECREMENT_MEMBER_QUOTA_FLOW)))

        # Create new members
        unordered_members_flow.add(
            lifecycle_tasks.MembersToErrorOnRevertTask(
                inject={constants.MEMBERS: new_members},
                name='{flow}-created'.format(
                    flow=constants.MEMBER_TO_ERROR_ON_REVERT_FLOW)))
        for m in new_members:
            unordered_members_active_flow.add(
                database_tasks.MarkMemberActiveInDB(
                    inject={constants.MEMBER: m},
                    name='{flow}-{id}'.format(
                        id=m.id, flow=constants.MARK_MEMBER_ACTIVE_INDB)))

        # Update existing members
        unordered_members_flow.add(
            lifecycle_tasks.MembersToErrorOnRevertTask(
                # updated_members is a list of (obj, dict), only pass `obj`
                inject={constants.MEMBERS: [m[0] for m in updated_members]},
                name='{flow}-updated'.format(
                    flow=constants.MEMBER_TO_ERROR_ON_REVERT_FLOW)))
        for m, um in updated_members:
            um.pop('id', None)
            unordered_members_active_flow.add(
                database_tasks.MarkMemberActiveInDB(
                    inject={constants.MEMBER: m},
                    name='{flow}-{id}'.format(
                        id=m.id, flow=constants.MARK_MEMBER_ACTIVE_INDB)))

        batch_update_members_flow.add(unordered_members_flow)

        # Done, do real updates
        batch_update_members_flow.add(
            network_tasks.CalculateDelta(requires=constants.LOADBALANCER,
                                         provides=constants.DELTAS))
        batch_update_members_flow.add(
            network_tasks.HandleNetworkDeltas(requires=constants.DELTAS,
                                              provides=constants.ADDED_PORTS))
        batch_update_members_flow.add(
            amphora_driver_tasks.AmphoraePostNetworkPlug(
                requires=(constants.LOADBALANCER, constants.ADDED_PORTS)))

        # Update the Listener (this makes the changes active on the Amp)
        batch_update_members_flow.add(
            amphora_driver_tasks.ListenersUpdate(
                requires=(constants.LOADBALANCER, constants.LISTENERS)))

        # Mark all the members ACTIVE here, then pool then LB/Listeners
        batch_update_members_flow.add(unordered_members_active_flow)
        batch_update_members_flow.add(
            database_tasks.MarkPoolActiveInDB(requires=constants.POOL))
        batch_update_members_flow.add(
            database_tasks.MarkLBAndListenersActiveInDB(
                requires=(constants.LOADBALANCER, constants.LISTENERS)))

        return batch_update_members_flow
    def get_rack_vthunder_update_member_flow(self, vthunder_conf, device_dict):
        """Flow to update a member in Thunder devices

        :returns: The flow for updating a member
        """
        update_member_flow = linear_flow.Flow(constants.UPDATE_MEMBER_FLOW)
        update_member_flow.add(
            lifecycle_tasks.MemberToErrorOnRevertTask(requires=[
                constants.MEMBER, constants.LISTENERS, constants.LOADBALANCER,
                constants.POOL
            ]))
        update_member_flow.add(
            database_tasks.MarkMemberPendingUpdateInDB(
                requires=constants.MEMBER))
        update_member_flow.add(
            a10_database_tasks.GetVThunderByLoadBalancer(
                requires=constants.LOADBALANCER,
                provides=a10constants.VTHUNDER))
        update_member_flow.add(
            vthunder_tasks.SetupDeviceNetworkMap(
                requires=a10constants.VTHUNDER,
                provides=a10constants.VTHUNDER))

        # For device flavor
        update_member_flow.add(
            a10_database_tasks.GetFlavorData(
                rebind={a10constants.LB_RESOURCE: constants.LOADBALANCER},
                provides=constants.FLAVOR))
        update_member_flow.add(
            vthunder_tasks.GetVthunderConfByFlavor(
                inject={
                    a10constants.VTHUNDER_CONFIG: vthunder_conf,
                    a10constants.DEVICE_CONFIG_DICT: device_dict
                },
                requires=(constants.LOADBALANCER, a10constants.VTHUNDER_CONFIG,
                          a10constants.DEVICE_CONFIG_DICT),
                rebind={constants.FLAVOR_DATA: constants.FLAVOR},
                provides=(a10constants.VTHUNDER_CONFIG,
                          a10constants.USE_DEVICE_FLAVOR)))

        # Handle VRID settings
        update_member_flow.add(self.handle_vrid_for_member_subflow())
        update_member_flow.add(
            server_tasks.MemberUpdate(requires=(constants.MEMBER,
                                                a10constants.VTHUNDER,
                                                constants.POOL,
                                                constants.FLAVOR,
                                                constants.UPDATE_DICT)))
        update_member_flow.add(
            database_tasks.UpdateMemberInDB(
                requires=[constants.MEMBER, constants.UPDATE_DICT]))
        if CONF.a10_global.network_type == 'vlan':
            update_member_flow.add(
                vthunder_tasks.TagInterfaceForMember(
                    requires=[constants.MEMBER, a10constants.VTHUNDER]))
        update_member_flow.add(
            database_tasks.MarkMemberActiveInDB(requires=constants.MEMBER))
        update_member_flow.add(
            database_tasks.MarkPoolActiveInDB(requires=constants.POOL))
        update_member_flow.add(
            database_tasks.MarkLBAndListenersActiveInDB(
                requires=[constants.LOADBALANCER, constants.LISTENERS]))
        update_member_flow.add(
            vthunder_tasks.WriteMemory(requires=a10constants.VTHUNDER))
        update_member_flow.add(
            a10_database_tasks.SetThunderUpdatedAt(
                requires=a10constants.VTHUNDER))
        return update_member_flow
    def get_rack_vthunder_create_member_flow(self, vthunder_conf, device_dict):
        """Create a flow to create a rack vthunder member

        :returns: The flow for creating a rack vthunder member
        """
        create_member_flow = linear_flow.Flow(constants.CREATE_MEMBER_FLOW)
        create_member_flow.add(
            lifecycle_tasks.MemberToErrorOnRevertTask(requires=[
                constants.MEMBER, constants.LISTENERS, constants.LOADBALANCER,
                constants.POOL
            ]))
        create_member_flow.add(
            database_tasks.MarkMemberPendingCreateInDB(
                requires=constants.MEMBER))
        create_member_flow.add(
            a10_database_tasks.GetVThunderByLoadBalancer(
                requires=constants.LOADBALANCER,
                provides=a10constants.VTHUNDER))
        create_member_flow.add(
            vthunder_tasks.SetupDeviceNetworkMap(
                requires=a10constants.VTHUNDER,
                provides=a10constants.VTHUNDER))
        create_member_flow.add(
            a10_database_tasks.GetFlavorData(
                rebind={a10constants.LB_RESOURCE: constants.LOADBALANCER},
                provides=constants.FLAVOR))
        create_member_flow.add(
            vthunder_tasks.GetVthunderConfByFlavor(
                inject={
                    a10constants.VTHUNDER_CONFIG: vthunder_conf,
                    a10constants.DEVICE_CONFIG_DICT: device_dict
                },
                requires=(constants.LOADBALANCER, a10constants.VTHUNDER_CONFIG,
                          a10constants.DEVICE_CONFIG_DICT),
                rebind={constants.FLAVOR_DATA: constants.FLAVOR},
                provides=(a10constants.VTHUNDER_CONFIG,
                          a10constants.USE_DEVICE_FLAVOR)))
        create_member_flow.add(self.handle_vrid_for_member_subflow())
        if CONF.a10_global.network_type == 'vlan':
            create_member_flow.add(
                vthunder_tasks.TagInterfaceForMember(
                    requires=[constants.MEMBER, a10constants.VTHUNDER]))
        create_member_flow.add(
            a10_database_tasks.CountMembersWithIP(
                requires=constants.MEMBER,
                provides=a10constants.MEMBER_COUNT_IP))
        create_member_flow.add(self.get_create_member_snat_pool_subflow())
        create_member_flow.add(
            server_tasks.MemberCreate(requires=(constants.MEMBER,
                                                a10constants.VTHUNDER,
                                                constants.POOL,
                                                a10constants.MEMBER_COUNT_IP,
                                                constants.FLAVOR)))
        create_member_flow.add(
            database_tasks.MarkMemberActiveInDB(requires=constants.MEMBER))
        create_member_flow.add(
            database_tasks.MarkPoolActiveInDB(requires=constants.POOL))
        create_member_flow.add(
            database_tasks.MarkLBAndListenersActiveInDB(
                requires=(constants.LOADBALANCER, constants.LISTENERS)))
        create_member_flow.add(
            vthunder_tasks.WriteMemory(requires=a10constants.VTHUNDER))
        create_member_flow.add(
            a10_database_tasks.SetThunderUpdatedAt(
                requires=a10constants.VTHUNDER))
        return create_member_flow
Esempio n. 26
0
    def get_delete_pool_flow(self, members, health_mon, store, topology):
        """Create a flow to delete a pool

        :returns: The flow for deleting a pool
        """
        delete_pool_flow = linear_flow.Flow(constants.DELETE_POOL_FLOW)
        delete_pool_flow.add(
            lifecycle_tasks.PoolToErrorOnRevertTask(requires=[
                constants.POOL, constants.LISTENERS, constants.LOADBALANCER
            ]))
        delete_pool_flow.add(
            vthunder_tasks.VthunderInstanceBusy(
                requires=a10constants.COMPUTE_BUSY))

        delete_pool_flow.add(
            database_tasks.MarkPoolPendingDeleteInDB(requires=constants.POOL))
        delete_pool_flow.add(
            database_tasks.CountPoolChildrenForQuota(
                requires=constants.POOL, provides=constants.POOL_CHILD_COUNT))
        delete_pool_flow.add(
            model_tasks.DeleteModelObject(
                rebind={constants.OBJECT: constants.POOL}))
        # Get VThunder details from database
        delete_pool_flow.add(
            a10_database_tasks.GetVThunderByLoadBalancer(
                requires=constants.LOADBALANCER,
                provides=a10constants.VTHUNDER))
        if topology == constants.TOPOLOGY_ACTIVE_STANDBY:
            delete_pool_flow.add(
                vthunder_tasks.GetMasterVThunder(
                    name=a10constants.GET_MASTER_VTHUNDER,
                    requires=a10constants.VTHUNDER,
                    provides=a10constants.VTHUNDER))
        delete_pool_flow.add(
            virtual_port_tasks.ListenerUpdateForPool(requires=[
                constants.LOADBALANCER, constants.LISTENER,
                a10constants.VTHUNDER
            ]))
        delete_pool_flow.add(
            persist_tasks.DeleteSessionPersistence(
                requires=[a10constants.VTHUNDER, constants.POOL]))
        # Delete pool children
        delete_pool_flow.add(
            self._get_delete_health_monitor_vthunder_subflow(health_mon))
        delete_pool_flow.add(
            self._get_delete_member_vthunder_subflow(members, store))
        delete_pool_flow.add(
            service_group_tasks.PoolDelete(
                requires=[constants.POOL, a10constants.VTHUNDER]))
        delete_pool_flow.add(
            database_tasks.DeletePoolInDB(requires=constants.POOL))
        # Interface delete.
        delete_pool_flow.add(
            a10_database_tasks.GetLoadBalancerListByProjectID(
                requires=a10constants.VTHUNDER,
                provides=a10constants.LOADBALANCERS_LIST))
        delete_pool_flow.add(
            a10_database_tasks.GetMemberListByProjectID(
                requires=a10constants.VTHUNDER,
                provides=a10constants.MEMBER_LIST))
        delete_pool_flow.add(
            a10_network_tasks.CalculateDelta(
                requires=(constants.LOADBALANCER,
                          a10constants.LOADBALANCERS_LIST,
                          a10constants.MEMBER_LIST),
                provides=constants.DELTAS))
        delete_pool_flow.add(
            a10_network_tasks.HandleNetworkDeltas(
                requires=constants.DELTAS, provides=constants.ADDED_PORTS))
        delete_pool_flow.add(
            vthunder_tasks.AmphoraePostNetworkUnplug(
                requires=(constants.LOADBALANCER, constants.ADDED_PORTS,
                          a10constants.VTHUNDER)))
        delete_pool_flow.add(
            database_tasks.GetAmphoraeFromLoadbalancer(
                requires=constants.LOADBALANCER_ID,
                provides=constants.AMPHORA))
        delete_pool_flow.add(
            vthunder_tasks.VThunderComputeConnectivityWait(
                requires=(a10constants.VTHUNDER, constants.AMPHORA)))
        delete_pool_flow.add(
            database_tasks.DecrementPoolQuota(
                requires=[constants.POOL, constants.POOL_CHILD_COUNT]))
        delete_pool_flow.add(
            database_tasks.MarkLBAndListenersActiveInDB(
                requires=[constants.LOADBALANCER, constants.LISTENERS]))
        delete_pool_flow.add(
            vthunder_tasks.WriteMemory(requires=a10constants.VTHUNDER))
        delete_pool_flow.add(
            a10_database_tasks.SetThunderUpdatedAt(
                requires=a10constants.VTHUNDER))

        return delete_pool_flow