Beispiel #1
0
 def create(self):
     if self.obj_attr_is_set('id'):
         raise exception.ObjectActionError(action='create',
                                           reason=_('already created'))
     updates = self.guts_obj_get_changes()
     db_migration = db.migration_create(self._context, updates)
     self._from_db_object(self._context, self, db_migration)
def create(ctxt, name, source_instance_id, description=None):
    """Creates migration.

    Raises:
        MigrationCreateFailed: If there is error during migration creation.
        InstanceNotReadyForMigration: Migrating instance failed
                                        pre-migration validations
    """
    try:
        migration_ref = db.migration_create(
            ctxt,
            dict(name=name,
                 source_instance_id=source_instance_id,
                 description=description))
    except db_exc.DBError:
        LOG.exception(_LE('DB error:'))
        raise exception.MigrationCreateFailed(name=name)

    migration_api = migration_rpcapi.MigrationAPI()

    try:
        migration_api.validate_for_migration(ctxt, migration_ref)
    except messaging.RemoteError as ex:
        raise exception.InstanceNotReadyForMigration(name=name,
                                                     reason=six.text_type(
                                                         ex.value))

    migration_api.create_migration(ctxt, migration_ref)

    return migration_ref
Beispiel #3
0
 def create(self):
     if self.obj_attr_is_set('id'):
         raise exception.ObjectActionError(action='create',
                                           reason=_('already created'))
     updates = self.guts_obj_get_changes()
     db_migration = db.migration_create(self._context, updates)
     self._from_db_object(self._context, self, db_migration)
Beispiel #4
0
def create(ctxt, name, source_instance_id, description=None):
    """Creates migration."""
    try:
        migration_ref = db.migration_create(
            ctxt,
            dict(name=name,
                 source_instance_id=source_instance_id,
                 description=description))
    except db_exc.DBError:
        LOG.exception(_LE('DB error:'))
        raise exception.MigrationCreateFailed(name=name)

    migration_api = migration_rpcapi.MigrationAPI()
    migration_api.create_migration(ctxt, migration_ref)

    return migration_ref