Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added availability flags and logic for genesis setting #77

Open
wants to merge 19 commits into
base: spyglass
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 8 additions & 26 deletions spyglass/data_extractor/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,6 @@ def extract_baremetal_information(self):
"""
LOG.info("Extract baremetal information from plugin")
baremetal = {}
is_genesis = False
hosts = self.get_hosts(self.region)

# For each host list fill host profile and network IPs
Expand All @@ -301,40 +300,23 @@ def extract_baremetal_information(self):

# Fill network IP for this host
temp_host['ip'] = {}
temp_host['ip']['oob'] = temp_host_ips[host_name].get('oob', "")
temp_host['ip']['oob'] = temp_host_ips[host_name].get(
'oob', "#CHANGE_ME")
temp_host['ip']['calico'] = temp_host_ips[host_name].get(
'calico', "")
temp_host['ip']['oam'] = temp_host_ips[host_name].get('oam', "")
'calico', "#CHANGE_ME")
temp_host['ip']['oam'] = temp_host_ips[host_name].get(
'oam', "#CHANGE_ME")
temp_host['ip']['storage'] = temp_host_ips[host_name].get(
'storage', "")
'storage', "#CHANGE_ME")
temp_host['ip']['overlay'] = temp_host_ips[host_name].get(
'overlay', "")
# TODO(pg710r): Testing only.
'overlay', "#CHANGE_ME")
temp_host['ip']['pxe'] = temp_host_ips[host_name].get(
'pxe', "#CHANGE_ME")

# TODO(nh863p): Can this logic goes into dervied plugin class
# How to determine genesis node??

# TODO(nh863p): If below logic is based on host profile name, then
# it should be part of design rule???
# Filling rack_type( compute/controller/genesis)
# "cp" host profile is controller
# "ns" host profile is compute
if (temp_host['host_profile'] == 'cp'):
# The controller node is designates as genesis"
if is_genesis is False:
is_genesis = True
temp_host['type'] = 'genesis'
else:
temp_host['type'] = 'controller'
else:
temp_host['type'] = 'compute'
temp_host['type'] = host.get('type', "#CHANGE_ME")

baremetal[rack_name][host_name] = temp_host
LOG.debug("Baremetal information:\n{}".format(
pprint.pformat(baremetal)))

return baremetal

def extract_site_information(self):
Expand Down
22 changes: 11 additions & 11 deletions spyglass/data_extractor/formation.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,13 +313,19 @@ def get_hosts(self, region, rack=None):
control_hosts = device_api.zones_zone_id_control_nodes_get(zone_id)
compute_hosts = device_api.zones_zone_id_devices_get(
zone_id, type='KVM')

hosts_list = []
genesis_set = False
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it a design rule to take first node as genesis or hardcoded?

Instead of introducing new flag, why cant the first element is taken out of control_host, handle genesis stuff. And then for loop from [1:]

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left it for readability sake we can loop fron [1: ] also

for host in control_hosts:
self.device_name_id_mapping[host.aic_standard_name] = host.id
# The first control node is designated as genesis node
if genesis_set is False:
node_type = 'genesis'
genesis_set = True
else:
node_type = 'genesis'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

node_type should be genesis in else loop?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has been fixed. It should be controller

hosts_list.append({
'name': host.aic_standard_name,
'type': 'controller',
'type': node_type,
'rack_name': host.rack_name,
'host_profile': host.host_profile_name
})
Expand Down Expand Up @@ -352,8 +358,9 @@ def get_networks(self, region):
vlan_api = swagger_client.VlansApi(self.formation_api_client)
vlans = vlan_api.zones_zone_id_regions_region_id_vlans_get(
zone_id, region_id)
# Case when vlans list is empty from
# zones_zone_id_regions_region_id_vlans_get
# TWEAK(pg710r):Case when vlans list is empty from
# zones_zone_id_regions_region_id_vlans_get. Ideally this should not
# be the case
if len(vlans) is 0:
# get device-id from the first host and get the network details
hosts = self.get_hosts(self.region)
Expand All @@ -375,13 +382,6 @@ def get_networks(self, region):
tmp_vlan['subnet_level'] = vlan_.vlan.subnet_level
vlans_list.append(tmp_vlan)

# TODO(pg710r): hack to put dummy values for pxe
tmp_vlan = {}
tmp_vlan['name'] = 'pxe'
tmp_vlan['vlan'] = '43'
tmp_vlan['subnet'] = '172.30.4.0/25'
tmp_vlan['gateway'] = '172.30.4.1'
vlans_list.append(tmp_vlan)
return vlans_list

def get_ips(self, region, host=None):
Expand Down
2 changes: 1 addition & 1 deletion spyglass/parser/generate_intermediary.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,6 @@ def load_extracted_data_from_data_source(self, extracted_data):
"""

LOG.info("Load extracted data from data source")
self._validate_extracted_data(extracted_data)
self.data = extracted_data
LOG.debug("Extracted data from plugin data source:\n{}".format(
pprint.pformat(extracted_data)))
Expand All @@ -266,6 +265,7 @@ def load_extracted_data_from_data_source(self, extracted_data):
with open(extracted_file, 'w') as f:
f.write(yaml_file)
f.close()
self._validate_extracted_data(extracted_data)
# Append region_data supplied from CLI to self.data
self.data['region_name'] = self.region_name

Expand Down