~yolanda.robla/nova/precise-security

« back to all changes in this revision

Viewing changes to nova/compute/api.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2012-06-05 09:50:59 UTC
  • mto: (79.1.1 precise-proposed)
  • mto: This revision was merged to the branch mainline in revision 81.
  • Revision ID: package-import@ubuntu.com-20120605095059-kb1utt7b1a5yff2a
Tags: upstream-2012.1+stable~20120612-3ee026e
ImportĀ upstreamĀ versionĀ 2012.1+stable~20120612-3ee026e

Show diffs side-by-side

added added

removed removed

Lines of Context:
106
106
    nova.policy.enforce(context, _action, target)
107
107
 
108
108
 
109
 
class API(base.Base):
110
 
    """API for interacting with the compute manager."""
111
 
 
112
 
    def __init__(self, image_service=None, network_api=None, volume_api=None,
113
 
                 **kwargs):
114
 
        self.image_service = (image_service or
115
 
                              nova.image.get_default_image_service())
116
 
 
117
 
        self.network_api = network_api or network.API()
118
 
        self.volume_api = volume_api or volume.API()
119
 
        super(API, self).__init__(**kwargs)
 
109
class BaseAPI(base.Base):
 
110
    """Base API class."""
 
111
    def __init__(self, **kwargs):
 
112
        super(BaseAPI, self).__init__(**kwargs)
120
113
 
121
114
    def _cast_or_call_compute_message(self, rpc_method, compute_method,
122
115
            context, instance=None, host=None, params=None):
157
150
        """Generic handler for RPC calls to compute."""
158
151
        return self._cast_or_call_compute_message(rpc.call, *args, **kwargs)
159
152
 
160
 
    def _cast_scheduler_message(self, context, args):
 
153
    @staticmethod
 
154
    def _cast_scheduler_message(context, args):
161
155
        """Generic handler for RPC calls to the scheduler."""
162
156
        rpc.cast(context, FLAGS.scheduler_topic, args)
163
157
 
 
158
 
 
159
class API(BaseAPI):
 
160
    """API for interacting with the compute manager."""
 
161
 
 
162
    def __init__(self, image_service=None, network_api=None, volume_api=None,
 
163
                 **kwargs):
 
164
        self.image_service = (image_service or
 
165
                              nova.image.get_default_image_service())
 
166
 
 
167
        self.network_api = network_api or network.API()
 
168
        self.volume_api = volume_api or volume.API()
 
169
        super(API, self).__init__(**kwargs)
 
170
 
164
171
    def _check_injected_file_quota(self, context, injected_files):
165
172
        """Enforce quota limits on injected files.
166
173
 
1677
1684
        return self.db.instance_fault_get_by_instance_uuids(context, uuids)
1678
1685
 
1679
1686
 
1680
 
class HostAPI(base.Base):
 
1687
class HostAPI(BaseAPI):
1681
1688
    """Sub-set of the Compute Manager API for managing host operations."""
1682
 
    def __init__(self, **kwargs):
1683
 
        super(HostAPI, self).__init__(**kwargs)
1684
 
 
1685
1689
    def set_host_enabled(self, context, host, enabled):
1686
1690
        """Sets the specified host's ability to accept new instances."""
1687
1691
        # NOTE(comstud): No instance_uuid argument to this compute manager