Coder Social home page Coder Social logo

ansible-maas-dynamic-inventory's People

Contributors

fsschmitt avatar mlimaloureiro avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

ansible-maas-dynamic-inventory's Issues

ModuleNotFoundError: No module named 'oauth2'

lsb_release -a
LSB Version: core-9.20170808ubuntu1-noarch:printing-9.20170808ubuntu1-noarch:security-9.20170808ubuntu1-noarch
Distributor ID: Ubuntu
Description: Ubuntu 18.04.3 LTS
Release: 18.04
Codename: bionic

When executing:
python3 maas.py --list

The following error is returned:

python3 maas.py --list
Traceback (most recent call last):
File "maas.py", line 11, in
import oauth2 as oauth
ModuleNotFoundError: No module named 'oauth2'

It seems there is no candidate for python-oauth2

sudo apt-cache search python-oauth2
python-oauth2client - OAuth 2.0 client library - Python 2.7

sudo apt-cache search python3-oauth2
python3-oauth2client - OAuth 2.0 client library - Python 3.x

There are candidates for:

sudo apt-cache search python-oauth
python-oauth - Python library implementing of the OAuth protocol
python-oauthlib - generic, spec-compliant implementation of OAuth for Python
python3-oauth - Python 3 library implementing of the OAuth protocol
python-oauth2client - OAuth 2.0 client library - Python 2.7

Installed both candidates but the result remains the same.

sudo apt-cache policy python-oauth
python-oauth:
Installed: 1.0.1-5
Candidate: 1.0.1-5
Version table:
*** 1.0.1-5 500
500 http://us.archive.ubuntu.com/ubuntu bionic/main amd64 Packages
500 http://us.archive.ubuntu.com/ubuntu bionic/main i386 Packages
100 /var/lib/dpkg/status

sudo apt-cache policy python3-oauth
python3-oauth:
Installed: 1.0.1-5
Candidate: 1.0.1-5
Version table:
*** 1.0.1-5 500
500 http://us.archive.ubuntu.com/ubuntu bionic/main amd64 Packages
500 http://us.archive.ubuntu.com/ubuntu bionic/main i386 Packages
100 /var/lib/dpkg/status

E: Unable to locate package python3-requests_cache

lsb_release -a
LSB Version: core-9.20170808ubuntu1-noarch:printing-9.20170808ubuntu1-noarch:security-9.20170808ubuntu1-noarch
Distributor ID: Ubuntu
Description: Ubuntu 18.04.3 LTS
Release: 18.04
Codename: bionic

There is no candidate for python3-requests_cache

sudo apt-cache policy python3-requests_cache
N: Unable to locate package python3-requests_cache

There is a candidate for python3-requests-cache

sudo apt-cache policy python3-requests-cache
python3-requests-cache:
Installed: 0.4.13-1
Candidate: 0.4.13-1
Version table:
*** 0.4.13-1 500
500 http://us.archive.ubuntu.com/ubuntu bionic/universe amd64 Packages
500 http://us.archive.ubuntu.com/ubuntu bionic/universe i386 Packages
100 /var/lib/dpkg/status

line 32 def __init__(self, maas_api_url: str, maas_api_key: str)

when run using: python3 maas.py --list
The script returns correct dynamic inventory JSON from MAAS.

When run using: ansible all -i maas.py -m ping
The script returns:

ansible all -i maas.py -m ping
[WARNING]: * Failed to parse /home/netadmin/ansible-tst/maas.py with script plugin: Inventory script
(/home/netadmin/ansible-tst/maas.py) had an execution error: File "/home/netadmin/ansible-tst/maas.py",
line 32 def init(self, maas_api_url: str, maas_api_key: str): ^
SyntaxError: invalid syntax

[WARNING]: Unable to parse /home/netadmin/ansible-tst/maas.py as an inventory source

[WARNING]: No inventory was parsed, only implicit localhost is available

[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does
not match 'all'

When run using: ansible apache-1 -i maas.py -m ping
[WARNING]: * Failed to parse /home/netadmin/ansible-tst/maas.py with script plugin: Inventory script
(/home/netadmin/ansible-tst/maas.py) had an execution error: File "/home/netadmin/ansible-tst/maas.py",
line 32 def init(self, maas_api_url: str, maas_api_key: str): ^
SyntaxError: invalid syntax

[WARNING]: Unable to parse /home/netadmin/ansible-tst/maas.py as an inventory source

[WARNING]: No inventory was parsed, only implicit localhost is available

[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does
not match 'all'

[WARNING]: Could not match supplied host pattern, ignoring: apache-1

Test Fetcher class

The code has 3 main classes:

  • Authentication creates http headers to make signed requests
  • Fetcher is a class that fetches information from MAAS API but also has some logic in fetch_machines_grouped_by_tags method to group the machines by tag
  • InventoryBuilder uses data from Fetcher and structure the data to match ansible inventories

Currently we're just testing the InventoryBuilder class but since Fetcher also has some logic and it's not only fetching we should test it.

Please create some tests to this class, specially, fetch_machines_grouped_by_tags method

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.