~ubuntu-branches/ubuntu/raring/nova/raring-proposed

« back to all changes in this revision

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

  • Committer: Package Import Robot
  • Author(s): Adam Gandelman
  • Date: 2013-08-09 10:12:27 UTC
  • mfrom: (1.1.74)
  • Revision ID: package-import@ubuntu.com-20130809101227-4n60fzcgra8dzk3d
Tags: 1:2013.1.3-0ubuntu1
* Resynchronize with stable/grizzly (89c7ee4) (LP: #1210447):
  - [8e6edd2] Bump stable/grizzly next version to 2013.1.3
  - [61fc529] attach quantum security group to an existing vm failed
    LP: 1189059
  - [60774bd] nova-compute fails to start if quantum is down LP: 1186357
  - [8e6d4b6] asymmetric routes in nova network with external gateway and
    routing_source_ip LP: 1182143
  - [8849413] Failed VM's not set to error state on exception LP: 1182056
  - [ef10eee] Double healing of info_cache with cells LP: 1180304
  - [7422d83] Can't log into  VM after powervm is resized LP: 1169848
  - [49ab0e8] stack trace when instance_actions extension can not find
    instance in GET LP: 1182867
  - [e71247c] nova service-list returns illegal result with non db service
    heartbeat LP: 1168861
  - [3f60606] Volume IO usage gets reset to 0 after a reboot / crash
    LP: 1169097
  - [19c443b] unused method  list_interfaces in vmware driver can be removed
    LP: 1187251
  - [a8dab9f] No cleanup done when file transfer fails with powervm driver
    LP: 1173017
  - [fc98015] nova consoleauth depends on Conductor Service LP: 1186123
  - [1066418] VMware drivers are no longer passing quantum port-id to
    vCenter LP: 1183452
  - [b92075c] nova net-list fails on empty list with Quantum backend
    LP: 1189976
  - [3ba31f2] Create VM with no networks with Quantum Gives SecurityGroups
    Exception LP: 1191044
  - [89150b2] Periodic ValueErrors when using qpid LP: 1185465
  - [0e0d615] Libvirt pre-Grizzly instances cannot be block migrated
    LP: 1185588
  - [27960ef] ZMQ ipc socket file is created using un-sanitized network
    input LP: 1122763
  - [265b868] cannot block migrate old style instances libvirt complains
    LP: 1175286
  - [008a68a] code logical error exists in vmwareapi vif.py  LP: 1177635
  - [378c045] Instance IP addresses are re-used even when previous instance
    could not be powered off LP: 1180178
  - [48ddffe] Reboot of compute node breaks VMs with volumes LP: 1188326
  - [f427f01] Missing dashes from console-log LP: 1194032
  - [78ebf1a] network-create returns an internal error when network
    conflicts LP: 1158075
  - [767c850] Instance nics are reorder after reboot LP: 1187092
  - [0b45996] instance directory naming update to use uuid  LP: 1186944
  - [06cfad5] Disassociate failed dhcp fixed ip in deallocate_for_instance()
    method LP: 1180766
  - [cbcdfc5] Allow confirm_resize action on an instance in 'deleting'
    status LP: 1189391
  - [2563c44] aggregate_get_by_host returns aggregates from other hosts
    LP: 1201277
  - [109f3a9] nova libvirt driver requires iscsi initiator name regardless
    of using it in volume drivers LP: 1007084
  - [7f1c336] Host is always set to None in get_instance_nw_info(...)
    LP: 1194178
  - [1cf30a3] nova boot with colume should fail if the volume is already
    attached to another instance LP: 1166770
  - [9cb9361] Aggregate metadata filtering by key returns unrelated metadata
    LP: 1201283
  - [a61872b] Need clean up  ftp transfer faiure  in powervm driver
    LP: 1188884
  - [91bcd15] Race can cause soft deleted instance to be erased by mistake
    LP: 1186243
  - [c57fded] Nova fails to create a security group rule if ::0/0 is used as
    cidr LP: 1199943
  - [c698dd3] VMwareESXDriver and VMwareVCDriver report incorrect stat
    LP: 1180779
  - [e572faf] novnc fails when amqp_rpc_single_reply_queue=True LP: 1193031
  - [34ddd27] eventlet.monkey_patch() for spice and vnc proxy
  - [864837f] hypervisor_hostname not updated on evacuate LP: 1198284
  - [756a772] libvirt migrate/resize on shared storage can cause data loss
    LP: 1177247
  - [889b215] nova live-migration of volume-backed VM fails because of image
    is None LP: 1199811
  - [60712a4] VNC console does not work with VCDriver LP: 1178369
  - [e0aa0f5] metadata service throws error 500 when compute_driver is not
    set LP: 1184641
  - [340d337] Instance IP addresses are re-used even when previous instance
    could not be powered off LP: 1180178
  - [8247dc8] Resource limit circumvention in Nova private flavors
    (CVE-2013-2256) LP: 1194093
  - [bd7e467] Denial of Service in Nova network source security groups
    (CVE-2013-4185) LP: 1184041
  - [c3fddb7] Resize a VM when a volume is attached fails LP: 1190364
  - [01edbaa] Hyper-V versions before 2012 are not properly recognized
    LP: 1203059
  - [b18818a] driver libvirt doesn't honor vif quota LP: 1185030
  - [798984d] config drive not visible to windows LP: 1155842
  - [d18ceb1] nova live-migration failed due to exception.MigrationError
    LP: 1171526
  - [1934dbc] vmware Hyper for nova vnc console url parameters error
    LP: 1172177
  - [89c7ee4] [OSSA 2013-023] Potential unsafe XML usage (CVE-2013-4179,
    CVE-2013-4202) LP: 1190229
* debian/rules: Clean new setuptools-git cruft.
* debian/control: Update Vcs fields.

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
from nova.openstack.common import excutils
39
39
from nova.openstack.common import log as logging
40
40
from nova.virt import driver
41
 
from nova.virt.vmwareapi import network_util
42
41
from nova.virt.vmwareapi import vif as vmwarevif
43
42
from nova.virt.vmwareapi import vim_util
44
43
from nova.virt.vmwareapi import vm_util
134
133
        4. Attach the disk to the VM by reconfiguring the same.
135
134
        5. Power on the VM.
136
135
        """
137
 
        vm_ref = vm_util.get_vm_ref_from_name(self._session, instance['name'])
138
 
        if vm_ref:
139
 
            raise exception.InstanceExists(name=instance['name'])
140
136
 
141
137
        client_factory = self._session._get_vim().client.factory
142
138
        service_content = self._session._get_vim().get_service_content()
159
155
                                                "lsiLogic")
160
156
            disk_type = image_properties.get("vmware_disktype",
161
157
                                             "preallocated")
162
 
            return vmdk_file_size_in_kb, os_type, adapter_type, disk_type
 
158
            # Get the network card type from the image properties.
 
159
            vif_model = image_properties.get("hw_vif_model", "VirtualE1000")
 
160
            return (vmdk_file_size_in_kb, os_type, adapter_type, disk_type,
 
161
                vif_model)
163
162
 
164
163
        (vmdk_file_size_in_kb, os_type, adapter_type,
165
 
         disk_type) = _get_image_properties()
 
164
            disk_type, vif_model) = _get_image_properties()
166
165
 
167
166
        vm_folder_ref = self._get_vmfolder_ref()
168
167
        res_pool_ref = self._get_res_pool_ref()
169
168
 
170
 
        def _check_if_network_bridge_exists(network_name):
171
 
            network_ref = network_util.get_network_with_the_name(
172
 
                          self._session, network_name, self._cluster)
173
 
            if network_ref is None:
174
 
                raise exception.NetworkNotFoundForBridge(bridge=network_name)
175
 
            return network_ref
176
 
 
177
169
        def _get_vif_infos():
178
170
            vif_infos = []
179
171
            if network_info is None:
187
179
                                                        self._session, vif,
188
180
                                                        self._cluster)
189
181
                else:
190
 
                    network_ref = _check_if_network_bridge_exists(network_name)
 
182
                    # FlatDHCP network without vlan.
 
183
                    network_ref = vmwarevif.ensure_vlan_bridge(
 
184
                        self._session, vif, self._cluster, create_vlan=False)
191
185
                vif_infos.append({'network_name': network_name,
192
186
                                  'mac_address': mac_address,
193
187
                                  'network_ref': network_ref,
194
 
                                  'iface_id': vif.get_meta('iface_id'),
 
188
                                  'vif_model': vif_model,
 
189
                                  'iface_id': vif['id'],
195
190
                                 })
196
191
            return vif_infos
197
192
 
215
210
            LOG.debug(_("Created VM on the ESX host"), instance=instance)
216
211
 
217
212
        _execute_create_vm()
218
 
        vm_ref = vm_util.get_vm_ref_from_name(self._session, instance['name'])
 
213
        vm_ref = vm_util.get_vm_ref(self._session, instance)
219
214
 
220
215
        # Set the machine.id parameter of the instance to inject
221
216
        # the NIC configuration inside the VM
358
353
                upload_folder = self._instance_path_base
359
354
                upload_name = instance['image_ref']
360
355
            else:
361
 
                upload_folder = instance['name']
 
356
                upload_folder = instance['uuid']
362
357
                upload_name = instance['name']
363
358
 
364
359
            # The vmdk meta-data file
415
410
            root_disk = driver.block_device_info_get_mapping(
416
411
                           block_device_info)[0]
417
412
            connection_info = root_disk['connection_info']
418
 
            self._volumeops.attach_volume(connection_info, instance['name'],
 
413
            self._volumeops.attach_volume(connection_info, instance['uuid'],
419
414
                                          self._default_root_device)
420
415
 
421
416
        def _power_on_vm():
444
439
        4. Now upload the -flat.vmdk file to the image store.
445
440
        5. Delete the coalesced .vmdk and -flat.vmdk created.
446
441
        """
447
 
        vm_ref = vm_util.get_vm_ref_from_name(self._session, instance['name'])
448
 
        if vm_ref is None:
449
 
            raise exception.InstanceNotFound(instance_id=instance['uuid'])
450
 
 
 
442
        vm_ref = vm_util.get_vm_ref(self._session, instance)
451
443
        client_factory = self._session._get_vim().client.factory
452
444
        service_content = self._session._get_vim().get_service_content()
453
445
 
477
469
            snapshot_task = self._session._call_method(
478
470
                        self._session._get_vim(),
479
471
                        "CreateSnapshot_Task", vm_ref,
480
 
                        name="%s-snapshot" % instance['name'],
 
472
                        name="%s-snapshot" % instance['uuid'],
481
473
                        description="Taking Snapshot of the VM",
482
474
                        memory=False,
483
475
                        quiesce=True)
592
584
 
593
585
    def reboot(self, instance, network_info):
594
586
        """Reboot a VM instance."""
595
 
        vm_ref = vm_util.get_vm_ref_from_name(self._session, instance['name'])
596
 
        if vm_ref is None:
597
 
            raise exception.InstanceNotFound(instance_id=instance['uuid'])
598
 
 
 
587
        vm_ref = vm_util.get_vm_ref(self._session, instance)
599
588
        self.plug_vifs(instance, network_info)
600
589
 
601
590
        lst_properties = ["summary.guest.toolsStatus", "runtime.powerState",
642
631
        2. Destroy the VM.
643
632
        """
644
633
        try:
645
 
            vm_ref = vm_util.get_vm_ref_from_name(self._session,
646
 
                                                  instance['name'])
647
 
            if vm_ref is None:
648
 
                LOG.debug(_("instance not present"), instance=instance)
649
 
                return
650
 
 
 
634
            vm_ref = vm_util.get_vm_ref(self._session, instance)
651
635
            self.power_off(instance)
652
 
 
653
636
            try:
654
637
                LOG.debug(_("Destroying the VM"), instance=instance)
655
638
                destroy_task = self._session._call_method(
674
657
        3. Delete the contents of the folder holding the VM related data.
675
658
        """
676
659
        try:
677
 
            vm_ref = vm_util.get_vm_ref_from_name(self._session,
678
 
                                                  instance['name'])
679
 
            if vm_ref is None:
680
 
                LOG.debug(_("instance not present"), instance=instance)
681
 
                return
 
660
            vm_ref = vm_util.get_vm_ref(self._session, instance)
682
661
            lst_properties = ["config.files.vmPathName", "runtime.powerState"]
683
662
            props = self._session._call_method(vim_util,
684
663
                        "get_object_properties",
757
736
 
758
737
    def suspend(self, instance):
759
738
        """Suspend the specified instance."""
760
 
        vm_ref = vm_util.get_vm_ref_from_name(self._session, instance['name'])
761
 
        if vm_ref is None:
762
 
            raise exception.InstanceNotFound(instance_id=instance['uuid'])
763
 
 
 
739
        vm_ref = vm_util.get_vm_ref(self._session, instance)
764
740
        pwr_state = self._session._call_method(vim_util,
765
741
                    "get_dynamic_property", vm_ref,
766
742
                    "VirtualMachine", "runtime.powerState")
781
757
 
782
758
    def resume(self, instance):
783
759
        """Resume the specified instance."""
784
 
        vm_ref = vm_util.get_vm_ref_from_name(self._session, instance['name'])
785
 
        if vm_ref is None:
786
 
            raise exception.InstanceNotFound(instance_id=instance['uuid'])
787
 
 
 
760
        vm_ref = vm_util.get_vm_ref(self._session, instance)
788
761
        pwr_state = self._session._call_method(vim_util,
789
762
                                     "get_dynamic_property", vm_ref,
790
763
                                     "VirtualMachine", "runtime.powerState")
806
779
            - spawn a rescue VM (the vm name-label will be instance-N-rescue).
807
780
 
808
781
        """
809
 
        vm_ref = vm_util.get_vm_ref_from_name(self._session, instance['name'])
810
 
        if vm_ref is None:
811
 
            raise exception.InstanceNotFound(instance_id=instance['uuid'])
 
782
        vm_ref = vm_util.get_vm_ref(self._session, instance)
812
783
 
813
784
        self.power_off(instance)
814
785
        instance['name'] = instance['name'] + self._rescue_suffix
822
793
            = vm_util.get_vmdk_path_and_adapter_type(hardware_devices)
823
794
        # Figure out the correct unit number
824
795
        unit_number = unit_number + 1
825
 
        rescue_vm_ref = vm_util.get_vm_ref_from_name(self._session,
 
796
        rescue_vm_ref = vm_util.get_vm_ref_from_uuid(self._session,
 
797
                                                     instance['uuid'])
 
798
        if rescue_vm_ref is None:
 
799
            rescue_vm_ref = vm_util.get_vm_ref_from_name(self._session,
826
800
                                                     instance['name'])
827
801
        self._volumeops.attach_disk_to_vm(
828
802
                                rescue_vm_ref, instance,
836
810
        instance['name'] = instance['name'] + self._rescue_suffix
837
811
        self.destroy(instance, None)
838
812
        instance['name'] = instance_orig_name
839
 
        self.power_on(instance)
 
813
        self._power_on(instance)
840
814
 
841
815
    def power_off(self, instance):
842
816
        """Power off the specified instance."""
843
 
        vm_ref = vm_util.get_vm_ref_from_name(self._session, instance['name'])
844
 
        if vm_ref is None:
845
 
            raise exception.InstanceNotFound(instance_id=instance['uuid'])
 
817
        vm_ref = vm_util.get_vm_ref(self._session, instance)
846
818
 
847
819
        pwr_state = self._session._call_method(vim_util,
848
820
                    "get_dynamic_property", vm_ref,
863
835
            LOG.debug(_("VM was already in powered off state. So returning "
864
836
                        "without doing anything"), instance=instance)
865
837
 
866
 
    def power_on(self, instance):
 
838
    def _power_on(self, instance):
867
839
        """Power on the specified instance."""
868
 
        vm_ref = vm_util.get_vm_ref_from_name(self._session, instance['name'])
869
 
        if vm_ref is None:
870
 
            raise exception.InstanceNotFound(instance_id=instance['uuid'])
 
840
        vm_ref = vm_util.get_vm_ref(self._session, instance)
871
841
 
872
842
        pwr_state = self._session._call_method(vim_util,
873
843
                                     "get_dynamic_property", vm_ref,
884
854
            self._session._wait_for_task(instance['uuid'], poweron_task)
885
855
            LOG.debug(_("Powered on the VM"), instance=instance)
886
856
 
 
857
    def power_on(self, context, instance, network_info, block_device_info):
 
858
        self._power_on(instance)
 
859
 
887
860
    def _get_orig_vm_name_label(self, instance):
888
861
        return instance['name'] + '-orig'
889
862
 
915
888
                                       step=0,
916
889
                                       total_steps=RESIZE_TOTAL_STEPS)
917
890
 
918
 
        vm_ref = vm_util.get_vm_ref_from_name(self._session, instance['name'])
919
 
        if vm_ref is None:
920
 
            raise exception.InstanceNotFound(instance_id=instance['name'])
 
891
        vm_ref = vm_util.get_vm_ref(self._session, instance)
921
892
        host_ref = self._get_host_ref_from_name(dest)
922
893
        if host_ref is None:
923
894
            raise exception.HostNotFound(host=dest)
968
939
        """Confirms a resize, destroying the source VM."""
969
940
        instance_name = self._get_orig_vm_name_label(instance)
970
941
        # Destroy the original VM.
971
 
        vm_ref = vm_util.get_vm_ref_from_name(self._session, instance_name)
 
942
        vm_ref = vm_util.get_vm_ref_from_uuid(self._session, instance['uuid'])
 
943
        if vm_ref is None:
 
944
            vm_ref = vm_util.get_vm_ref_from_name(self._session, instance_name)
972
945
        if vm_ref is None:
973
946
            LOG.debug(_("instance not present"), instance=instance)
974
947
            return
987
960
        if network_info:
988
961
            self.unplug_vifs(instance, network_info)
989
962
 
990
 
    def finish_revert_migration(self, instance):
991
 
        """Finish reverting a resize, powering back on the instance."""
 
963
    def finish_revert_migration(self, instance, network_info,
 
964
                                block_device_info, power_on=True):
 
965
        """Finish reverting a resize."""
992
966
        # The original vm was suffixed with '-orig'; find it using
993
967
        # the old suffix, remove the suffix, then power it back on.
994
968
        name_label = self._get_orig_vm_name_label(instance)
1000
974
                  instance=instance)
1001
975
        rename_task = self._session._call_method(
1002
976
                            self._session._get_vim(),
1003
 
                            "Rename_Task", vm_ref, newName=instance['name'])
 
977
                            "Rename_Task", vm_ref, newName=instance['uuid'])
1004
978
        self._session._wait_for_task(instance['uuid'], rename_task)
1005
979
        LOG.debug(_("Renamed the VM from %s") % name_label,
1006
980
                  instance=instance)
1007
 
        self.power_on(instance)
 
981
        if power_on:
 
982
            self._power_on(instance)
1008
983
 
1009
984
    def finish_migration(self, context, migration, instance, disk_info,
1010
 
                         network_info, image_meta, resize_instance=False):
 
985
                         network_info, image_meta, resize_instance=False,
 
986
                         block_device_info=None, power_on=True):
1011
987
        """Completes a resize, turning on the migrated instance."""
1012
988
        # 4. Start VM
1013
 
        self.power_on(instance)
 
989
        if power_on:
 
990
            self._power_on(instance)
1014
991
        self._update_instance_progress(context, instance,
1015
992
                                       step=4,
1016
993
                                       total_steps=RESIZE_TOTAL_STEPS)
1018
995
    def live_migration(self, context, instance_ref, dest,
1019
996
                       post_method, recover_method, block_migration=False):
1020
997
        """Spawning live_migration operation for distributing high-load."""
1021
 
        vm_ref = vm_util.get_vm_ref_from_name(self._session, instance_ref.name)
1022
 
        if vm_ref is None:
1023
 
            raise exception.InstanceNotFound(instance_id=instance_ref.name)
 
998
        vm_ref = vm_util.get_vm_ref(self._session, instance_ref)
 
999
 
1024
1000
        host_ref = self._get_host_ref_from_name(dest)
1025
1001
        if host_ref is None:
1026
1002
            raise exception.HostNotFound(host=dest)
1056
1032
 
1057
1033
    def get_info(self, instance):
1058
1034
        """Return data about the VM instance."""
1059
 
        vm_ref = vm_util.get_vm_ref_from_name(self._session, instance['name'])
1060
 
        if vm_ref is None:
1061
 
            raise exception.InstanceNotFound(instance_id=instance['name'])
 
1035
        vm_ref = vm_util.get_vm_ref(self._session, instance)
1062
1036
 
1063
1037
        lst_properties = ["summary.config.numCpu",
1064
1038
                    "summary.config.memorySizeMB",
1092
1066
 
1093
1067
    def get_console_output(self, instance):
1094
1068
        """Return snapshot of console."""
1095
 
        vm_ref = vm_util.get_vm_ref_from_name(self._session, instance['name'])
1096
 
        if vm_ref is None:
1097
 
            raise exception.InstanceNotFound(instance_id=instance['uuid'])
1098
 
        param_list = {"id": str(vm_ref)}
 
1069
        vm_ref = vm_util.get_vm_ref(self._session, instance)
 
1070
 
 
1071
        param_list = {"id": str(vm_ref.value)}
1099
1072
        base_url = "%s://%s/screen?%s" % (self._session._scheme,
1100
1073
                                         self._session._host_ip,
1101
1074
                                         urllib.urlencode(param_list))
1113
1086
 
1114
1087
    def get_vnc_console(self, instance):
1115
1088
        """Return connection info for a vnc console."""
1116
 
        vm_ref = vm_util.get_vm_ref_from_name(self._session, instance['name'])
1117
 
        if vm_ref is None:
1118
 
            raise exception.InstanceNotFound(instance_id=instance['uuid'])
 
1089
        vm_ref = vm_util.get_vm_ref(self._session, instance)
1119
1090
 
1120
1091
        return {'host': CONF.vmwareapi_host_ip,
1121
1092
                'port': self._get_vnc_port(vm_ref),
1122
1093
                'internal_access_path': None}
1123
1094
 
 
1095
    def get_vnc_console_vcenter(self, instance):
 
1096
        """Return connection info for a vnc console using vCenter logic."""
 
1097
 
 
1098
        # vCenter does not run virtual machines and does not run
 
1099
        # a VNC proxy. Instead, you need to tell OpenStack to talk
 
1100
        # directly to the ESX host running the VM you are attempting
 
1101
        # to connect to via VNC.
 
1102
 
 
1103
        vnc_console = self.get_vnc_console(instance)
 
1104
        host_name = vm_util.get_host_name_for_vm(
 
1105
                        self._session,
 
1106
                        instance)
 
1107
        vnc_console['host'] = host_name
 
1108
 
 
1109
        # NOTE: VM can move hosts in some situations. Debug for admins.
 
1110
        LOG.debug(_("VM %(uuid)s is currently on host %(host_name)s"),
 
1111
                {'uuid': instance['name'], 'host_name': host_name})
 
1112
 
 
1113
        return vnc_console
 
1114
 
1124
1115
    @staticmethod
1125
1116
    def _get_vnc_port(vm_ref):
1126
1117
        """Return VNC port for an VM."""
1161
1152
        Set the machine id of the VM for guest tools to pick up and reconfigure
1162
1153
        the network interfaces.
1163
1154
        """
1164
 
        vm_ref = vm_util.get_vm_ref_from_name(self._session, instance['name'])
1165
 
        if vm_ref is None:
1166
 
            raise exception.InstanceNotFound(instance_id=instance['uuid'])
 
1155
        vm_ref = vm_util.get_vm_ref(self._session, instance)
1167
1156
 
1168
1157
        machine_id_change_spec = vm_util.get_machine_id_change_spec(
1169
1158
                                 client_factory,
1182
1171
        """
1183
1172
        Set the vnc configuration of the VM.
1184
1173
        """
1185
 
        vm_ref = vm_util.get_vm_ref_from_name(self._session, instance['name'])
1186
 
        if vm_ref is None:
1187
 
            raise exception.InstanceNotFound(instance_id=instance['uuid'])
 
1174
        vm_ref = vm_util.get_vm_ref(self._session, instance)
1188
1175
 
1189
1176
        vnc_config_spec = vm_util.get_vnc_config_spec(
1190
1177
                                      client_factory, port, password)
1329
1316
    def unplug_vifs(self, instance, network_info):
1330
1317
        """Unplug VIFs from networks."""
1331
1318
        pass
1332
 
 
1333
 
    def list_interfaces(self, instance_name):
1334
 
        """
1335
 
        Return the IDs of all the virtual network interfaces attached to the
1336
 
        specified instance, as a list.  These IDs are opaque to the caller
1337
 
        (they are only useful for giving back to this layer as a parameter to
1338
 
        interface_stats).  These IDs only need to be unique for a given
1339
 
        instance.
1340
 
        """
1341
 
        vm_ref = vm_util.get_vm_ref_from_name(self._session, instance_name)
1342
 
        if vm_ref is None:
1343
 
            raise exception.InstanceNotFound(instance_id=instance_name)
1344
 
 
1345
 
        interfaces = []
1346
 
        # Get the virtual network interfaces attached to the VM
1347
 
        hardware_devices = self._session._call_method(vim_util,
1348
 
                    "get_dynamic_property", vm_ref,
1349
 
                    "VirtualMachine", "config.hardware.device")
1350
 
 
1351
 
        for device in hardware_devices:
1352
 
            if device.__class__.__name__ in ["VirtualE1000", "VirtualE1000e",
1353
 
                "VirtualPCNet32", "VirtualVmxnet"]:
1354
 
                interfaces.append(device.key)
1355
 
 
1356
 
        return interfaces