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 get_node_property(self, node_id, property_name):
38 for node in self.dha_struct['nodes']:
39 if node['id'] == node_id and property_name in node:
40 return node[property_name]
42 def get_fuel_access(self):
43 for node in self.dha_struct['nodes']:
44 if 'isFuel' in node and node['isFuel']:
45 return node['username'], node['password']
48 return self.dha_struct['disks']