Finished cleaning up the openstack servers API, it no longer touches the database directly. Also cleaned up similar things in ec2 API and refactored a couple methods in nova.compute.api to accomodate this work.
This commit is contained in:
		@@ -624,6 +624,10 @@ class AuthManager(object):
 | 
			
		||||
        with self.driver() as drv:
 | 
			
		||||
            drv.modify_user(uid, access_key, secret_key, admin)
 | 
			
		||||
 | 
			
		||||
    @staticmethod
 | 
			
		||||
    def get_key_pairs(context):
 | 
			
		||||
        return db.key_pair_get_all_by_user(context.elevated(), context.user_id)
 | 
			
		||||
 | 
			
		||||
    def get_credentials(self, user, project=None):
 | 
			
		||||
        """Get credential zip for user in project"""
 | 
			
		||||
        if not isinstance(user, User):
 | 
			
		||||
 
 | 
			
		||||
@@ -259,7 +259,7 @@ DEFINE_string('scheduler_manager', 'nova.scheduler.manager.SchedulerManager',
 | 
			
		||||
              'Manager for scheduler')
 | 
			
		||||
 | 
			
		||||
# The service to use for image search and retrieval
 | 
			
		||||
DEFINE_string('image_service', 'nova.image.local.LocalImageService',
 | 
			
		||||
DEFINE_string('image_service', 'nova.image.s3.S3ImageService',
 | 
			
		||||
              'The service to use for retrieving and searching for images.')
 | 
			
		||||
 | 
			
		||||
DEFINE_string('host', socket.gethostname(),
 | 
			
		||||
 
 | 
			
		||||
@@ -72,33 +72,27 @@ class ComputeTestCase(test.TrialTestCase):
 | 
			
		||||
        """Verify that an instance cannot be created without a display_name."""
 | 
			
		||||
        cases = [dict(), dict(display_name=None)]
 | 
			
		||||
        for instance in cases:
 | 
			
		||||
            ref = self.compute_api.create_instance(self.context, None,
 | 
			
		||||
                                                   **instance)
 | 
			
		||||
            ref = self.compute_api.create_instances(self.context,
 | 
			
		||||
                FLAGS.default_instance_type, None, **instance)
 | 
			
		||||
            try:
 | 
			
		||||
                self.assertNotEqual(ref.display_name, None)
 | 
			
		||||
                self.assertNotEqual(ref[0].display_name, None)
 | 
			
		||||
            finally:
 | 
			
		||||
                db.instance_destroy(self.context, ref['id'])
 | 
			
		||||
                db.instance_destroy(self.context, ref[0]['id'])
 | 
			
		||||
 | 
			
		||||
    def test_create_instance_associates_security_groups(self):
 | 
			
		||||
        """Make sure create_instance associates security groups"""
 | 
			
		||||
        inst = {}
 | 
			
		||||
        inst['user_id'] = self.user.id
 | 
			
		||||
        inst['project_id'] = self.project.id
 | 
			
		||||
        """Make sure create_instances associates security groups"""
 | 
			
		||||
        values = {'name': 'default',
 | 
			
		||||
                  'description': 'default',
 | 
			
		||||
                  'user_id': self.user.id,
 | 
			
		||||
                  'project_id': self.project.id}
 | 
			
		||||
        group = db.security_group_create(self.context, values)
 | 
			
		||||
        ref = self.compute_api.create_instance(self.context,
 | 
			
		||||
                                               security_groups=[group['id']],
 | 
			
		||||
                                               **inst)
 | 
			
		||||
        # reload to get groups
 | 
			
		||||
        instance_ref = db.instance_get(self.context, ref['id'])
 | 
			
		||||
        ref = self.compute_api.create_instances(self.context,
 | 
			
		||||
            FLAGS.default_instance_type, None, security_group=['default'])
 | 
			
		||||
        try:
 | 
			
		||||
            self.assertEqual(len(instance_ref['security_groups']), 1)
 | 
			
		||||
            self.assertEqual(len(ref[0]['security_groups']), 1)
 | 
			
		||||
        finally:
 | 
			
		||||
            db.security_group_destroy(self.context, group['id'])
 | 
			
		||||
            db.instance_destroy(self.context, instance_ref['id'])
 | 
			
		||||
            db.instance_destroy(self.context, ref[0]['id'])
 | 
			
		||||
 | 
			
		||||
    @defer.inlineCallbacks
 | 
			
		||||
    def test_run_terminate(self):
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user