1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
#nova/nova/compute/api.py
from nova.compute import rpcapi as compute_rpcapi
class API(base.Base):
"""API for interacting with the compute manager."""
def start(self, context, instance):
"""Start an instance."""
LOG.debug("Going to try to start instance", instance=instance)
instance.task_state = task_states.POWERING_ON
instance.save(expected_task_state=[None])
self._record_action_start(context, instance, instance_actions.START)
#調用類 nova.compute.rpcapi.ComputeAPI 中的接口
self.compute_rpcapi.start_instance(context, instance)
|
1 2 3 4 5 6 7 8 9 10 11 |
#nova/nova/compute/rpcapi.py
class ComputeAPI(object):
'''Client side of the compute rpc API.
'''
def start_instance(self, ctxt, instance):
version = self._ver(ctxt, '4.0')
cctxt = self.router.client(ctxt).prepare(
server=_compute_host(None, instance), version=version)
cctxt.cast(ctxt, 'start_instance', instance=instance)
|
1 2 3 4 5 6 7 8 9 |
#nova/nova/compute/manager.py
class ComputeManager(manager.Manager):
"""Manages the running instances from creation to destruction."""
@wrap_exception()
@reverts_task_state
@wrap_instance_event(prefix='compute')
@wrap_instance_fault
def start_instance(self, context, instance):
"""Starting an instance on this host."""
|