예제 #1
0
    def list_silences(self, cloud_id):
        """List all silencers belong to a cloud.

        :param cloud_id: The id of cloud.
        """
        url = utils.generate_url('/silences', cloud_id)
        return self.get(url, headers=self.headers).json()
예제 #2
0
    def unregister_cloud(self, id):
        """Remove a cloud from Faythe

        :param id: The id of cloud.
        """
        url = utils.generate_url('/clouds', id)
        return self.delete(url.format(id), headers=self.headers).json()
예제 #3
0
    def delete_silence(self, cloud_id):
        """Delete a healer belong to a cloud.

        :param cloud_id: The id of cloud.
        """
        url = utils.generate_url('/silences', cloud_id)
        return self.delete(url, headers=self.headers).json()
예제 #4
0
    def delete_user(self, username):
        """Delete an existing user.

        :param username: The name of user.
        """
        url = utils.generate_url('/users', username)
        return self.delete(url, headers=self.headers).json()
예제 #5
0
    def delete_healers(self, cloud_id):
        """Delete a healer.

        :param cloud_id: The id of cloud.
        """
        url = utils.generate_url('/healers', cloud_id)
        return self.delete(url.format(cloud_id), headers=self.headers).json()
예제 #6
0
    def remove_policies(self, username, body):
        """Remove a set of policies.

        :param username: The name of user.
        :param body: A list of dictionary object.
        """
        url = utils.generate_url('/policies', username)
        return self.delete(url, headers=self.headers, body=body).json()
예제 #7
0
    def create_user(self, user):
        """Create new Faythe user.

        :param user: A dict of user information.
                     for example: {'username': '******', 'password': '******'}
        """
        url = utils.generate_url('/users')
        return self.post(url, headers=self.headers, data=user).json()
예제 #8
0
    def create_silence(self, cloud_id, body):
        """Create a silencer to ignore healing action.

        :param cloud_id: The id of cloud.
        :param body: A dictionary object.
        """
        url = utils.generate_url('/silences', cloud_id)
        return self.post(url, body=body, headers=self.headers).json()
예제 #9
0
    def create_healer(self, cloud_id, body):
        """Create a new healer belongs to a cloud.

        :param cloud_id: The id of cloud.
        :param body: A dictionary object.
        """
        url = utils.generate_url('/healers', cloud_id)
        return self.post(url, body=body, headers=self.headers).json()
예제 #10
0
    def register_cloud(self, provider, body):
        """Register a new cloud to Faythe

        :param provider: The cloud provider type. 'OpenStack' is the only
                         provider supported by now.
        :param body: A dictionary object.
        """
        url = utils.generate_url('/clouds', provider)
        return self.post(url, body=body, headers=self.headers).json()
예제 #11
0
    def update_cloud(self, id, body=None):
        """Update a cloud information

        :param id: The id of cloud.
        :param body: (optional) A dictionary object. If it
                     is None, the cloud won't be updated.
        """
        url = utils.generate_url('/clouds', id)
        return self.put(url, body=body, headers=self.headers).json()
예제 #12
0
    def update_scaler(self, cloud_id, body=None):
        """Update a scaler information.

        :param cloud_id: The id of cloud.
        :param body: (optional) A dictionary object. If it
                     is None, the scaler won't be updated.
        """
        url = utils.generate_url('/scalers', cloud_id)
        return self.put(url, body=body, headers=self.headers).json()
예제 #13
0
    def change_password(self, username, newpassword):
        """Change user's password.

        :param username: The name of user.
        :param newpassword: The new password.
        """
        url = utils.generate_url('/users', username, 'change_password')
        return self.put(url,
                        headers=self.headers,
                        data={'newpassword': newpassword})
예제 #14
0
    def list_scalers(self, cloud_id, **kwargs):
        """List all scalers belong to a cloud.

        :param cloud_id: The id of cloud.
        :param tags: (optional) A list of tags to filter the scaler list by.
                     Scalers that match all tags in this list will be returned.
        :param tags_any: (optional) A list of tags to filter the scaler list by.
                         Scalers that match any tags in this list will be returned.
        """
        url = utils.generate_url('/scalers', cloud_id, **kwargs)
        return self.get(url, headers=self.headers).json()
예제 #15
0
    def list_clouds(self, **kwargs):
        """List all clouds that are registerd to Faythe

        :param provider: (optional) Filter a cloud result by provider.
                         The only supported provider is OpenStack so
                         this one is useless right now.
        :param id: (optional) Filter cloud result by id.
        :param tags: (optional) A list of tags to filter the cloud list by.
                     Clouds that match all tags in this list will be returned.
        :param tags_any: (optional) A list of tags to filter the cloud list by.
                         Clouds that match any tags in this list will be returned.
        """
        url = utils.generate_url('/clouds', **kwargs)
        return self.get(url, headers=self.headers).json()
예제 #16
0
 def list_users(self):
     """List all Faythe users with policies."""
     url = utils.generate_url('/users')
     return self.get(url, headers=self.headers).json()
예제 #17
0
 def delete_scaler(self, cloud_id):
     """Delete a scaler."""
     url = utils.generate_url('/scalers', cloud_id)
     return self.delete(url, headers=self.headers).json()