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 9 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
56 changes: 36 additions & 20 deletions doc/source/getting_started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ Basic Usage
Before using Spyglass you must:


1. Clone the Tugboat repository:
1. Clone the Spyglass repository:

.. code-block:: console

git clone https://github.com/att-comdev/tugboat/tree/spyglass

2. Install the required packages in spyglass/:
2. Install the required packages in spyglass:

.. code-block:: console

Expand All @@ -87,24 +87,40 @@ CLI Options
Usage: spyglass [OPTIONS]

Options:
-s, --site TEXT Specify the site for which manifests to be
generated
-t, --type TEXT Specify the plugin type formation or tugboat
-f, --formation_url TEXT Specify the formation url
-u, --formation_user TEXT Specify the formation user id
-p, --formation_password TEXT Specify the formation user password
-d, --additional_config PATH Site specific configuraton details
-g, --generate_intermediary Dump intermediary file from passed excel and
excel spec
-m, --generate_manifests Generate manifests from the generated
intermediary file
-l, --loglevel INTEGER Loglevel NOTSET:0 ,DEBUG:10, INFO:20,
WARNING:30, ERROR:40, CRITICAL:50 [default:
20]
--help Show this message and exit.


1. Running Spyglass with Remote Data Source
-s, --site TEXT Specify the site for which manifests to be
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we create plugin as the sub command to spyglass, this will cleanup this help to an extent.

e.g.: spyglass [options] plugin_name [ options]
spyglass --loglevel 10 tugboat ...

generated
-t, --type TEXT Specify the plugin type formation or tugboat
-f, --formation_url TEXT Specify the formation url
-u, --formation_user TEXT Specify the formation user id
-p, --formation_password TEXT Specify the formation user password
-i, --intermediary PATH Intermediary file path generate manifests,
use -m also with this option
-d, --additional_config PATH Site specific configuraton details
-g, --generate_intermediary Dump intermediary file from passed excel and
excel spec
-idir, --intermediary_dir PATH The path where intermediary file needs to be
generated
-e, --edit_intermediary / -nedit, --no_edit_intermediary
Flag to let user edit intermediary
-m, --generate_manifests Generate manifests from the generated
intermediary file
-mdir, --manifest_dir PATH The path where manifest files needs to be
generated
-x, --excel PATH Path to engineering excel file, to be passed
with generate_intermediary
-e, --excel_spec PATH Path to excel spec, to be passed with
generate_intermediary
-l, --loglevel INTEGER Loglevel NOTSET:0 ,DEBUG:10, INFO:20,
WARNING:30, ERROR:40, CRITICAL:50 [default:
20]
--help Show this message and exit.


1. Running Spyglass with Remote Data Source Plugin

spyglass -mg --type formation -f <URL> -u <user_id> -p <password> -d <site_config> -s <sitetype>

2. Running Spyglass with Excel Plugin

spyglass -mg --type tugboat -x <Excel File> -e <Excel Spec> -d <Site Config> -s <Region>

2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
],
'data_extractor_plugins':
['formation=spyglass.data_extractor.formation:FormationPlugin',
'tugboat=spyglass.data_extractor.tugboat:TugboatPlugin',
'tugboat=spyglass.data_extractor.tugboat.tugboat:TugboatPlugin',
]
},
include_package_data=True,
Expand Down
44 changes: 13 additions & 31 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 Expand Up @@ -414,12 +396,11 @@ def extract_network_information(self):
'calico', 'overlay', 'pxe', 'storage', 'oam', 'oob', 'ingress'
]
network_data['vlan_network_data'] = {}

for net in networks:
tmp_net = {}
if net['name'] in networks_to_scan:
tmp_net['subnet'] = net['subnet']
tmp_net['vlan'] = net['vlan']
tmp_net['subnet'] = net.get('subnet', '')
tmp_net['vlan'] = net.get('vlan', '')

network_data['vlan_network_data'][net['name']] = tmp_net

Expand All @@ -436,9 +417,10 @@ def extract_data(self):
LOG.info("Extract data from plugin")
site_data = {}
site_data['baremetal'] = self.extract_baremetal_information()
site_data['site_info'] = self.extract_site_information()
site_data['network'] = self.extract_network_information()
site_data['site_info'] = self.extract_site_information()
self.site_data = site_data

return site_data

def apply_additional_data(self, extra_data):
Expand All @@ -450,7 +432,7 @@ def apply_additional_data(self, extra_data):
If there is repetition of data then additional data supplied
shall take precedence.
"""
LOG.info("Update site data with additional input")
LOG.info("Merging site data with additional configuration")
tmp_site_data = utils.dict_merge(self.site_data, extra_data)
self.site_data = tmp_site_data
return self.site_data
Loading