コード例 #1
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
コード例 #2
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
コード例 #3
0
    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
コード例 #4
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
コード例 #5
0
    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
コード例 #6
0
    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
コード例 #7
0
    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