Ejemplo n.º 1
0
def task_delete_public_gateway_workflow(self, task_id, cloud_id, region,
                                        public_gateway_id):
    """
    This request deletes a public gateway and detach it from the subnet first.
    @return:
    """

    workflow_steps = list()

    ibm_public_gateway = doosradb.session.query(IBMPublicGateway).filter_by(
        id=public_gateway_id).first()
    if not ibm_public_gateway:
        return

    workflow_steps.append(
        task_detach_public_gateway_from_subnet.si(
            task_id=task_id,
            cloud_id=cloud_id,
            region=region,
            public_gateway_id=public_gateway_id))

    workflow_steps.append(
        task_delete_public_gateway.si(task_id=task_id,
                                      cloud_id=cloud_id,
                                      region=region,
                                      public_gateway_id=public_gateway_id))

    workflow_steps.append(update_ibm_task.si(task_id=task_id))
    chain(workflow_steps).delay()
Ejemplo n.º 2
0
def task_delete_ibm_ike_policy_workflow(self, task_id, cloud_id, region, ike_policy_id):
    """
    This request deletes ike policy and vpn connection
    @return:
    """
    workflow_steps, vpn_connections_tasks_list = list(), list()
    ibm_ike_policy = doosradb.session.query(IBMIKEPolicy).filter_by(id=ike_policy_id).first()
    if not ibm_ike_policy:
        return

    for vpn_connection in ibm_ike_policy.vpn_connections.all():
        vpn_connections_tasks_list.append(task_delete_ibm_vpn_connection.si(task_id=task_id,
                                                                            cloud_id=cloud_id, region=region,
                                                                            vpn_connection_id=vpn_connection.id))

    if vpn_connections_tasks_list and len(vpn_connections_tasks_list) == 1:
        workflow_steps.extend(vpn_connections_tasks_list)
    elif vpn_connections_tasks_list:
        workflow_steps.append(
            chord(group(vpn_connections_tasks_list), update_group_tasks.si(
                task_id=task_id, cloud_id=cloud_id, region=region, message="VPN Connection's Tasks Chord Finisher")))

    workflow_steps.append(task_delete_ibm_ike_policy.si(task_id=task_id,
                                                        cloud_id=cloud_id, region=region,
                                                        ike_policy_id=ibm_ike_policy.id))

    workflow_steps.append(update_ibm_task.si(task_id=task_id))
    chain(workflow_steps).delay()
Ejemplo n.º 3
0
def task_delete_image_workflow(self, task_id, cloud_id, region, image_id):
    """
    This request is workflow for the deletion of image
    @return:
    """
    workflow_steps = list()

    ibm_image = doosradb.session.query(IBMImage).filter_by(id=image_id).first()
    if not ibm_image:
        return

    workflow_steps.append(task_delete_image.si(
        task_id=task_id, cloud_id=cloud_id, region=region, image_id=image_id))
    workflow_steps.append(update_ibm_task.si(task_id=task_id))
    chain(workflow_steps).delay()
Ejemplo n.º 4
0
def task_delete_ibm_vpn_gateway_workflow(self, task_id, cloud_id, region, vpn_id):
    """
    This request is workflow for vpn deletion
    @return:
    """
    workflow_steps = list()

    ibm_vpn_gateway = doosradb.session.query(IBMVpnGateway).filter_by(id=vpn_id).first()
    if not ibm_vpn_gateway:
        return

    workflow_steps.append(task_delete_ibm_vpn_gateway.si(task_id=task_id, cloud_id=cloud_id,
                                                         region=region, vpn_id=vpn_id))

    workflow_steps.append(update_ibm_task.si(task_id=task_id))
    chain(workflow_steps).delay()
Ejemplo n.º 5
0
def task_delete_ibm_security_group_workflow(self, task_id, cloud_id, region, security_group_id):
    """
    This request deletes a security group and detach the instance from it.
    @return:
    """
    workflow_steps = list()
    ibm_security_group = doosradb.session.query(IBMSecurityGroup).filter_by(id=security_group_id).first()
    if not ibm_security_group:
        return

    workflow_steps.append(task_detach_network_interface_from_security_group.si(task_id=task_id, cloud_id=cloud_id,
                                                                               region=region,
                                                                               security_group_id=security_group_id))

    workflow_steps.append(task_delete_ibm_security_group.si(task_id=task_id, cloud_id=cloud_id,
                                                            region=region, security_group_id=security_group_id))

    workflow_steps.append(update_ibm_task.si(task_id=task_id))
    chain(workflow_steps).delay()
Ejemplo n.º 6
0
def task_delete_ibm_security_group_rule_workflow(self, task_id, cloud_id, region, security_group_rule_id):
    """
    This request deletes a security group rule
    @return:
    """

    workflow_steps = list()

    ibm_security_group_rule = doosradb.session.query(IBMSecurityGroupRule).filter_by(id=security_group_rule_id).first()
    if not ibm_security_group_rule:
        return

    workflow_steps.append(task_delete_ibm_security_group_rule.si(task_id=task_id,
                                                                 cloud_id=cloud_id,
                                                                 region=region,
                                                                 security_group_rule_id=security_group_rule_id))

    workflow_steps.append(update_ibm_task.si(task_id=task_id))
    chain(workflow_steps).delay()
Ejemplo n.º 7
0
def task_delete_ibm_floating_ip_workflow(self, task_id, cloud_id, region,
                                         floating_ip_id):
    """
    This request is workflow for deletion of floating ip
    @return:
    """
    workflow_steps = list()

    ibm_floating_ip = doosradb.session.query(IBMFloatingIP).filter_by(
        id=floating_ip_id).first()
    if not ibm_floating_ip:
        return

    workflow_steps.append(
        task_delete_ibm_floating_ip.si(task_id=task_id,
                                       cloud_id=cloud_id,
                                       region=region,
                                       floating_ip_id=floating_ip_id))

    workflow_steps.append(update_ibm_task.si(task_id=task_id))
    chain(workflow_steps).delay()
Ejemplo n.º 8
0
def task_delete_ssh_key_workflow(self, task_id, cloud_id, region, ssh_key_id):
    """
    This request is workflow for the deletion for ssh key
    @return:
    """

    workflow_steps = list()

    ibm_ssh_key = doosradb.session.query(IBMSshKey).filter_by(
        id=ssh_key_id).first()
    if not ibm_ssh_key:
        return

    workflow_steps.append(
        task_delete_ssh_key.si(task_id=task_id,
                               cloud_id=cloud_id,
                               region=region,
                               ssh_key_id=ssh_key_id))

    workflow_steps.append(update_ibm_task.si(task_id=task_id))
    chain(workflow_steps).delay()
Ejemplo n.º 9
0
def task_delete_network_acl_workflow(self, task_id, cloud_id, region,
                                     ibm_network_acl_id):
    """
    This request is a workflow for acl deletion
    @return:
    """
    workflow_steps = list()

    ibm_network_acl = doosradb.session.query(IBMNetworkAcl).filter_by(
        id=ibm_network_acl_id).first()
    if not ibm_network_acl:
        return

    workflow_steps.append(
        task_delete_network_acl.si(task_id=task_id,
                                   cloud_id=cloud_id,
                                   region=region,
                                   ibm_network_acl_id=ibm_network_acl_id))

    workflow_steps.append(update_ibm_task.si(task_id=task_id))
    chain(workflow_steps).delay()
Ejemplo n.º 10
0
def task_delete_address_prefix_workflow(self, task_id, cloud_id, region,
                                        addr_prefix_id):
    """
    This request is workflow for the deletion of address prefix
    @return:
    """
    workflow_steps = list()

    ibm_address_prefix = doosradb.session.query(IBMAddressPrefix).filter_by(
        id=addr_prefix_id).first()
    if not ibm_address_prefix:
        return

    workflow_steps.append(
        task_delete_address_prefix.si(task_id=task_id,
                                      cloud_id=cloud_id,
                                      region=region,
                                      addr_prefix_id=addr_prefix_id))

    workflow_steps.append(update_ibm_task.si(task_id=task_id))
    chain(workflow_steps).delay()
Ejemplo n.º 11
0
def task_delete_ibm_k8s_cluster_workflow(self, task_id, cloud_id, region,
                                         k8s_cluster_id):
    """
    This request is workflow for the K8S Cluster deletion
    @return:
    """

    workflow_steps = list()

    ibm_k8s_cluster = doosradb.session.query(KubernetesCluster).filter_by(
        id=k8s_cluster_id).first()
    if not ibm_k8s_cluster:
        return

    workflow_steps.append(
        task_delete_ibm_k8s_cluster.si(task_id=task_id,
                                       cloud_id=cloud_id,
                                       region=region,
                                       k8s_cluster_id=k8s_cluster_id))

    workflow_steps.append(update_ibm_task.si(task_id=task_id))
    chain(workflow_steps).delay()
Ejemplo n.º 12
0
def task_delete_ibm_load_balancer_workflow(self, task_id, cloud_id, region,
                                           load_balancer_id):
    """
    This request is workflow for the load balancer deletion
    @return:
    """

    workflow_steps = list()

    ibm_load_balancer = doosradb.session.query(IBMLoadBalancer).filter_by(
        id=load_balancer_id).first()
    if not ibm_load_balancer:
        return

    workflow_steps.append(
        task_delete_ibm_load_balancer.si(task_id=task_id,
                                         cloud_id=cloud_id,
                                         region=region,
                                         load_balancer_id=load_balancer_id))

    workflow_steps.append(update_ibm_task.si(task_id=task_id))
    chain(workflow_steps).delay()
Ejemplo n.º 13
0
def task_delete_ibm_subnet_workflow(self, task_id, cloud_id, region,
                                    subnet_id):
    """
    This request deletes a VPC Subnet and its attached resources
    such as vpn gateways and its attached resources,load balancers
    and its attached resources,and the instances and its floating ip
    @return:
    """

    workflow_steps, subnet_tasks_list, floating_ip_tasks_list = list(), list(
    ), list()
    vpn_instance_tasks_list, load_balancer_task_list = list(), list()
    ibm_subnet = doosradb.session.query(IBMSubnet).filter_by(
        id=subnet_id).first()
    if not ibm_subnet:
        return

    for lb in ibm_subnet.ibm_load_balancers:
        load_balancer_task_list.append(
            task_delete_ibm_load_balancer.si(task_id=task_id,
                                             cloud_id=cloud_id,
                                             region=region,
                                             load_balancer_id=lb.id))

    for vpn in ibm_subnet.vpn_gateways.all():
        vpn_instance_tasks_list.append(
            task_delete_ibm_vpn_gateway.si(task_id=task_id,
                                           cloud_id=cloud_id,
                                           region=region,
                                           vpn_id=vpn.id))

    for network_interface in ibm_subnet.network_interfaces.all():
        if network_interface.ibm_instance:
            if network_interface.floating_ip:
                floating_ip_tasks_list.append(
                    task_delete_ibm_floating_ip.si(
                        task_id=task_id,
                        cloud_id=cloud_id,
                        region=region,
                        floating_ip_id=network_interface.floating_ip.id))

        vpn_instance_tasks_list.append(
            task_delete_ibm_instance.si(
                task_id=task_id,
                cloud_id=cloud_id,
                region=region,
                instance_id=network_interface.ibm_instance.id))

    if load_balancer_task_list and len(load_balancer_task_list) == 1:
        workflow_steps.extend(load_balancer_task_list)
    elif load_balancer_task_list:
        workflow_steps.append(
            chord(
                group(load_balancer_task_list),
                update_group_tasks.si(
                    task_id=task_id,
                    cloud_id=cloud_id,
                    region=region,
                    message="Load Balancers Tasks Chord Finisher")))

    if floating_ip_tasks_list and len(floating_ip_tasks_list) == 1:
        workflow_steps.extend(floating_ip_tasks_list)
    elif floating_ip_tasks_list:
        workflow_steps.append(
            chord(
                group(floating_ip_tasks_list),
                update_group_tasks.si(
                    task_id=task_id,
                    cloud_id=cloud_id,
                    region=region,
                    message="Floating IP's Tasks Chord Finisher")))

    if vpn_instance_tasks_list and len(vpn_instance_tasks_list) == 1:
        workflow_steps.extend(vpn_instance_tasks_list)
    elif vpn_instance_tasks_list:
        workflow_steps.append(
            chord(
                group(vpn_instance_tasks_list),
                update_group_tasks.si(
                    task_id=task_id,
                    cloud_id=cloud_id,
                    region=region,
                    message="VPN/VSI's Tasks Chord Finisher")))

    workflow_steps.append(
        task_delete_ibm_subnet.si(task_id=task_id,
                                  cloud_id=cloud_id,
                                  region=region,
                                  subnet_id=ibm_subnet.id))

    workflow_steps.append(update_ibm_task.si(task_id=task_id))
    chain(workflow_steps).delay()