示例#1
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
    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
    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