3 class DeploymentEnvironmentAdapter(object):
10 def parse_yaml(self, yaml_path):
11 with open(yaml_path) as yaml_file:
12 self.dea_struct = yaml.load(yaml_file)
13 self.collect_shelf_and_blade_info()
15 def get_no_of_blades(self):
17 for shelf in self.dea_struct['shelf']:
18 no_of_blades += len(shelf['blade'])
21 def get_server_type(self):
22 return self.dea_struct['server_type']
24 def get_environment_name(self):
25 return self.dea_struct['name']
27 def get_shelf_ids(self):
30 def get_blade_ids(self, shelf_id):
31 return self.blade_ids[shelf_id]
33 def collect_shelf_and_blade_info(self):
37 for shelf in self.dea_struct['shelf']:
38 self.shelf_ids.append(shelf['id'])
39 blade_ids = self.blade_ids[shelf['id']] = []
40 blades = self.blades[shelf['id']] = {}
41 for blade in shelf['blade']:
42 blade_ids.append(blade['id'])
43 blades[blade['id']] = blade
45 def is_controller(self, shelf_id, blade_id):
46 blade = self.blades[shelf_id][blade_id]
47 return (True if 'role' in blade and blade['role'] == 'controller'
50 def is_compute_host(self, shelf_id, blade_id):
51 blade = self.blades[shelf_id][blade_id]
52 return True if 'role' not in blade else False