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(
            a10_database_tasks.CountMembersInProject(
                requires=constants.MEMBER, provides=a10constants.MEMBER_COUNT))
        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(
            a10_database_tasks.GetVThunderByLoadBalancer(
                requires=constants.LOADBALANCER,
                provides=a10constants.VTHUNDER))
        delete_member_flow.add(
            server_tasks.MemberDelete(requires=(constants.MEMBER,
                                                a10constants.VTHUNDER,
                                                constants.POOL)))
        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(
            a10_database_tasks.GetVRIDForProjectMember(
                requires=constants.MEMBER, provides=a10constants.VRID))
        delete_member_flow.add(
            a10_network_tasks.DeleteMemberVRIDPort(
                requires=[
                    a10constants.VTHUNDER, a10constants.VRID,
                    a10constants.MEMBER_COUNT
                ],
                provides=a10constants.DELETE_VRID))
        delete_member_flow.add(
            a10_database_tasks.DeleteVRIDEntry(
                requires=[a10constants.VRID, a10constants.DELETE_VRID]))

        return delete_member_flow
 def handle_vrid_for_member_subflow(self):
     handle_vrid_for_member_subflow = linear_flow.Flow(
         a10constants.HANDLE_VRID_MEMBER_SUBFLOW)
     handle_vrid_for_member_subflow.add(
         a10_database_tasks.GetVRIDForProjectMember(
             requires=constants.MEMBER, provides=a10constants.VRID))
     handle_vrid_for_member_subflow.add(
         a10_network_tasks.HandleVRIDFloatingIP(requires=[
             constants.MEMBER, a10constants.VTHUNDER, a10constants.VRID
         ],
                                                provides=a10constants.PORT))
     handle_vrid_for_member_subflow.add(
         a10_database_tasks.UpdateVRIDForProjectMember(requires=[
             constants.MEMBER, a10constants.VRID, a10constants.PORT
         ]))
     return handle_vrid_for_member_subflow
    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(
            a10_database_tasks.GetVThunderByLoadBalancer(
                requires=constants.LOADBALANCER,
                provides=a10constants.VTHUNDER))
        # Handle VRID settings
        update_member_flow.add(
            a10_database_tasks.GetVRIDForProjectMember(
                requires=constants.MEMBER, provides=a10constants.VRID))
        update_member_flow.add(
            a10_network_tasks.HandleVRIDFloatingIP(requires=[
                constants.MEMBER, a10constants.VTHUNDER, a10constants.VRID
            ],
                                                   provides=a10constants.PORT))
        update_member_flow.add(
            a10_database_tasks.UpdateVRIDForProjectMember(requires=[
                constants.MEMBER, a10constants.VRID, a10constants.PORT
            ]))

        update_member_flow.add(
            server_tasks.MemberUpdate(requires=(constants.MEMBER,
                                                a10constants.VTHUNDER)))
        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_delete_member_vrid_subflow(self):
     delete_member_vrid_subflow = linear_flow.Flow(
         a10constants.DELETE_MEMBER_VRID_SUBFLOW)
     delete_member_vrid_subflow.add(
         a10_database_tasks.GetVRIDForProjectMember(
             requires=constants.MEMBER, provides=a10constants.VRID))
     delete_member_vrid_subflow.add(
         a10_network_tasks.DeleteMemberVRIDPort(
             requires=[
                 a10constants.VTHUNDER, a10constants.VRID,
                 a10constants.MEMBER_COUNT
             ],
             provides=a10constants.DELETE_VRID))
     delete_member_vrid_subflow.add(
         a10_database_tasks.DeleteVRIDEntry(
             requires=[a10constants.VRID, a10constants.DELETE_VRID]))
     return delete_member_vrid_subflow
 def get_delete_member_vrid_internal_subflow(self, member_id):
     delete_member_vrid_subflow = linear_flow.Flow(
         a10constants.DELETE_MEMBER_VRID_INTERNAL_SUBFLOW)
     delete_member_vrid_subflow.add(
         a10_database_tasks.GetVRIDForProjectMember(
             name='get_vrid_for_project_member_' + member_id,
             requires=constants.MEMBER,
             provides=a10constants.VRID,
             rebind={constants.MEMBER: member_id}))
     delete_member_vrid_subflow.add(
         a10_network_tasks.DeleteMemberVRIDPort(
             name='delete_member_vrid_port_' + member_id,
             requires=[
                 a10constants.VTHUNDER, a10constants.VRID,
                 a10constants.MEMBER_COUNT
             ],
             provides=a10constants.DELETE_VRID))
     delete_member_vrid_subflow.add(
         a10_database_tasks.DeleteVRIDEntry(
             name='delete_vrid_entry_' + member_id,
             requires=[a10constants.VRID, a10constants.DELETE_VRID]))
     return delete_member_vrid_subflow
 def test_get_vrid_for_project_member(self):
     mock_vrid_entry = task.GetVRIDForProjectMember()
     mock_vrid_entry.vrid_repo = mock.Mock()
     mock_vrid_entry.vrid_repo.get_vrid_from_project_id.return_value = VRID
     vrid = mock_vrid_entry.execute(MEMBER_1)
     self.assertEqual(VRID, vrid)