Refactor MAAS power processing
Change-Id: I327b5ed71c2ba164f3d9dcab076c1dbe423cf91a
Related-bug: PROD-21897
diff --git a/_modules/maas.py b/_modules/maas.py
index aa57498..b0f5bb2 100644
--- a/_modules/maas.py
+++ b/_modules/maas.py
@@ -421,27 +421,11 @@
'mac_addresses': machine_pxe_mac,
'power_type': power_data.get('power_type', 'manual'),
}
- if 'power_address' in power_data:
- data['power_parameters_power_address'] = power_data['power_address']
- if 'power_driver' in power_data:
- data['power_parameters_power_driver'] = power_data['power_driver']
- if 'power_user' in power_data:
- data['power_parameters_power_user'] = power_data['power_user']
- if 'power_password' in power_data:
- data['power_parameters_power_pass'] = \
- power_data['power_password']
- if 'power_id' in power_data:
- data['power_parameters_power_id'] = power_data['power_id']
- if 'power_nova_id' in power_data:
- data['power_parameters_nova_id'] = power_data['power_nova_id']
- if 'power_os_tenantname' in power_data:
- data['power_parameters_os_tenantname'] = power_data['power_os_tenantname']
- if 'power_os_username' in power_data:
- data['power_parameters_os_username'] = power_data['power_os_username']
- if 'power_os_password' in power_data:
- data['power_parameters_os_password'] = power_data['power_os_password']
- if 'power_os_authurl' in power_data:
- data['power_parameters_os_authurl'] = power_data['power_os_authurl']
+ for k,v in power_data.items():
+ if k == 'power_type':
+ continue
+ data_key = 'power_parameters_{}'.format(k)
+ data[data_key] = v
return data
def update(self, new, old):