~rackspace-titan/nova/extensions-osapi1.1-serx

« back to all changes in this revision

Viewing changes to nova/virt/xenapi/vm_utils.py

  • Committer: Naveed Massjouni
  • Date: 2011-07-29 05:58:12 UTC
  • mfrom: (1299.1.44 nova)
  • Revision ID: naveedm9@gmail.com-20110729055812-xabjblxndjkf3of1
MergeĀ fromĀ trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
283
283
            raise StorageError(_('Unable to destroy VDI %s') % vdi_ref)
284
284
 
285
285
    @classmethod
286
 
    def create_vif(cls, session, vm_ref, network_ref, mac_address,
287
 
                   dev, rxtx_cap=0):
288
 
        """Create a VIF record.  Returns a Deferred that gives the new
289
 
        VIF reference."""
290
 
        vif_rec = {}
291
 
        vif_rec['device'] = str(dev)
292
 
        vif_rec['network'] = network_ref
293
 
        vif_rec['VM'] = vm_ref
294
 
        vif_rec['MAC'] = mac_address
295
 
        vif_rec['MTU'] = '1500'
296
 
        vif_rec['other_config'] = {}
297
 
        vif_rec['qos_algorithm_type'] = "ratelimit" if rxtx_cap else ''
298
 
        vif_rec['qos_algorithm_params'] = \
299
 
                {"kbps": str(rxtx_cap * 1024)} if rxtx_cap else {}
300
 
        LOG.debug(_('Creating VIF for VM %(vm_ref)s,'
301
 
                ' network %(network_ref)s.') % locals())
302
 
        vif_ref = session.call_xenapi('VIF.create', vif_rec)
303
 
        LOG.debug(_('Created VIF %(vif_ref)s for VM %(vm_ref)s,'
304
 
                ' network %(network_ref)s.') % locals())
305
 
        return vif_ref
306
 
 
307
 
    @classmethod
308
286
    def create_vdi(cls, session, sr_ref, name_label, virtual_size, read_only):
309
287
        """Create a VDI record and returns its reference."""
310
288
        vdi_ref = session.get_xenapi().VDI.create(