1 ###############################################################################
2 # Copyright (c) 2015 Ericsson AB and others.
3 # szilard.cserey@ericsson.com
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ###############################################################################
14 class HardwareAdapter(object):
16 def __init__(self, yaml_path):
17 self.dha_struct = None
18 self.parse_yaml(yaml_path)
20 def parse_yaml(self, yaml_path):
21 with io.open(yaml_path) as yaml_file:
22 self.dha_struct = yaml.load(yaml_file)
24 def get_adapter_type(self):
25 return self.dha_struct['adapter']
27 def get_all_node_ids(self):
29 for node in self.dha_struct['nodes']:
30 node_ids.append(node['id'])
34 def get_fuel_node_id(self):
35 for node in self.dha_struct['nodes']:
36 if 'isFuel' in node and node['isFuel']:
39 def get_node_ids(self):
41 fuel_node_id = self.get_fuel_node_id()
42 for node in self.dha_struct['nodes']:
43 if node['id'] != fuel_node_id:
44 node_ids.append(node['id'])
48 def get_node_property(self, node_id, property_name):
49 for node in self.dha_struct['nodes']:
50 if node['id'] == node_id and property_name in node:
51 return node[property_name]
53 def get_fuel_access(self):
54 for node in self.dha_struct['nodes']:
55 if 'isFuel' in node and node['isFuel']:
56 return node['username'], node['password']
59 return self.dha_struct['disks']