Ejemplo n.º 1
0
    def get_release_floating_ips_tasks(cls, instance, release_floating_ips):
        _tasks = []
        if release_floating_ips:
            for index, floating_ip in enumerate(instance.floating_ips):
                _tasks.append(
                    core_tasks.BackendMethodTask()
                    .si(
                        core_utils.serialize_instance(floating_ip),
                        'delete_floating_ip',
                    )
                    .set(countdown=5 if not index else 0)
                )
        else:
            # pull related floating IPs state after instance deletion
            for index, floating_ip in enumerate(instance.floating_ips):
                _tasks.append(
                    core_tasks.BackendMethodTask()
                    .si(
                        core_utils.serialize_instance(floating_ip),
                        'pull_floating_ip_runtime_state',
                    )
                    .set(countdown=5 if not index else 0)
                )

        shared_tenant = instance.service_project_link.service.settings.scope
        if shared_tenant and isinstance(shared_tenant, openstack_models.Tenant):
            serialized_tenant = core_utils.serialize_instance(shared_tenant)
            _tasks.append(core_tasks.PollStateTask().si(serialized_tenant))
            _tasks.append(
                openstack_executors.TenantPullFloatingIPsExecutor.as_signature(
                    shared_tenant
                )
            )

        return _tasks
Ejemplo n.º 2
0
    def create_floating_ips(cls, instance, serialized_instance):
        _tasks = []

        if not instance.floating_ips.exists():
            return _tasks

        # Create non-existing floating IPs
        for floating_ip in instance.floating_ips.filter(backend_id=''):
            serialized_floating_ip = core_utils.serialize_instance(floating_ip)
            _tasks.append(core_tasks.BackendMethodTask().si(
                serialized_floating_ip, 'create_floating_ip'))

        # Push instance floating IPs
        _tasks.append(core_tasks.BackendMethodTask().si(
            serialized_instance, 'push_instance_floating_ips'))

        # Wait for operation completion
        for index, floating_ip in enumerate(instance.floating_ips):
            _tasks.append(core_tasks.PollRuntimeStateTask().si(
                core_utils.serialize_instance(floating_ip),
                backend_pull_method='pull_floating_ip_runtime_state',
                success_state='ACTIVE',
                erred_state='ERRED',
            ).set(countdown=5 if not index else 0))

        shared_tenant = instance.service_settings.scope
        if shared_tenant:
            serialized_tenant = core_utils.serialize_instance(shared_tenant)
            _tasks.append(core_tasks.PollStateTask().si(serialized_tenant))
            _tasks.append(
                openstack_executors.TenantPullFloatingIPsExecutor.as_signature(
                    shared_tenant))

        return _tasks
Ejemplo n.º 3
0
    def get_delete_incomplete_instance_tasks(cls, instance, serialized_instance):
        _tasks = []

        _tasks.append(
            core_tasks.StateTransitionTask().si(
                serialized_instance, state_transition='begin_deleting'
            )
        )

        _tasks += cls.get_delete_internal_ips_tasks(serialized_instance)

        for volume in instance.volumes.all():
            if volume.backend_id:
                serialized_volume = core_utils.serialize_instance(volume)
                _tasks.append(core_tasks.PollStateTask().si(serialized_volume))
                _tasks.append(VolumeDeleteExecutor.as_signature(volume))

        _tasks += [tasks.DeleteIncompleteInstanceTask().si(serialized_instance)]

        return _tasks