fb-vmware 1.5.1__py3-none-any.whl → 1.6.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. fb_vmware/__init__.py +3 -3
  2. fb_vmware/about.py +70 -59
  3. fb_vmware/app/__init__.py +104 -39
  4. fb_vmware/app/get_host_list.py +160 -96
  5. fb_vmware/app/get_network_list.py +171 -125
  6. fb_vmware/app/get_storage_cluster_list.py +135 -78
  7. fb_vmware/app/get_vm_info.py +103 -57
  8. fb_vmware/app/get_vm_list.py +208 -128
  9. fb_vmware/base.py +85 -57
  10. fb_vmware/cluster.py +131 -77
  11. fb_vmware/config/__init__.py +161 -115
  12. fb_vmware/connect.py +561 -350
  13. fb_vmware/controller.py +146 -106
  14. fb_vmware/datastore.py +154 -107
  15. fb_vmware/dc.py +95 -59
  16. fb_vmware/disk.py +145 -98
  17. fb_vmware/ds_cluster.py +87 -54
  18. fb_vmware/dvs.py +183 -123
  19. fb_vmware/errors.py +48 -40
  20. fb_vmware/ether.py +196 -141
  21. fb_vmware/host.py +242 -162
  22. fb_vmware/host_port_group.py +115 -68
  23. fb_vmware/iface.py +35 -24
  24. fb_vmware/network.py +107 -78
  25. fb_vmware/obj.py +72 -58
  26. fb_vmware/typed_dict.py +25 -26
  27. fb_vmware/vm.py +226 -162
  28. fb_vmware/xlate.py +24 -27
  29. fb_vmware-1.6.0.data/data/share/locale/de_DE/LC_MESSAGES/fb_vmware.mo +0 -0
  30. fb_vmware-1.6.0.data/data/share/locale/en_US/LC_MESSAGES/fb_vmware.mo +0 -0
  31. fb_vmware-1.6.0.dist-info/METADATA +54 -0
  32. fb_vmware-1.6.0.dist-info/RECORD +35 -0
  33. {fb_vmware-1.5.1.dist-info → fb_vmware-1.6.0.dist-info}/WHEEL +1 -2
  34. fb_vmware-1.6.0.dist-info/entry_points.txt +7 -0
  35. fb_vmware/local_version.py +0 -17
  36. fb_vmware-1.5.1.data/data/share/locale/de_DE/LC_MESSAGES/fb_vmware.mo +0 -0
  37. fb_vmware-1.5.1.data/data/share/locale/en_US/LC_MESSAGES/fb_vmware.mo +0 -0
  38. fb_vmware-1.5.1.data/scripts/get-vsphere-host-list +0 -71
  39. fb_vmware-1.5.1.data/scripts/get-vsphere-network-list +0 -71
  40. fb_vmware-1.5.1.data/scripts/get-vsphere-storage-cluster-list +0 -71
  41. fb_vmware-1.5.1.data/scripts/get-vsphere-vm-info +0 -71
  42. fb_vmware-1.5.1.data/scripts/get-vsphere-vm-list +0 -71
  43. fb_vmware-1.5.1.dist-info/METADATA +0 -51
  44. fb_vmware-1.5.1.dist-info/RECORD +0 -41
  45. fb_vmware-1.5.1.dist-info/top_level.txt +0 -1
  46. {fb_vmware-1.5.1.dist-info → fb_vmware-1.6.0.dist-info}/licenses/LICENSE +0 -0
fb_vmware/dvs.py CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env python
2
2
  # -*- coding: utf-8 -*-
3
3
  """
4
- @summary: The module for a VSphere Distributed Virtual Switching.
4
+ @summary: The module for a vSphere Distributed Virtual Switching.
5
5
 
6
6
  The following classes were definded:
7
7
  * Distributed Virtual Switch
@@ -27,110 +27,129 @@ from .obj import DEFAULT_OBJ_STATUS
27
27
  from .obj import VsphereObject
28
28
  from .xlate import XLATOR
29
29
 
30
- __version__ = '0.4.2'
30
+ __version__ = "0.4.2"
31
31
  LOG = logging.getLogger(__name__)
32
32
 
33
33
  _ = XLATOR.gettext
34
34
 
35
+
35
36
  # =============================================================================
36
37
  class VsphereDVS(VsphereObject):
37
- """Wrapper class for a VSphere Distributed Virtual Switch (vim.DistributedVirtualSwitch)."""
38
+ """Wrapper class for a vSphere Distributed Virtual Switch (vim.DistributedVirtualSwitch)."""
38
39
 
39
40
  properties = [
40
- 'contact_info',
41
- 'contact_name',
42
- 'create_time',
43
- 'def_proxy_switch_max_num_ports',
44
- 'description',
45
- 'extension_key',
46
- 'ip_address',
47
- 'max_ports',
48
- 'net_resource_mgmt_enabled',
49
- 'num_hosts',
50
- 'num_ports',
51
- 'num_standalone_ports',
52
- 'pnic_cap_ratio_reservation',
53
- 'product_name',
54
- 'product_vendor',
55
- 'product_version',
56
- 'uuid',
41
+ "contact_info",
42
+ "contact_name",
43
+ "create_time",
44
+ "def_proxy_switch_max_num_ports",
45
+ "description",
46
+ "extension_key",
47
+ "ip_address",
48
+ "max_ports",
49
+ "net_resource_mgmt_enabled",
50
+ "num_hosts",
51
+ "num_ports",
52
+ "num_standalone_ports",
53
+ "pnic_cap_ratio_reservation",
54
+ "product_name",
55
+ "product_vendor",
56
+ "product_version",
57
+ "uuid",
57
58
  ]
58
59
 
59
60
  prop_source = {
60
- 'uuid': 'uuid',
61
+ "uuid": "uuid",
61
62
  }
62
63
 
63
64
  prop_source_config = {
64
- 'create_time': 'createTime',
65
- 'def_proxy_switch_max_num_ports': 'defaultProxySwitchMaxNumPorts',
66
- 'description': 'description',
67
- 'extension_key': 'extensionKey',
68
- 'ip_address': 'switchIpAddress',
69
- 'max_ports': 'maxPorts',
70
- 'name': 'name',
71
- 'net_resource_mgmt_enabled': 'networkResourceManagementEnabled',
72
- 'num_ports': 'numPorts',
73
- 'num_standalone_ports': 'numStandalonePorts',
74
- 'pnic_cap_ratio_reservation': 'pnicCapacityRatioForReservation',
65
+ "create_time": "createTime",
66
+ "def_proxy_switch_max_num_ports": "defaultProxySwitchMaxNumPorts",
67
+ "description": "description",
68
+ "extension_key": "extensionKey",
69
+ "ip_address": "switchIpAddress",
70
+ "max_ports": "maxPorts",
71
+ "name": "name",
72
+ "net_resource_mgmt_enabled": "networkResourceManagementEnabled",
73
+ "num_ports": "numPorts",
74
+ "num_standalone_ports": "numStandalonePorts",
75
+ "pnic_cap_ratio_reservation": "pnicCapacityRatioForReservation",
75
76
  }
76
77
 
77
78
  prop_source_contact = {
78
- 'contact_info': 'contact',
79
- 'contact_name': 'name',
79
+ "contact_info": "contact",
80
+ "contact_name": "name",
80
81
  }
81
82
 
82
83
  prop_source_product = {
83
- 'product_name': 'name',
84
- 'product_vendor': 'vendor',
85
- 'product_version': 'version',
84
+ "product_name": "name",
85
+ "product_vendor": "vendor",
86
+ "product_version": "version",
86
87
  }
87
88
 
88
89
  prop_source_summary = {
89
- 'num_hosts': 'numHosts',
90
+ "num_hosts": "numHosts",
90
91
  }
91
92
 
92
93
  necessary_fields = [
93
- 'uuid',
94
+ "uuid",
94
95
  ]
95
96
 
96
97
  necessary_config_fields = [
97
- 'createTime',
98
- 'maxPorts',
99
- 'numPorts',
100
- 'numStandalonePorts',
98
+ "createTime",
99
+ "maxPorts",
100
+ "numPorts",
101
+ "numStandalonePorts",
101
102
  ]
102
103
 
103
- repr_fields = ['name'] + properties + ['appname', 'verbose']
104
+ repr_fields = ["name"] + properties + ["appname", "verbose"]
104
105
 
105
106
  # -------------------------------------------------------------------------
106
107
  def __init__(
107
- self, appname=None, verbose=0, version=__version__, base_dir=None, initialized=None,
108
- name=None, obj_type='vsphere_vds', name_prefix='vds', status=DEFAULT_OBJ_STATUS,
109
- config_status=DEFAULT_OBJ_STATUS, **kwargs):
108
+ self,
109
+ appname=None,
110
+ verbose=0,
111
+ version=__version__,
112
+ base_dir=None,
113
+ initialized=None,
114
+ name=None,
115
+ obj_type="vsphere_vds",
116
+ name_prefix="vds",
117
+ status=DEFAULT_OBJ_STATUS,
118
+ config_status=DEFAULT_OBJ_STATUS,
119
+ **kwargs,
120
+ ):
110
121
  """Initialize a VsphereDVS object."""
111
122
  for prop in self.properties:
112
- setattr(self, '_' + prop, None)
123
+ setattr(self, "_" + prop, None)
113
124
 
114
125
  self._dvs = None
115
126
 
116
127
  super(VsphereDVS, self).__init__(
117
- name=name, obj_type=obj_type, name_prefix=name_prefix, status=status,
118
- config_status=config_status, appname=appname, verbose=verbose,
119
- version=version, base_dir=base_dir)
128
+ name=name,
129
+ obj_type=obj_type,
130
+ name_prefix=name_prefix,
131
+ status=status,
132
+ config_status=config_status,
133
+ appname=appname,
134
+ verbose=verbose,
135
+ version=version,
136
+ base_dir=base_dir,
137
+ )
120
138
 
121
139
  for argname in kwargs:
122
140
  if argname not in self.properties:
123
- msg = _('Invalid Argument {arg!r} on {what} given.').format(
124
- arg=argname, what='VsphereDVS.init()')
141
+ msg = _("Invalid Argument {arg!r} on {what} given.").format(
142
+ arg=argname, what="VsphereDVS.init()"
143
+ )
125
144
  raise AttributeError(msg)
126
145
  if kwargs[argname] is not None:
127
- setattr(self, '_' + argname, kwargs[argname])
146
+ setattr(self, "_" + argname, kwargs[argname])
128
147
 
129
148
  if initialized is not None:
130
149
  self.initialized = initialized
131
150
 
132
151
  if self.verbose > 3:
133
- LOG.debug(_('Initialized Distributed Virtual Switch:') + '\n' + pp(self.as_dict()))
152
+ LOG.debug(_("Initialized Distributed Virtual Switch:") + "\n" + pp(self.as_dict()))
134
153
 
135
154
  # -----------------------------------------------------------
136
155
  @property
@@ -260,7 +279,7 @@ class VsphereDVS(VsphereObject):
260
279
  def __eq__(self, other):
261
280
  """Magic method for using it as the '=='-operator."""
262
281
  if self.verbose > 4:
263
- LOG.debug(_('Comparing {} objects ...').format(self.__class__.__name__))
282
+ LOG.debug(_("Comparing {} objects ...").format(self.__class__.__name__))
264
283
 
265
284
  if not isinstance(other, VsphereDVS):
266
285
  return False
@@ -274,8 +293,9 @@ class VsphereDVS(VsphereObject):
274
293
  def search_port_keys(self, portgroup_key):
275
294
  """Search usable ports in the current DVS by a Port Group key."""
276
295
  if not self._dvs:
277
- msg = _('No {o} reference found in VDS {n!r}.').format(
278
- o='vim.DistributedVirtualSwitch', n=self.name)
296
+ msg = _("No {o} reference found in VDS {n!r}.").format(
297
+ o="vim.DistributedVirtualSwitch", n=self.name
298
+ )
279
299
  raise RuntimeError(msg)
280
300
 
281
301
  port_keys = []
@@ -288,8 +308,8 @@ class VsphereDVS(VsphereObject):
288
308
  for port in ports:
289
309
  port_keys.append(port.key)
290
310
  if self.verbose > 1:
291
- msg = _('Found usable port keys for DVS {!r}:').format(self.name)
292
- msg += ' ' + pp(port_keys)
311
+ msg = _("Found usable port keys for DVS {!r}:").format(self.name)
312
+ msg += " " + pp(port_keys)
293
313
 
294
314
  return port_keys
295
315
 
@@ -297,8 +317,9 @@ class VsphereDVS(VsphereObject):
297
317
  def find_port_by_portkey(self, port_key):
298
318
  """Find a port object by a given port key."""
299
319
  if not self._dvs:
300
- msg = _('No {o} reference found in VDS {n!r}.').format(
301
- o='vim.DistributedVirtualSwitch', n=self.name)
320
+ msg = _("No {o} reference found in VDS {n!r}.").format(
321
+ o="vim.DistributedVirtualSwitch", n=self.name
322
+ )
302
323
  raise RuntimeError(msg)
303
324
 
304
325
  obj = None
@@ -347,10 +368,10 @@ class VsphereDVS(VsphereObject):
347
368
  # raise TypeError(msg)
348
369
 
349
370
  params = {
350
- 'appname': appname,
351
- 'verbose': verbose,
352
- 'base_dir': base_dir,
353
- 'initialized': True,
371
+ "appname": appname,
372
+ "verbose": verbose,
373
+ "base_dir": base_dir,
374
+ "initialized": True,
354
375
  }
355
376
 
356
377
  for prop in cls.prop_source:
@@ -385,10 +406,13 @@ class VsphereDVS(VsphereObject):
385
406
 
386
407
  if verbose > 1:
387
408
  if verbose > 2:
388
- LOG.debug(_('Creating {} object from:').format(cls.__name__) + '\n' + pp(params))
409
+ LOG.debug(_("Creating {} object from:").format(cls.__name__) + "\n" + pp(params))
389
410
  else:
390
- LOG.debug(_('Creating {cls} object {name!r}.').format(
391
- cls=cls.__name__, name=data.summary.name))
411
+ LOG.debug(
412
+ _("Creating {cls} object {name!r}.").format(
413
+ cls=cls.__name__, name=data.summary.name
414
+ )
415
+ )
392
416
 
393
417
  vds = cls(**params)
394
418
 
@@ -399,72 +423,106 @@ class VsphereDVS(VsphereObject):
399
423
 
400
424
  # =============================================================================
401
425
  class VsphereDvPortGroup(VsphereNetwork):
402
- """Wrapper class for a Network definition in VSPhere (vim.dvs.DistributedVirtualPortgroup)."""
426
+ """Wrapper class for a Network definition in vSphere (vim.dvs.DistributedVirtualPortgroup)."""
403
427
 
404
428
  repr_fields = (
405
- 'name', 'obj_type', 'status', 'config_status', 'accessible',
406
- 'ip_pool_id', 'ip_pool_name', 'appname', 'verbose')
429
+ "name",
430
+ "obj_type",
431
+ "status",
432
+ "config_status",
433
+ "accessible",
434
+ "ip_pool_id",
435
+ "ip_pool_name",
436
+ "appname",
437
+ "verbose",
438
+ )
407
439
 
408
440
  dvpg_properties = [
409
- 'auto_expand',
410
- 'backing_type',
411
- 'description',
412
- 'dvs_uuid',
413
- 'key',
414
- 'num_ports',
415
- 'port_keys',
416
- 'port_name_format',
417
- 'segment_id',
418
- 'pg_type',
419
- 'uplink',
441
+ "auto_expand",
442
+ "backing_type",
443
+ "description",
444
+ "dvs_uuid",
445
+ "key",
446
+ "num_ports",
447
+ "port_keys",
448
+ "port_name_format",
449
+ "segment_id",
450
+ "pg_type",
451
+ "uplink",
420
452
  ]
421
453
 
422
454
  repr_fields = [
423
- 'name', 'obj_type', 'status', 'config_status', 'accessible',
424
- 'ip_pool_id', 'ip_pool_name', 'appname', 'verbose',
425
- 'auto_expand', 'backing_type', 'description', 'dvs_uuid', 'key',
426
- 'num_ports', 'port_keys', 'port_name_format', 'segment_id', 'pg_type', 'uplink',
455
+ "name",
456
+ "obj_type",
457
+ "status",
458
+ "config_status",
459
+ "accessible",
460
+ "ip_pool_id",
461
+ "ip_pool_name",
462
+ "appname",
463
+ "verbose",
464
+ "auto_expand",
465
+ "backing_type",
466
+ "description",
467
+ "dvs_uuid",
468
+ "key",
469
+ "num_ports",
470
+ "port_keys",
471
+ "port_name_format",
472
+ "segment_id",
473
+ "pg_type",
474
+ "uplink",
427
475
  ]
428
476
 
429
477
  dvpg_prop_source = {
430
- 'key': 'key',
431
- 'port_keys': 'portKeys',
478
+ "key": "key",
479
+ "port_keys": "portKeys",
432
480
  }
433
481
 
434
482
  dvpg_prop_source_config = {
435
- 'auto_expand': 'autoExpand',
436
- 'backing_type': 'backingType',
437
- 'description': 'description',
438
- 'num_ports': 'numPorts',
439
- 'port_name_format': 'portNameFormat',
440
- 'segment_id': 'segmentId',
441
- 'pg_type': 'type',
442
- 'uplink': 'uplink',
483
+ "auto_expand": "autoExpand",
484
+ "backing_type": "backingType",
485
+ "description": "description",
486
+ "num_ports": "numPorts",
487
+ "port_name_format": "portNameFormat",
488
+ "segment_id": "segmentId",
489
+ "pg_type": "type",
490
+ "uplink": "uplink",
443
491
  }
444
492
 
445
- obj_desc_singular = _('Distrubuted Virtual Port Group')
446
- obj_desc_plural = _('Distrubuted Virtual Port Groups')
493
+ obj_desc_singular = _("Distrubuted Virtual Port Group")
494
+ obj_desc_plural = _("Distrubuted Virtual Port Groups")
447
495
 
448
496
  # -------------------------------------------------------------------------
449
497
  def __init__(
450
- self, appname=None, verbose=0, version=__version__, base_dir=None, initialized=None,
451
- name=None, obj_type='vsphere_dvportgroup', name_prefix='dvpg',
452
- status=DEFAULT_OBJ_STATUS, config_status=DEFAULT_OBJ_STATUS, **kwargs):
498
+ self,
499
+ appname=None,
500
+ verbose=0,
501
+ version=__version__,
502
+ base_dir=None,
503
+ initialized=None,
504
+ name=None,
505
+ obj_type="vsphere_dvportgroup",
506
+ name_prefix="dvpg",
507
+ status=DEFAULT_OBJ_STATUS,
508
+ config_status=DEFAULT_OBJ_STATUS,
509
+ **kwargs,
510
+ ):
453
511
  """Initialize a VsphereDvPortGroup object."""
454
512
  for prop in self.dvpg_properties:
455
- setattr(self, '_' + prop, None)
513
+ setattr(self, "_" + prop, None)
456
514
 
457
515
  init_args = {
458
- 'name': name,
459
- 'obj_type': obj_type,
460
- 'name_prefix': name_prefix,
461
- 'status': status,
462
- 'config_status': config_status,
463
- 'appname': appname,
464
- 'verbose': verbose,
465
- 'version': version,
466
- 'base_dir': base_dir,
467
- 'initialized': initialized,
516
+ "name": name,
517
+ "obj_type": obj_type,
518
+ "name_prefix": name_prefix,
519
+ "status": status,
520
+ "config_status": config_status,
521
+ "appname": appname,
522
+ "verbose": verbose,
523
+ "version": version,
524
+ "base_dir": base_dir,
525
+ "initialized": initialized,
468
526
  }
469
527
 
470
528
  for arg in kwargs:
@@ -477,8 +535,9 @@ class VsphereDvPortGroup(VsphereNetwork):
477
535
 
478
536
  for arg in kwargs:
479
537
  if arg not in self.net_properties and arg not in self.dvpg_properties:
480
- msg = _('Invalid Argument {arg!r} on {what} given.').format(
481
- arg=arg, what='VsphereNetwork.init()')
538
+ msg = _("Invalid Argument {arg!r} on {what} given.").format(
539
+ arg=arg, what="VsphereNetwork.init()"
540
+ )
482
541
  raise AttributeError(msg)
483
542
  if arg in self.dvpg_properties and kwargs[arg] is not None:
484
543
  setattr(self, arg, kwargs[arg])
@@ -487,7 +546,7 @@ class VsphereDvPortGroup(VsphereNetwork):
487
546
  self.initialized = initialized
488
547
 
489
548
  if self.verbose > 3:
490
- LOG.debug(_('Initialized network object:') + '\n' + pp(self.as_dict()))
549
+ LOG.debug(_("Initialized network object:") + "\n" + pp(self.as_dict()))
491
550
 
492
551
  # -----------------------------------------------------------
493
552
  @property
@@ -644,8 +703,8 @@ class VsphereDvPortGroup(VsphereNetwork):
644
703
  if value is not None:
645
704
  params[prop] = value
646
705
 
647
- if hasattr(data.config, 'distributedVirtualSwitch'):
648
- params['dvs_uuid'] = data.config.distributedVirtualSwitch.uuid
706
+ if hasattr(data.config, "distributedVirtualSwitch"):
707
+ params["dvs_uuid"] = data.config.distributedVirtualSwitch.uuid
649
708
 
650
709
  return params
651
710
 
@@ -665,8 +724,9 @@ class VsphereDvPortGroup(VsphereNetwork):
665
724
  """Return a backing device for a new virtual network interface."""
666
725
  if self.verbose > 1:
667
726
  msg = _(
668
- 'Creating network device backing specification with a '
669
- 'Distributed Virtual Port Group.')
727
+ "Creating network device backing specification with a "
728
+ "Distributed Virtual Port Group."
729
+ )
670
730
  LOG.debug(msg)
671
731
 
672
732
  backing_device = vim.vm.device.VirtualEthernetCard.DistributedVirtualPortBackingInfo()
@@ -677,14 +737,14 @@ class VsphereDvPortGroup(VsphereNetwork):
677
737
  backing_device.port.portKey = port.key
678
738
 
679
739
  if self.verbose > 0:
680
- msg = _('Got Backing device for port group {!r}:').format(self.name)
681
- LOG.debug(msg + ' ' + pp(backing_device))
740
+ msg = _("Got Backing device for port group {!r}:").format(self.name)
741
+ LOG.debug(msg + " " + pp(backing_device))
682
742
 
683
743
  return backing_device
684
744
 
685
745
 
686
746
  # =============================================================================
687
- if __name__ == '__main__':
747
+ if __name__ == "__main__":
688
748
 
689
749
  pass
690
750