def __init__(self, sslenabled, authenticator): """ Setup the CloudFiles API Class in the same manner as rcbu.common.Command """ Command.__init__(self, sslenabled, 'localhost', '/') # save the ssl status for the various reinits done for each API call supported self.sslenabled = sslenabled self.authenticator = authenticator self.auth = authenticator self.log = logging.getLogger(__name__)
def __init__(self, username, apikey): """ Initialize the Agent access sslenabled - True if using HTTPS; otherwise False authenticator - instance of rcbu.client.auth.Authentication to use apihost - server to use for API calls username - user for the authentication apikey - apikey/password for the given user """ Command.__init__(self, True, "identity.api.rackspacecloud.com", "/v2.0/tokens") self.log = logging.getLogger(__name__) self.o = {} self.o["auth"] = {} self.o["auth"]["RAX-KSKEY:apiKeyCredentials"] = {} self.o["auth"]["RAX-KSKEY:apiKeyCredentials"]["username"] = username self.o["auth"]["RAX-KSKEY:apiKeyCredentials"]["apiKey"] = apikey self.body = json.dumps(self.o) self.auth_data = {}