Example #1
0
    def create(self, req, body):
        # TODO(alexpilotti): validate body
        migration_body = body.get("migration", {})
        context = req.environ['coriolis.context']
        context.can(migration_policies.get_migrations_policy_label("create"))

        replica_id = migration_body.get("replica_id")
        if replica_id:
            clone_disks = migration_body.get("clone_disks", True)
            force = migration_body.get("force", False)
            skip_os_morphing = migration_body.get("skip_os_morphing", False)

            # NOTE: destination environment for replica should have been
            # validated upon its creation.
            migration = self._migration_api.deploy_replica_instances(
                context, replica_id, clone_disks, force, skip_os_morphing)
        else:
            (origin_endpoint_id, destination_endpoint_id, source_environment,
             destination_environment, instances, notes, skip_os_morphing,
             network_map, storage_mappings) = self._validate_migration_input(
                 context, migration_body)
            migration = self._migration_api.migrate_instances(
                context, origin_endpoint_id, destination_endpoint_id,
                source_environment, destination_environment, instances,
                network_map, storage_mappings, notes, skip_os_morphing)

        return migration_view.single(req, migration)
Example #2
0
    def show(self, req, id):
        migration = self._migration_api.get_migration(
            req.environ["coriolis.context"], id)
        if not migration:
            raise exc.HTTPNotFound()

        return migration_view.single(req, migration)
Example #3
0
    def show(self, req, id):
        context = req.environ["coriolis.context"]
        context.can(migration_policies.get_migrations_policy_label("show"))
        migration = self._migration_api.get_migration(context, id)
        if not migration:
            raise exc.HTTPNotFound()

        return migration_view.single(req, migration)
Example #4
0
    def create(self, req, body):
        migration_body = body.get("migration", {})
        context = req.environ['coriolis.context']
        context.can(migration_policies.get_migrations_policy_label("create"))
        user_scripts = migration_body.get('user_scripts', {})
        api_utils.validate_user_scripts(user_scripts)
        user_scripts = api_utils.normalize_user_scripts(
            user_scripts, migration_body.get("instances", []))
        replica_id = migration_body.get("replica_id")
        if replica_id:
            clone_disks = migration_body.get("clone_disks", True)
            force = migration_body.get("force", False)
            skip_os_morphing = migration_body.get("skip_os_morphing", False)
            instance_osmorphing_minion_pool_mappings = migration_body.get(
                'instance_osmorphing_minion_pool_mappings', {})

            # NOTE: destination environment for replica should have been
            # validated upon its creation.
            migration = self._migration_api.deploy_replica_instances(
                context, replica_id, instance_osmorphing_minion_pool_mappings, clone_disks,
                force, skip_os_morphing, user_scripts=user_scripts)
        else:
            (origin_endpoint_id,
             destination_endpoint_id,
             origin_minion_pool_id,
             destination_minion_pool_id,
             instance_osmorphing_minion_pool_mappings,
             source_environment,
             destination_environment,
             instances,
             notes,
             skip_os_morphing,
             replication_count,
             shutdown_instances,
             network_map,
             storage_mappings) = self._validate_migration_input(
                 context, body)
            migration = self._migration_api.migrate_instances(
                context, origin_endpoint_id, destination_endpoint_id,
                origin_minion_pool_id, destination_minion_pool_id,
                instance_osmorphing_minion_pool_mappings,
                source_environment, destination_environment, instances,
                network_map, storage_mappings, replication_count,
                shutdown_instances, notes=notes,
                skip_os_morphing=skip_os_morphing,
                user_scripts=user_scripts)

        return migration_view.single(req, migration)
Example #5
0
    def create(self, req, body):
        # TODO(alexpilotti): validate body
        migration_body = body.get("migration", {})
        context = req.environ['coriolis.context']

        replica_id = migration_body.get("replica_id")
        if replica_id:
            clone_disks = migration_body.get("clone_disks", True)
            force = migration_body.get("force", False)
            skip_os_morphing = migration_body.get("skip_os_morphing", False)

            migration = self._migration_api.deploy_replica_instances(
                context, replica_id, clone_disks, force, skip_os_morphing)
        else:
            (origin_endpoint_id, destination_endpoint_id,
             destination_environment, instances, notes,
             skip_os_morphing) = self._validate_migration_input(migration_body)
            migration = self._migration_api.migrate_instances(
                context, origin_endpoint_id, destination_endpoint_id,
                destination_environment, instances, notes, skip_os_morphing)

        return migration_view.single(req, migration)
Example #6
0
 def create(self, req, body):
     origin, destination, instances = self._validate_create_body(body)
     return migration_view.single(
         req, self._migration_api.start(req.environ["coriolis.context"], origin, destination, instances)
     )
Example #7
0
    def show(self, req, id):
        migration = self._migration_api.get_migration(req.environ["coriolis.context"], id)
        if not migration:
            raise exc.HTTPNotFound()

        return migration_view.single(req, migration)
Example #8
0
 def create(self, req, body):
     origin, destination, instances = self._validate_create_body(body)
     return migration_view.single(
         req,
         self._migration_api.start(req.environ['coriolis.context'], origin,
                                   destination, instances))