Beispiel #1
0
def load_mgmt_instance(cls, context, id, include_deleted):
    try:
        instance = instance_models.load_instance(
            cls,
            context,
            id,
            needs_server=True,
            include_deleted=include_deleted)
        client = clients.create_nova_client(
            context, CONF.service_credentials.region_name)
        try:
            server = client.rdservers.get(instance.server_id)
        except AttributeError:
            server = client.servers.get(instance.server_id)
        if hasattr(server, 'host'):
            instance.server.host = server.host
        elif hasattr(server, 'hostId'):
            instance.server.host = server.hostId
        if hasattr(server, 'deleted'):
            instance.server.deleted = server.deleted
        if hasattr(server, 'deleted_at'):
            instance.server.deleted_at = server.deleted_at
        if hasattr(server, 'local_id'):
            instance.server.local_id = server.local_id
        assert instance.server is not None
    except Exception as e:
        LOG.error(e)
        instance = instance_models.load_instance(
            cls,
            context,
            id,
            needs_server=False,
            include_deleted=include_deleted)
    return instance
Beispiel #2
0
def load_mgmt_instance(cls, context, id, include_deleted):
    try:
        instance = load_instance(cls, context, id, needs_server=True,
                                 include_deleted=include_deleted)
        client = remote.create_nova_client(context, CONF.os_region_name)
        try:
            server = client.rdservers.get(instance.server_id)
        except AttributeError:
            server = client.servers.get(instance.server_id)
        if hasattr(server, 'host'):
            instance.server.host = server.host
        elif hasattr(server, 'hostId'):
            instance.server.host = server.hostId
        if hasattr(server, 'deleted'):
            instance.server.deleted = server.deleted
        if hasattr(server, 'deleted_at'):
            instance.server.deleted_at = server.deleted_at
        if hasattr(server, 'local_id'):
            instance.server.local_id = server.local_id
        assert instance.server is not None
    except Exception as e:
        LOG.error(e)
        instance = load_instance(cls, context, id, needs_server=False,
                                 include_deleted=include_deleted)
    return instance
Beispiel #3
0
def load_mgmt_instance(cls, context, id):
    try:
        instance = load_instance(cls, context, id, needs_server=True)
        client = remote.create_nova_client(context)
        server = client.rdservers.get(instance.server_id)
        instance.server.host = server.host
        instance.server.deleted = server.deleted
        instance.server.deleted_at = server.deleted_at
        instance.server.local_id = server.local_id
        assert instance.server is not None
    except Exception as e:
        LOG.error(e)
        instance = load_instance(cls, context, id, needs_server=False)
    return instance
    def test_upgrade(self, task_upgrade):
        instance_model = DBInstance(
            InstanceTasks.NONE,
            id=str(uuid.uuid4()),
            name="TestUpgradeInstance",
            datastore_version_id=self.datastore_version1.id)
        instance_model.set_task_status(InstanceTasks.NONE)
        instance_model.save()
        instance_status = InstanceServiceStatus(
            ServiceStatuses.RUNNING,
            id=str(uuid.uuid4()),
            instance_id=instance_model.id)
        instance_status.save()
        self.assertIsNotNone(instance_model)
        instance = models.load_instance(models.Instance, self.context,
                                        instance_model.id)

        try:
            instance.upgrade(self.datastore_version2)

            self.assertEqual(self.datastore_version2.id,
                             instance.db_info.datastore_version_id)
            self.assertEqual(InstanceTasks.UPGRADING,
                             instance.db_info.task_status)
            self.assertTrue(task_upgrade.called)
        finally:
            instance_status.delete()
            instance_model.delete()
Beispiel #5
0
    def test_upgrade(self, task_upgrade):
        instance_model = DBInstance(
            InstanceTasks.NONE,
            id=str(uuid.uuid4()),
            name="TestUpgradeInstance",
            datastore_version_id=self.datastore_version1.id)
        instance_model.set_task_status(InstanceTasks.NONE)
        instance_model.save()
        instance_status = InstanceServiceStatus(ServiceStatuses.RUNNING,
                                                id=str(uuid.uuid4()),
                                                instance_id=instance_model.id)
        instance_status.save()
        self.assertIsNotNone(instance_model)
        instance = models.load_instance(models.Instance, self.context,
                                        instance_model.id)

        try:
            instance.upgrade(self.datastore_version2)

            self.assertEqual(self.datastore_version2.id,
                             instance.db_info.datastore_version_id)
            self.assertEqual(InstanceTasks.UPGRADING,
                             instance.db_info.task_status)
            self.assertTrue(task_upgrade.called)
        finally:
            instance_status.delete()
            instance_model.delete()
Beispiel #6
0
def load_mgmt_instance(cls, context, id):
    try:
        instance = load_instance(cls, context, id, needs_server=True)
        client = remote.create_nova_client(context)
        try:
            server = client.rdservers.get(instance.server_id)
        except AttributeError:
            server = client.servers.get(instance.server_id)
        if hasattr(server, 'host'):
            instance.server.host = server.host
        elif hasattr(server, 'hostId'):
            instance.server.host = server.hostId
        if hasattr(server, 'deleted'):
            instance.server.deleted = server.deleted
        if hasattr(server, 'deleted_at'):
            instance.server.deleted_at = server.deleted_at
        if hasattr(server, 'local_id'):
            instance.server.local_id = server.local_id
        assert instance.server is not None
    except Exception as e:
        LOG.error(e)
        instance = load_instance(cls, context, id, needs_server=False)
    return instance