4 class HardwareAdapter(object):
5 def __init__(self, yaml_path):
7 self.parse_yaml(yaml_path)
9 def parse_yaml(self, yaml_path):
10 with io.open(yaml_path) as yaml_file:
11 self.dha_struct = yaml.load(yaml_file)
13 def get_adapter_type(self):
14 return self.dha_struct['adapter']
16 def get_all_node_ids(self):
18 for node in self.dha_struct['nodes']:
19 node_ids.append(node['id'])
23 def get_fuel_node_id(self):
24 for node in self.dha_struct['nodes']:
25 if 'isFuel' in node and node['isFuel']:
28 def get_node_ids(self):
30 fuel_node_id = self.get_fuel_node_id()
31 for node in self.dha_struct['nodes']:
32 if node['id'] != fuel_node_id:
33 node_ids.append(node['id'])
37 def use_fuel_custom_install(self):
38 return self.dha_struct['fuelCustomInstall']
40 def get_node_property(self, node_id, property_name):
41 for node in self.dha_struct['nodes']:
42 if node['id'] == node_id and property_name in node:
43 return node[property_name]
45 def node_can_zero_mbr(self, node_id):
46 return self.get_node_property(node_id, 'nodeCanZeroMBR')
48 def get_fuel_access(self):
49 for node in self.dha_struct['nodes']:
50 if 'isFuel' in node and node['isFuel']:
51 return node['username'], node['password']