コード例 #1
0
 def test_upgrade_flavor_already_migrated(self):
     flavor = flavors.get_default_flavor()
     sysmeta = flavors.save_flavor_info({}, flavor)
     sysmeta['foo'] = 'bar'
     inst = objects.Instance(context=self.context,
                             uuid=uuid.uuid4(),
                             user_id=self.context.user_id,
                             project_id=self.context.project_id,
                             system_metadata=sysmeta)
     inst.create()
     # Trigger the migration by lazy-loading flavor
     inst.flavor
     inst.save()
     self.assertNotIn('instance_type_id', inst.system_metadata)
     sysmeta = db_api.instance_system_metadata_get(self.context, inst.uuid)
     self.assertEqual({'foo': 'bar'}, sysmeta)
     self.migration.upgrade(self.engine)
コード例 #2
0
 def test_upgrade_flavor_already_migrated(self):
     flavor = flavors.get_default_flavor()
     sysmeta = flavors.save_flavor_info({}, flavor)
     sysmeta['foo'] = 'bar'
     inst = objects.Instance(context=self.context,
                             uuid=uuid.uuid4(),
                             user_id=self.context.user_id,
                             project_id=self.context.project_id,
                             system_metadata=sysmeta)
     inst.create()
     # Trigger the migration by lazy-loading flavor
     inst.flavor
     inst.save()
     self.assertNotIn('instance_type_id', inst.system_metadata)
     sysmeta = db_api.instance_system_metadata_get(self.context,
                                                   inst.uuid)
     self.assertEqual({'foo': 'bar'}, sysmeta)
     self.migration.upgrade(self.engine)
コード例 #3
0
    def test_upgrade_flavor_deleted_sysmeta(self):
        flavor = flavors.get_default_flavor()
        sysmeta = flavors.save_flavor_info({}, flavor)
        sysmeta['foo'] = 'bar'
        inst = objects.Instance(context=self.context,
                                uuid=uuid.uuid4(),
                                user_id=self.context.user_id,
                                project_id=self.context.project_id,
                                system_metadata=sysmeta)
        inst.create()

        sysmeta = db_api.instance_system_metadata_get(self.context,
                                                      inst.uuid)
        sysmeta = {k: v for k, v in sysmeta.items()
                   if not k.startswith('instance_type_')}
        db_api.instance_system_metadata_update(self.context, inst.uuid,
                                               sysmeta, True)
        inst.refresh()

        self.assertEqual({'foo': 'bar'}, inst.system_metadata)
        self.migration.upgrade(self.engine)
コード例 #4
0
    def test_upgrade_flavor_deleted_sysmeta(self):
        flavor = flavors.get_default_flavor()
        sysmeta = flavors.save_flavor_info({}, flavor)
        sysmeta['foo'] = 'bar'
        inst = objects.Instance(context=self.context,
                                uuid=uuid.uuid4(),
                                user_id=self.context.user_id,
                                project_id=self.context.project_id,
                                system_metadata=sysmeta)
        inst.create()

        sysmeta = db_api.instance_system_metadata_get(self.context,
                                                      inst.uuid)
        sysmeta = {k: v for k, v in sysmeta.items()
                   if not k.startswith('instance_type_')}
        db_api.instance_system_metadata_update(self.context, inst.uuid,
                                               sysmeta, True)
        inst.refresh()

        self.assertEqual({'foo': 'bar'}, inst.system_metadata)
        self.migration.upgrade(self.engine)
コード例 #5
0
def get_metadata(instance_uuid):
    context = RequestContext('1', '1', is_admin=True)
    return sqlapi.instance_system_metadata_get(context, instance_uuid)
コード例 #6
0
ファイル: usage_seed.py プロジェクト: Lupul/stacktach
def get_metadata(instance_uuid):
    context = RequestContext('1', '1', is_admin=True)
    return sqlapi.instance_system_metadata_get(context, instance_uuid)