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

« back to all changes in this revision

Viewing changes to nova/virt/vmwareapi/fake.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:
1
1
# vim: tabstop=4 shiftwidth=4 softtabstop=4
2
2
 
 
3
# Copyright (c) 2013 Hewlett-Packard Development Company, L.P.
3
4
# Copyright (c) 2012 VMware, Inc.
4
5
# Copyright (c) 2011 Citrix Systems, Inc.
5
6
# Copyright 2011 OpenStack Foundation
20
21
A fake VMware VI API implementation.
21
22
"""
22
23
 
 
24
import collections
23
25
import pprint
24
26
import uuid
25
27
 
81
83
    return lst_objs
82
84
 
83
85
 
84
 
class Prop(object):
 
86
class Property(object):
85
87
    """Property Object base class."""
86
88
 
87
 
    def __init__(self):
88
 
        self.name = None
89
 
        self.val = None
 
89
    def __init__(self, name=None, val=None):
 
90
        self.name = name
 
91
        self.val = val
 
92
 
 
93
 
 
94
class ManagedObjectReference(object):
 
95
    """A managed object reference is a remote identifier."""
 
96
 
 
97
    def __init__(self, value="object-123", _type="ManagedObject"):
 
98
        super(ManagedObjectReference, self)
 
99
        # Managed Object Reference value attributes
 
100
        # typically have values like vm-123 or
 
101
        # host-232 and not UUID.
 
102
        self.value = value
 
103
        # Managed Object Reference _type
 
104
        # attributes hold the name of the type
 
105
        # of the vCenter object the value
 
106
        # attribute is the identifier for
 
107
        self._type = _type
 
108
 
 
109
 
 
110
class ObjectContent(object):
 
111
    """ObjectContent array holds dynamic properties."""
 
112
 
 
113
    # This class is a *fake* of a class sent back to us by
 
114
    # SOAP. It has its own names. These names are decided
 
115
    # for us by the API we are *faking* here.
 
116
    def __init__(self, obj_ref, prop_list=None, missing_list=None):
 
117
        self.obj = obj_ref
 
118
 
 
119
        if not isinstance(prop_list, collections.Iterable):
 
120
            prop_list = []
 
121
 
 
122
        if not isinstance(missing_list, collections.Iterable):
 
123
            missing_list = []
 
124
 
 
125
        # propSet is the name your Python code will need to
 
126
        # use since this is the name that the API will use
 
127
        self.propSet = prop_list
 
128
 
 
129
        # missingSet is the name your python code will
 
130
        # need to use since this is the name that the
 
131
        # API we are talking to will use.
 
132
        self.missingSet = missing_list
90
133
 
91
134
 
92
135
class ManagedObject(object):
93
 
    """Managed Data Object base class."""
 
136
    """Managed Object base class."""
94
137
 
95
 
    def __init__(self, name="ManagedObject", obj_ref=None):
 
138
    def __init__(self, name="ManagedObject", obj_ref=None, value=None):
96
139
        """Sets the obj property which acts as a reference to the object."""
97
140
        super(ManagedObject, self).__setattr__('objName', name)
 
141
 
 
142
        # A managed object is a local representation of a
 
143
        # remote object that you can reference using the
 
144
        # object reference.
98
145
        if obj_ref is None:
99
 
            obj_ref = str(uuid.uuid4())
 
146
            if value is None:
 
147
                value = 'obj-123'
 
148
            obj_ref = ManagedObjectReference(value, name)
 
149
 
 
150
        # we use __setattr__ here because below the
 
151
        # default setter has been altered for this class.
100
152
        object.__setattr__(self, 'obj', obj_ref)
101
153
        object.__setattr__(self, 'propSet', [])
102
154
 
116
168
        return self.__getattr__(attr)
117
169
 
118
170
    def __setattr__(self, attr, val):
 
171
        # TODO(hartsocks): this is adds unnecessary complexity to the class
119
172
        for prop in self.propSet:
120
173
            if prop.name == attr:
121
174
                prop.val = val
122
175
                return
123
 
        elem = Prop()
 
176
        elem = Property()
124
177
        elem.name = attr
125
178
        elem.val = val
126
179
        self.propSet.append(elem)
127
180
 
128
181
    def __getattr__(self, attr):
 
182
        # TODO(hartsocks): remove this
 
183
        # in a real ManagedObject you have to iterate the propSet
 
184
        # in a real ManagedObject, the propSet is a *set* not a list
129
185
        for elem in self.propSet:
130
186
            if elem.name == attr:
131
187
                return elem.val
136
192
 
137
193
class DataObject(object):
138
194
    """Data object base class."""
139
 
    pass
 
195
    def __init__(self, obj_name=None):
 
196
        self.obj_name = obj_name
140
197
 
141
198
 
142
199
class VirtualDisk(DataObject):
184
241
    """Virtual Machine class."""
185
242
 
186
243
    def __init__(self, **kwargs):
187
 
        super(VirtualMachine, self).__init__("VirtualMachine")
 
244
        super(VirtualMachine, self).__init__("VirtualMachine", value='vm-10')
188
245
        self.set("name", kwargs.get("name"))
189
246
        self.set("runtime.connectionState",
190
247
                 kwargs.get("conn_state", "connected"))
202
259
        self.set("summary.config.memorySizeMB", kwargs.get("mem", 1))
203
260
        self.set("config.hardware.device", kwargs.get("virtual_device", None))
204
261
        self.set("config.extraConfig", kwargs.get("extra_config", None))
 
262
        self.set('runtime.host',
 
263
                 ManagedObjectReference(value='host-123', _type="HostSystem"))
 
264
        self.device = kwargs.get("virtual_device")
205
265
 
206
266
    def reconfig(self, factory, val):
207
267
        """
224
284
            controller = VirtualLsiLogicController()
225
285
            controller.key = controller_key
226
286
 
227
 
            nic = VirtualPCNet32()
228
 
 
229
 
            self.set("config.hardware.device", [disk, controller, nic])
 
287
            self.set("config.hardware.device", [disk, controller,
 
288
                                                  self.device[0]])
230
289
        except AttributeError:
231
290
            # Case of Reconfig of VM to set extra params
232
291
            self.set("config.extraConfig", val.extraConfig)
255
314
        super(Datastore, self).__init__("Datastore")
256
315
        self.set("summary.type", "VMFS")
257
316
        self.set("summary.name", "fake-ds")
258
 
        self.set("summary.capacity", 1024 * 1024 * 1024)
259
 
        self.set("summary.freeSpace", 500 * 1024 * 1024)
 
317
        self.set("summary.capacity", 1024 * 1024 * 1024 * 1024)
 
318
        self.set("summary.freeSpace", 500 * 1024 * 1024 * 1024)
260
319
 
261
320
 
262
321
class HostNetworkSystem(ManagedObject):
278
337
class HostSystem(ManagedObject):
279
338
    """Host System class."""
280
339
 
281
 
    def __init__(self):
282
 
        super(HostSystem, self).__init__("HostSystem")
 
340
    def __init__(self, obj_ref=None, value='host-123'):
 
341
        super(HostSystem, self).__init__("HostSystem", obj_ref, value)
283
342
        self.set("name", "ha-host")
284
343
        if _db_content.get("HostNetworkSystem", None) is None:
285
344
            create_host_network_system()
308
367
        config.product = product
309
368
        summary.config = config
310
369
 
 
370
        pnic_do = DataObject()
 
371
        pnic_do.device = "vmnic0"
 
372
        net_info_pnic = DataObject()
 
373
        net_info_pnic.PhysicalNic = [pnic_do]
 
374
 
311
375
        self.set("summary", summary)
 
376
        self.set("config.network.pnic", net_info_pnic)
312
377
 
313
378
        if _db_content.get("Network", None) is None:
314
379
            create_network()
495
560
 
496
561
    def create(self, obj_name):
497
562
        """Creates a namespace object."""
498
 
        return DataObject()
 
563
        return DataObject(obj_name)
499
564
 
500
565
 
501
566
class FakeVim(object):
577
642
                  "powerstate": "poweredOff",
578
643
                  "vmPathName": config_spec.files.vmPathName,
579
644
                  "numCpu": config_spec.numCPUs,
580
 
                  "mem": config_spec.memoryMB}
 
645
                  "mem": config_spec.memoryMB,
 
646
                  "virtual_device": config_spec.deviceChange,
 
647
                  "extra_config": config_spec.extraConfig}
581
648
        virtual_machine = VirtualMachine(**vm_dict)
582
649
        _create_object("VirtualMachine", virtual_machine)
583
650
        task_mdo = create_task(method, "success")