summaryrefslogtreecommitdiff
path: root/cloud
diff options
context:
space:
mode:
authorJames Tanner <tanner.jc@gmail.com>2016-08-01 22:47:26 -0400
committerJames Tanner <tanner.jc@gmail.com>2016-08-01 22:47:26 -0400
commita3f415a892b6da42ad4ad8f007307e323e8ae8a5 (patch)
tree2978b7e360a7b08515abd8f908c6856597bcce98 /cloud
parent5d2d0e0045e7935b8fd55bdfcd31202c8e59544b (diff)
downloadansible-modules-extras-a3f415a892b6da42ad4ad8f007307e323e8ae8a5.tar.gz
fix tabs
Diffstat (limited to 'cloud')
-rw-r--r--cloud/vmware/vmware_guest_state.py56
1 files changed, 24 insertions, 32 deletions
diff --git a/cloud/vmware/vmware_guest_state.py b/cloud/vmware/vmware_guest_state.py
index 298d1098..ed8a3b2c 100644
--- a/cloud/vmware/vmware_guest_state.py
+++ b/cloud/vmware/vmware_guest_state.py
@@ -263,28 +263,25 @@ class PyVmomiHelper(object):
def set_powerstate(self, vm, state, force):
- """
- Set the power status for a VM determined by the current and
- requested states. force is forceful
- """
+ """
+ Set the power status for a VM determined by the current and
+ requested states. force is forceful
+ """
facts = self.gather_facts(vm)
expected_state = state.replace('_', '').lower()
current_state = facts['hw_power_status'].lower()
result = {}
- # Need Force
- if not force and current_state not in ['poweredon', 'poweredoff']:
- return "VM is in %s power state. Force is required!" % current_state
+ # Need Force
+ if not force and current_state not in ['poweredon', 'poweredoff']:
+ return "VM is in %s power state. Force is required!" % current_state
- # State is already true
- if current_state == expected_state:
+ # State is already true
+ if current_state == expected_state:
result['changed'] = False
result['failed'] = False
-
- else:
-
+ else:
task = None
-
try:
if expected_state == 'poweredoff':
task = vm.PowerOff()
@@ -341,9 +338,6 @@ class PyVmomiHelper(object):
mac = device.macAddress
ips = list(device.ipAddress)
netDict[mac] = ips
- #facts['network'] = {}
- #facts['network']['ipaddress_v4'] = None
- #facts['network']['ipaddress_v6'] = None
for k,v in netDict.iteritems():
for ipaddress in v:
if ipaddress:
@@ -352,23 +346,21 @@ class PyVmomiHelper(object):
else:
facts['ipv4'] = ipaddress
- for idx,entry in enumerate(vm.config.hardware.device):
+ for idx,entry in enumerate(vm.config.hardware.device):
+ if not hasattr(entry, 'macAddress'):
+ continue
+
+ factname = 'hw_eth' + str(idx)
+ facts[factname] = {
+ 'addresstype': entry.addressType,
+ 'label': entry.deviceInfo.label,
+ 'macaddress': entry.macAddress,
+ 'ipaddresses': netDict.get(entry.macAddress, None),
+ 'macaddress_dash': entry.macAddress.replace(':', '-'),
+ 'summary': entry.deviceInfo.summary,
+ }
+ facts['hw_interfaces'].append('eth'+str(idx))
- if not hasattr(entry, 'macAddress'):
- continue
-
- factname = 'hw_eth' + str(idx)
- facts[factname] = {
- 'addresstype': entry.addressType,
- 'label': entry.deviceInfo.label,
- 'macaddress': entry.macAddress,
- 'ipaddresses': netDict.get(entry.macAddress, None),
- 'macaddress_dash': entry.macAddress.replace(':', '-'),
- 'summary': entry.deviceInfo.summary,
- }
- facts['hw_interfaces'].append('eth'+str(idx))
-
- #import epdb; epdb.st()
return facts