Converted a few more ec2 calls to use compute api.
This commit is contained in:
		@@ -138,7 +138,7 @@ class CloudController(object):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    def get_metadata(self, address):
 | 
					    def get_metadata(self, address):
 | 
				
			||||||
        ctxt = context.get_admin_context()
 | 
					        ctxt = context.get_admin_context()
 | 
				
			||||||
        instance_ref = db.fixed_ip_get_instance(ctxt, address)
 | 
					        instance_ref = self.compute_api.get(ctxt, fixed_ip=address)
 | 
				
			||||||
        if instance_ref is None:
 | 
					        if instance_ref is None:
 | 
				
			||||||
            return None
 | 
					            return None
 | 
				
			||||||
        mpi = self._get_mpi_data(ctxt, instance_ref['project_id'])
 | 
					        mpi = self._get_mpi_data(ctxt, instance_ref['project_id'])
 | 
				
			||||||
@@ -555,13 +555,9 @@ class CloudController(object):
 | 
				
			|||||||
        assert len(i) == 1
 | 
					        assert len(i) == 1
 | 
				
			||||||
        return i[0]
 | 
					        return i[0]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def _format_instances(self, context, reservation_id=None):
 | 
					    def _format_instances(self, context, **kwargs):
 | 
				
			||||||
        reservations = {}
 | 
					        reservations = {}
 | 
				
			||||||
        if reservation_id:
 | 
					        instances = self.compute_api.get(context, **kwargs)
 | 
				
			||||||
            instances = db.instance_get_all_by_reservation(context,
 | 
					 | 
				
			||||||
                                                           reservation_id)
 | 
					 | 
				
			||||||
        else:
 | 
					 | 
				
			||||||
            instances = self.compute_api.get(context)
 | 
					 | 
				
			||||||
        for instance in instances:
 | 
					        for instance in instances:
 | 
				
			||||||
            if not context.user.is_admin():
 | 
					            if not context.user.is_admin():
 | 
				
			||||||
                if instance['image_id'] == FLAGS.vpn_image_id:
 | 
					                if instance['image_id'] == FLAGS.vpn_image_id:
 | 
				
			||||||
@@ -747,8 +743,7 @@ class CloudController(object):
 | 
				
			|||||||
                changes[field] = kwargs[field]
 | 
					                changes[field] = kwargs[field]
 | 
				
			||||||
        if changes:
 | 
					        if changes:
 | 
				
			||||||
            instance_id = ec2_id_to_id(ec2_id)
 | 
					            instance_id = ec2_id_to_id(ec2_id)
 | 
				
			||||||
            inst = self.compute_api.get(context, instance_id)
 | 
					            self.compute_api.update(context, instance_id, **kwargs)
 | 
				
			||||||
            db.instance_update(context, inst['id'], kwargs)
 | 
					 | 
				
			||||||
        return True
 | 
					        return True
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def describe_images(self, context, image_id=None, **kwargs):
 | 
					    def describe_images(self, context, image_id=None, **kwargs):
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -243,12 +243,18 @@ class API(base.Base):
 | 
				
			|||||||
        else:
 | 
					        else:
 | 
				
			||||||
            self.db.instance_destroy(context, instance['id'])
 | 
					            self.db.instance_destroy(context, instance['id'])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def get(self, context, instance_id=None, project_id=None):
 | 
					    def get(self, context, instance_id=None, project_id=None,
 | 
				
			||||||
        """Get one or more instances, possibly filtered by project
 | 
					            reservation_id=None, fixed_ip=None):
 | 
				
			||||||
        ID or user ID. If there is no filter and the context is
 | 
					        """Get one or more instances, possibly filtered by one of the
 | 
				
			||||||
 | 
					        given parameters. If there is no filter and the context is
 | 
				
			||||||
        an admin, it will retreive all instances in the system."""
 | 
					        an admin, it will retreive all instances in the system."""
 | 
				
			||||||
        if instance_id is not None:
 | 
					        if instance_id is not None:
 | 
				
			||||||
            return self.db.instance_get_by_id(context, instance_id)
 | 
					            return self.db.instance_get_by_id(context, instance_id)
 | 
				
			||||||
 | 
					        if reservation_id is not None:
 | 
				
			||||||
 | 
					            return self.db.instance_get_all_by_reservation(context,
 | 
				
			||||||
 | 
					                                                           reservation_id)
 | 
				
			||||||
 | 
					        if fixed_ip is not None:
 | 
				
			||||||
 | 
					            return self.db.fixed_ip_get_instance(context, fixed_ip)
 | 
				
			||||||
        if project_id or not context.is_admin:
 | 
					        if project_id or not context.is_admin:
 | 
				
			||||||
            if not context.project:
 | 
					            if not context.project:
 | 
				
			||||||
                return self.db.instance_get_all_by_user(context,
 | 
					                return self.db.instance_get_all_by_user(context,
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user