quipucords / camayoc

Test automation framework that facilitates functional testing of quipucords.
https://camayoc.readthedocs.io/
GNU General Public License v3.0
5 stars 4 forks source link

Add camayoc.inventory module - host based inventory #337

Closed ruda closed 4 years ago

ruda commented 4 years ago

This module allows one to query the host based inventory, like this:

>>> from camayoc import config 
>>> from camayoc import inventory
>>> cfg = config.get_config()
>>> cfg['yupana']['inventory']
{'api_url': 'https://ci.example.com/api/inventory/v1/',
 'rh_username': 'test',
 'rh_password': 'example',
 'rh_account_number': '000001',
 'rh_org_id': '0000001'}
>>> cfg_inv  = cfg['yupana']['inventory']

Then we can get the whole host inventory as a list:

>>> auth = (cfg_inv['rh_username'], cfg_Inv['rh_password'])
>>> url = cfg_inv['api_url']
>>> inventory.get_hosts(url=url, auth=auth)

If something is wrong, then an exception of kind RuntimeError() will be raised. There is also a function to query for a list of host ids, use inventory.find_hosts for that. There is also support for passing account number and org id in these functions.

>>> from camayoc import utils
>>> x_rh_id = utils.create_indentity(cfg_inv['account_number])
>>> x_rh_id = utils.create_indentity(cfg_inv['account_number], cfg_inv['org_id'])
>>> inventory.get_hosts(url=url, auth=auth, x_rh_identity=x_rh_id)

This PR closes #332

codecov[bot] commented 4 years ago

Codecov Report

Merging #337 into master will decrease coverage by 3.45%. The diff coverage is 28.57%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #337      +/-   ##
==========================================
- Coverage   82.35%   78.89%   -3.46%     
==========================================
  Files           5        5              
  Lines         204      218      +14     
==========================================
+ Hits          168      172       +4     
- Misses         36       46      +10
Impacted Files Coverage Δ
camayoc/utils.py 80% <28.57%> (-15.66%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update f70af4e...63c7ce0. Read the comment docs.