Esempio n. 1
0
 def get_task_signature(cls, instance, serialized_instance, **kwargs):
     _tasks = [
         core_tasks.BackendMethodTask().si(
             serialized_instance,
             'reset_virtual_machine',
             state_transition='begin_updating',
         )
     ]
     if instance.tools_installed:
         _tasks.append(
             core_tasks.PollBackendCheckTask().si(
                 serialized_instance, 'is_virtual_machine_tools_not_running'
             )
         )
         _tasks.append(
             core_tasks.PollBackendCheckTask().si(
                 serialized_instance, 'is_virtual_machine_tools_running'
             )
         )
     _tasks.append(
         core_tasks.BackendMethodTask().si(
             serialized_instance, 'pull_virtual_machine',
         )
     )
     return chain(_tasks)
Esempio n. 2
0
 def get_instances_cleanup_tasks(cls, serialized_tenant):
     return [
         core_tasks.BackendMethodTask().si(
             serialized_tenant,
             backend_method='delete_tenant_security_groups',
         ),
         core_tasks.BackendMethodTask().si(
             serialized_tenant,
             backend_method='delete_tenant_snapshots',
         ),
         core_tasks.PollBackendCheckTask().si(
             serialized_tenant,
             backend_check_method='are_all_tenant_snapshots_deleted'),
         core_tasks.BackendMethodTask().si(
             serialized_tenant,
             backend_method='delete_tenant_instances',
         ),
         core_tasks.PollBackendCheckTask().si(
             serialized_tenant,
             backend_check_method='are_all_tenant_instances_deleted'),
         core_tasks.BackendMethodTask().si(
             serialized_tenant,
             backend_method='delete_tenant_volumes',
         ),
         core_tasks.PollBackendCheckTask().si(
             serialized_tenant,
             backend_check_method='are_all_tenant_volumes_deleted'),
     ]
Esempio n. 3
0
 def get_task_signature(cls, instance, serialized_instance, **kwargs):
     return chain(
         core_tasks.BackendMethodTask().si(
             serialized_instance, 'reboot_guest', state_transition='begin_updating'
         ),
         core_tasks.PollBackendCheckTask().si(
             serialized_instance, 'is_virtual_machine_tools_not_running'
         ),
         core_tasks.PollBackendCheckTask().si(
             serialized_instance, 'is_virtual_machine_tools_running'
         ),
         core_tasks.BackendMethodTask().si(
             serialized_instance, 'pull_virtual_machine',
         ),
     )
Esempio n. 4
0
    def get_task_signature(cls, backup, serialized_backup, force=False, **kwargs):
        serialized_snapshots = [
            core_utils.serialize_instance(snapshot)
            for snapshot in backup.snapshots.all()
        ]

        _tasks = [
            core_tasks.StateTransitionTask().si(
                serialized_backup, state_transition='begin_deleting'
            )
        ]
        for serialized_snapshot in serialized_snapshots:
            _tasks.append(
                core_tasks.BackendMethodTask().si(
                    serialized_snapshot,
                    'delete_snapshot',
                    state_transition='begin_deleting',
                )
            )
        for serialized_snapshot in serialized_snapshots:
            _tasks.append(
                core_tasks.PollBackendCheckTask().si(
                    serialized_snapshot, 'is_snapshot_deleted'
                )
            )
            _tasks.append(core_tasks.DeletionTask().si(serialized_snapshot))

        return chain(*_tasks)
Esempio n. 5
0
    def get_delete_instance_tasks(cls, instance, serialized_instance, release_floating_ips):
        _tasks = [
            core_tasks.BackendMethodTask().si(
                serialized_instance,
                backend_method='delete_instance',
                state_transition='begin_deleting',
            ),
            core_tasks.PollBackendCheckTask().si(
                serialized_instance,
                backend_check_method='is_instance_deleted',
            ),
        ]
        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:
            serialized_executor = core_utils.serialize_class(openstack_executors.TenantPullFloatingIPsExecutor)
            serialized_tenant = core_utils.serialize_instance(shared_tenant)
            _tasks.append(core_tasks.ExecutorTask().si(serialized_executor, serialized_tenant))

        return _tasks
Esempio n. 6
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.append(core_tasks.BackendMethodTask().si(
            serialized_instance,
            backend_method='delete_instance_internal_ips',
        ))

        for volume in instance.volumes.all():
            if volume.backend_id:
                serialized_volume = core_utils.serialize_instance(volume)
                _tasks.append(core_tasks.BackendMethodTask().si(
                    serialized_volume,
                    'delete_volume',
                    state_transition='begin_deleting'
                ))
                _tasks.append(core_tasks.PollBackendCheckTask().si(
                    serialized_volume,
                    'is_volume_deleted'
                ))

        return _tasks
Esempio n. 7
0
 def get_task_signature(cls, volume, serialized_volume, **kwargs):
     if volume.backend_id:
         return chain(
             core_tasks.BackendMethodTask().si(
                 serialized_volume, 'delete_volume', state_transition='begin_deleting'),
             core_tasks.PollBackendCheckTask().si(serialized_volume, 'is_volume_deleted'),
         )
     else:
         return core_tasks.StateTransitionTask().si(serialized_volume, state_transition='begin_deleting')
Esempio n. 8
0
 def get_task_signature(cls, snapshot, serialized_snapshot, **kwargs):
     if snapshot.backend_id:
         return chain(
             core_tasks.BackendMethodTask().si(
                 serialized_snapshot, 'delete_snapshot', state_transition='begin_deleting'),
             core_tasks.PollBackendCheckTask().si(serialized_snapshot, 'is_snapshot_deleted'),
         )
     else:
         return core_tasks.StateTransitionTask().si(serialized_snapshot, state_transition='begin_deleting')
Esempio n. 9
0
 def get_task_signature(cls, instance, serialized_instance, **kwargs):
     if instance.backend_id:
         return chain(
             core_tasks.BackendMethodTask().si(
                 serialized_instance, backend_method='destroy_vm', state_transition='begin_deleting'),
             core_tasks.PollBackendCheckTask().si(serialized_instance, 'is_vm_deleted'),
         )
     else:
         return core_tasks.StateTransitionTask().si(serialized_instance, state_transition='begin_deleting')
Esempio n. 10
0
 def get_delete_instance_tasks(cls, serialized_instance):
     return [
         core_tasks.BackendMethodTask().si(
             serialized_instance,
             backend_method='delete_instance',
             state_transition='begin_deleting',
         ),
         core_tasks.PollBackendCheckTask().si(
             serialized_instance, backend_check_method='is_instance_deleted',
         ),
     ]
Esempio n. 11
0
    def get_delete_instance_tasks(cls, instance, serialized_instance):
        _tasks = [
            core_tasks.BackendMethodTask().si(
                serialized_instance,
                'delete_instance',
                state_transition='begin_deleting'),
            core_tasks.PollBackendCheckTask().si(serialized_instance,
                                                 'is_instance_deleted'),
            core_tasks.IndependentBackendMethodTask().si(
                serialized_instance, 'pull_networks'),
        ]

        if instance.floating_ip:
            _tasks.append(core_tasks.IndependentBackendMethodTask().si(
                serialized_instance, 'pull_floating_ips'))

        return chain(_tasks)