Ejemplo n.º 1
0
    def setUp(self):
        self.token_file_contents = '123TOKEN'
        self.response = MagicMock()
        self.session_get = 'ecsminion.util.token_request.requests.Session.get'

        self.token_request = TokenRequest(username='******',
                                          password='******',
                                          ecs_endpoint='https://localhost',
                                          token_endpoint='https://localhost',
                                          verify_ssl=False,
                                          token_filename='ecstoken.tkn',
                                          token_location='/tmp',
                                          request_timeout=5.0,
                                          cache_token=True)
Ejemplo n.º 2
0
    def __init__(self,
                 username=None,
                 password=None,
                 token=None,
                 ecs_endpoint=None,
                 token_endpoint=None,
                 verify_ssl=False,
                 token_filename='ecsminion.tkn',
                 token_location='/tmp',
                 request_timeout=15.0,
                 cache_token=True):
        """
        Creates the ECSMinion class that the client will directly work with

        :param username: The username to fetch a token
        :param password: The password to fetch a token
        :param token: Supply a valid token to use instead of username/password
        :param ecs_endpoint: The URL where ECS is located
        :param token_endpoint: The URL where the ECS login is located
        :param verify_ssl: Verify SSL certificates
        :param token_filename: The name of the cached token filename
        :param token_location: By default this is stored in /tmp
        :param request_timeout: How long to wait for ECS to respond
        :param cache_token: Whether to cache the token, by default this is true
        you should only switch this to false when you want to directly fetch
        a token for a user
        """

        self.username = username
        self.password = password
        self.token = token
        self.ecs_endpoint = ecs_endpoint.rstrip('/')
        self.token_endpoint = token_endpoint.rstrip('/')
        self.verify_ssl = verify_ssl
        self.token_filename = token_filename
        self.token_location = token_location
        self.request_timeout = request_timeout
        self.cache_token = cache_token
        self._session = requests.Session()
        self._token_request = TokenRequest(
            username=self.username,
            password=self.password,
            ecs_endpoint=self.ecs_endpoint,
            token_endpoint=self.token_endpoint,
            verify_ssl=self.verify_ssl,
            token_filename=self.token_filename,
            token_location=self.token_location,
            request_timeout=self.request_timeout,
            cache_token=self.cache_token)
        self.token_file = os.path.join(self.token_location,
                                       self.token_filename)

        # API -> Authentication
        self.authentication = Authentication(self)

        # API -> Billing
        self.billing = Billing(self)

        # API -> Configuration
        self.certificate = Certificate(self)
        self.configuration_properties = ConfigurationProperties(self)
        self.licensing = Licensing(self)

        # API -> Geo Replication
        self.replication_group = ReplicationGroup(self)
        self.temp_failed_zone = TemporaryFailedZone(self)

        # API -> Monitoring
        self.capacity = Capacity(self)
        self.dashboard = Dashboard(self)
        self.events = Events(self)

        # API -> Monitoring
        self.namespace = Namespace(self)

        # API -> Provisioning
        self.base_url = BaseUrl(self)
        self.bucket = Bucket(self)
        self.data_store = DataStore(self)
        self.node = Node(self)
        self.storage_pool = StoragePool(self)
        self.virtual_data_center = VirtualDataCenter(self)

        # API -> Support
        self.call_home = CallHome(self)

        # API -> User Management
        self.authentication_provider = AuthenticationProvider(self)
        self.secret_key = SecretKey(self)
        self.secret_key_self_service = SecretKeySelfService(self)
        self.management_object = ManagementUser(self)
        self.user_object = ObjectUser(self)

        # API -> Undocumented
        self.user_info = UserInfo(self)