Ejemplo n.º 1
0
    def __init__(self, api_key, maas_url):

        # store values
        self.api_key = api_key
        self.maas_url = maas_url
        self.oauth = maas_client.MAASOAuth(*APIKEY.split(":"))

        # create client for this class
        self.client = MAASClientOverride(self.oauth,
                                         maas_client.MAASDispatcher(),
                                         self.maas_url)
Ejemplo n.º 2
0
    def client(self):
        """
        MAAS client

        :rtype: MAASClient
        """
        if self._client:
            return self._client

        self._client = maas.MAASClient(auth=self.oauth,
                                       dispatcher=maas.MAASDispatcher(),
                                       base_url=self.api_url)
        return self._client
Ejemplo n.º 3
0
 def __init__(self):
     '''
         Initialize the connection and return a client (cursor?) ...
     '''
     try:
         config = configparser.ConfigParser()
         config.read(CONFIGFILE)
         apikey = config['maas']['apikey']
         maas_url = config['maas']['url']
         auth = maas_client.MAASOAuth(*apikey.split(":"))
         self.client = maas_client.MAASClient(auth,
                                              maas_client.MAASDispatcher(),
                                              maas_url)
     except Exception as e:
         print(str(e))
         sys.exit(1)