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 __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)
Ejemplo n.º 3
0
    def oauth(self):
        """
        MAAS OAuth information for interacting with the MAAS API.

        :rtype: MAASOAuth
        """
        if self._oauth:
            return self._oauth

        if self.api_key:
            api_key = self.api_key.split(':')
            self._oauth = maas.MAASOAuth(consumer_key=api_key[0],
                                         resource_token=api_key[1],
                                         resource_secret=api_key[2])
            return self._oauth
        else:
            return None
Ejemplo n.º 4
0
 def sign(uri, headers, credentials):
     """Sign the URI and headers."""
     center('RestClient.sign')
     auth = maas.MAASOAuth(*credentials)
     auth.sign_request(uri, headers)
     cleave('RestClient.sign')