~eday/nova/api-port

« back to all changes in this revision

Viewing changes to nova/virt/fake.py

  • Committer: Tarmac
  • Author(s): Ewan Mellor
  • Date: 2010-08-17 21:28:25 UTC
  • mfrom: (145.7.9 fake-virt-deferreds)
  • Revision ID: hudson@openstack.org-20100817212825-f92ublsmcg6rnq6k
Add documentation to spawn, reboot, and destroy stating that those functions
should return Deferreds.  Update the fake implementations to do so (the
libvirt ones already do, and making the xenapi ones do so is the subject of
a current merge request).

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
 
25
25
import logging
26
26
 
 
27
from twisted.internet import defer
 
28
 
27
29
from nova.compute import power_state
28
30
 
29
31
 
89
91
        This function should use the data there to guide the creation of
90
92
        the new instance.
91
93
 
92
 
        Once this function successfully completes, the instance should be
 
94
        The work will be done asynchronously.  This function returns a
 
95
        Deferred that allows the caller to detect when it is complete.
 
96
 
 
97
        Once this successfully completes, the instance should be
93
98
        running (power_state.RUNNING).
94
99
 
95
 
        If this function fails, any partial instance should be completely
 
100
        If this fails, any partial instance should be completely
96
101
        cleaned up, and the virtualization platform should be in the state
97
102
        that it was before this call began.
98
103
        """
100
105
        fake_instance = FakeInstance()
101
106
        self.instances[instance.name] = fake_instance
102
107
        fake_instance._state = power_state.RUNNING
 
108
        return defer.succeed(None)
103
109
 
104
110
    def reboot(self, instance):
105
111
        """
107
113
 
108
114
        The given parameter is an instance of nova.compute.service.Instance,
109
115
        and so the instance is being specified as instance.name.
 
116
 
 
117
        The work will be done asynchronously.  This function returns a
 
118
        Deferred that allows the caller to detect when it is complete.
110
119
        """
111
 
        pass
 
120
        return defer.succeed(None)
112
121
 
113
122
    def destroy(self, instance):
114
123
        """
116
125
 
117
126
        The given parameter is an instance of nova.compute.service.Instance,
118
127
        and so the instance is being specified as instance.name.
 
128
 
 
129
        The work will be done asynchronously.  This function returns a
 
130
        Deferred that allows the caller to detect when it is complete.
119
131
        """
120
132
        del self.instances[instance.name]
 
133
        return defer.succeed(None)
121
134
 
122
135
    def get_info(self, instance_id):
123
136
        """