Now passing ansible sanity tests
This commit is contained in:
parent
76642d2703
commit
166e281700
|
|
@ -60,18 +60,21 @@ DOCUMENTATION = r"""
|
||||||
|
|
||||||
EXAMPLES = r"""
|
EXAMPLES = r"""
|
||||||
"""
|
"""
|
||||||
from ansible.errors import AnsibleError, AnsibleParserError
|
from ansible.errors import AnsibleError
|
||||||
|
# TODO: Re-enable if necessary
|
||||||
|
# , AnsibleParserError
|
||||||
from ansible.utils.display import Display
|
from ansible.utils.display import Display
|
||||||
from ansible.plugins.inventory import BaseInventoryPlugin, Constructable, Cacheable
|
from ansible.plugins.inventory import BaseInventoryPlugin, Constructable, Cacheable
|
||||||
|
|
||||||
# Specific for the NetbirdAPI Class
|
# Specific for the NetbirdAPI Class
|
||||||
import requests
|
import requests
|
||||||
import json
|
# import json
|
||||||
|
|
||||||
display = Display()
|
display = Display()
|
||||||
|
|
||||||
|
|
||||||
class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable):
|
class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable):
|
||||||
NAME="dominion_solutions.netbird"
|
NAME = "dominion_solutions.netbird"
|
||||||
|
|
||||||
def _build_client(self, loader):
|
def _build_client(self, loader):
|
||||||
"""Build the Netbird API Client"""
|
"""Build the Netbird API Client"""
|
||||||
|
|
@ -148,11 +151,13 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable):
|
||||||
peer.label,
|
peer.label,
|
||||||
strict=strict)
|
strict=strict)
|
||||||
|
|
||||||
### This is a very limited wrapper for the netbird API.
|
|
||||||
|
# This is a very limited wrapper for the netbird API.
|
||||||
class NetbirdApi:
|
class NetbirdApi:
|
||||||
def __init__ (self, api_key, api_url):
|
def __init__(self, api_key, api_url):
|
||||||
self.api_key = api_key
|
self.api_key = api_key
|
||||||
self.api_url = api_url
|
self.api_url = api_url
|
||||||
|
|
||||||
def ListPeers(self):
|
def ListPeers(self):
|
||||||
url = f"{self.api_url}/peers"
|
url = f"{self.api_url}/peers"
|
||||||
|
|
||||||
|
|
@ -163,6 +168,7 @@ class NetbirdApi:
|
||||||
response = requests.request("GET", url, headers=headers)
|
response = requests.request("GET", url, headers=headers)
|
||||||
return response.text
|
return response.text
|
||||||
|
|
||||||
|
|
||||||
class Peer:
|
class Peer:
|
||||||
def __init__(self, name, id, data):
|
def __init__(self, name, id, data):
|
||||||
self.name = name
|
self.name = name
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,9 @@ from __future__ import (absolute_import, division, print_function)
|
||||||
__metaclass__ = type
|
__metaclass__ = type
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
import sys
|
|
||||||
|
# TODO: Reenable this if needed.
|
||||||
|
# import sys
|
||||||
|
|
||||||
from ansible.errors import AnsibleError
|
from ansible.errors import AnsibleError
|
||||||
from ansible.parsing.dataloader import DataLoader
|
from ansible.parsing.dataloader import DataLoader
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue