~0x44/nova/extdoc

« back to all changes in this revision

Viewing changes to nova/virt/vmwareapi/vm_util.py

  • Committer: Dan Prince
  • Date: 2011-09-14 15:34:08 UTC
  • mfrom: (1568 nova)
  • mto: This revision was merged to the branch mainline in revision 1570.
  • Revision ID: dan.prince@rackspace.com-20110914153408-y8iqlnz2uphraexp
Merge w/ trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
39
39
 
40
40
 
41
41
def get_vm_create_spec(client_factory, instance, data_store_name,
42
 
                       network_name="vmnet0",
43
 
                       os_type="otherGuest", network_ref=None):
 
42
                       vif_infos, os_type="otherGuest"):
44
43
    """Builds the VM Create spec."""
45
44
    config_spec = client_factory.create('ns0:VirtualMachineConfigSpec')
46
45
    config_spec.name = instance.name
61
60
    config_spec.numCPUs = int(instance.vcpus)
62
61
    config_spec.memoryMB = int(instance.memory_mb)
63
62
 
64
 
    mac_address = None
65
 
    if instance['mac_addresses']:
66
 
        mac_address = instance['mac_addresses'][0]['address']
67
 
 
68
 
    nic_spec = create_network_spec(client_factory,
69
 
                                    network_name, mac_address)
70
 
 
71
 
    device_config_spec = [nic_spec]
 
63
    vif_spec_list = []
 
64
    for vif_info in vif_infos:
 
65
        vif_spec = create_network_spec(client_factory, vif_info)
 
66
        vif_spec_list.append(vif_spec)
 
67
 
 
68
    device_config_spec = vif_spec_list
72
69
 
73
70
    config_spec.deviceChange = device_config_spec
74
71
    return config_spec
93
90
    return virtual_device_config
94
91
 
95
92
 
96
 
def create_network_spec(client_factory, network_name, mac_address,
97
 
                        network_ref=None):
 
93
def create_network_spec(client_factory, vif_info):
98
94
    """
99
95
    Builds a config spec for the addition of a new network
100
96
    adapter to the VM.
109
105
    # NOTE(asomya): Only works on ESXi if the portgroup binding is set to
110
106
    # ephemeral. Invalid configuration if set to static and the NIC does
111
107
    # not come up on boot if set to dynamic.
 
108
    network_ref = vif_info['network_ref']
 
109
    network_name = vif_info['network_name']
 
110
    mac_address = vif_info['mac_address']
112
111
    backing = None
113
112
    if (network_ref and
114
113
        network_ref['type'] == "DistributedVirtualPortgroup"):
295
294
    return config_spec
296
295
 
297
296
 
298
 
def get_machine_id_change_spec(client_factory, mac, ip_addr, netmask,
299
 
                               gateway, broadcast, dns):
 
297
def get_machine_id_change_spec(client_factory, machine_id_str):
300
298
    """Builds the machine id change config spec."""
301
 
    machine_id_str = "%s;%s;%s;%s;%s;%s" % (mac, ip_addr, netmask,
302
 
                                            gateway, broadcast, dns)
303
299
    virtual_machine_config_spec = \
304
300
        client_factory.create('ns0:VirtualMachineConfigSpec')
305
301