~ubuntu-branches/ubuntu/quantal/nova/quantal-proposed

« back to all changes in this revision

Viewing changes to nova/virt/fake.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2012-08-16 14:04:11 UTC
  • mto: This revision was merged to the branch mainline in revision 84.
  • Revision ID: package-import@ubuntu.com-20120816140411-0mr4n241wmk30t9l
Tags: upstream-2012.2~f3
ImportĀ upstreamĀ versionĀ 2012.2~f3

Show diffs side-by-side

added added

removed removed

Lines of Context:
42
42
        self.name = name
43
43
        self.state = state
44
44
 
 
45
    def __getitem__(self, key):
 
46
        return getattr(self, key)
 
47
 
45
48
 
46
49
class FakeDriver(driver.ComputeDriver):
47
50
    """Fake hypervisor driver"""
71
74
    def list_instances(self):
72
75
        return self.instances.keys()
73
76
 
74
 
    def _map_to_instance_info(self, instance):
75
 
        instance = utils.check_isinstance(instance, FakeInstance)
76
 
        info = driver.InstanceInfo(instance.name, instance.state)
77
 
        return info
78
 
 
79
 
    def list_instances_detail(self):
80
 
        info_list = []
81
 
        for instance in self.instances.values():
82
 
            info_list.append(self._map_to_instance_info(instance))
83
 
        return info_list
84
 
 
85
77
    def plug_vifs(self, instance, network_info):
86
78
        """Plug VIFs into networks."""
87
79
        pass
90
82
        """Unplug VIFs from networks."""
91
83
        pass
92
84
 
93
 
    def spawn(self, context, instance, image_meta,
94
 
              network_info=None, block_device_info=None):
95
 
        name = instance.name
 
85
    def spawn(self, context, instance, image_meta, injected_files,
 
86
              admin_password, network_info=None, block_device_info=None):
 
87
        name = instance['name']
96
88
        state = power_state.RUNNING
97
89
        fake_instance = FakeInstance(name, state)
98
90
        self.instances[name] = fake_instance
114
106
    def inject_file(self, instance, b64_path, b64_contents):
115
107
        pass
116
108
 
117
 
    def agent_update(self, instance, url, md5hash):
118
 
        pass
119
 
 
120
109
    def resume_state_on_host_boot(self, context, instance, network_info):
121
110
        pass
122
111
 
123
 
    def rescue(self, context, instance, network_info, image_meta):
 
112
    def rescue(self, context, instance, network_info, image_meta,
 
113
               rescue_password):
124
114
        pass
125
115
 
126
116
    def unrescue(self, instance, network_info):
224
214
    def refresh_security_group_members(self, security_group_id):
225
215
        return True
226
216
 
 
217
    def refresh_instance_security_rules(self, instance):
 
218
        return True
 
219
 
227
220
    def refresh_provider_fw_rules(self):
228
221
        pass
229
222
 
259
252
            LOG.info(_('Compute_service record updated for %s ') % host)
260
253
            db.compute_node_update(ctxt, compute_node_ref[0]['id'], dic)
261
254
 
262
 
    def compare_cpu(self, xml):
263
 
        """This method is supported only by libvirt."""
264
 
        raise NotImplementedError('This method is supported only by libvirt.')
265
 
 
266
255
    def ensure_filtering_rules_for_instance(self, instance_ref, network_info):
267
256
        """This method is supported only by libvirt."""
268
257
        raise NotImplementedError('This method is supported only by libvirt.')
269
258
 
270
259
    def get_instance_disk_info(self, instance_name):
271
 
        """This method is supported only by libvirt."""
272
260
        return
273
261
 
274
262
    def live_migration(self, context, instance_ref, dest,
275
 
                       post_method, recover_method, block_migration=False):
276
 
        """This method is supported only by libvirt."""
 
263
                       post_method, recover_method, block_migration=False,
 
264
                       migrate_data=None):
277
265
        return
278
266
 
279
267
    def finish_migration(self, context, migration, instance, disk_info,
283
271
    def confirm_migration(self, migration, instance, network_info):
284
272
        return
285
273
 
286
 
    def pre_live_migration(self, block_device_info):
287
 
        """This method is supported only by libvirt."""
 
274
    def pre_live_migration(self, context, instance_ref, block_device_info,
 
275
                           network_info):
288
276
        return
289
277
 
290
278
    def unfilter_instance(self, instance_ref, network_info):