Beispiel #1
0
    def remove_service(self, res):
        """ Remove a Service.
        Arguments:
            id
        Return:
            message
        """
        assert res
        hippo_id = res['id'] if isinstance(res, HippoInstanceRequest) else res

        rtn_code, resp = self.request_delete(
            '/services/instances/{0}'.format(hippo_id))
        self.logger.debug('rtn_code: {}'.format(rtn_code))
        self.logger.debug('resp: {}'.format(resp))

        if rtn_code == 200:
            return True, HippoMsg.from_dict(resp)
        else:
            return False, HippoMsg.from_dict(resp)
Beispiel #2
0
    def get_sshkey(self):
        """ Get a Service Status.
        Return:
            HippoInstance
        """

        rtn_code, resp = self.request_get('/services/key')
        self.logger.debug('rtn_code: {}'.format(rtn_code))
        self.logger.debug('resp: {}'.format(resp))

        if rtn_code == 200:
            return True, KeyResponse.from_dict(resp)
        else:
            return False, HippoMsg.from_dict(resp)
Beispiel #3
0
    def get_cluster_status(self, res):
        """ Get Cluster Services Status.
        Return:
            HippoInstanceCollection
        """
        query_str = self.gen_status_querystr(res)

        rtn_code, resp = self.request_get('/services{}'.format(query_str))
        self.logger.debug('rtn_code: {}'.format(rtn_code))
        self.logger.debug('resp: {}'.format(resp))
        if rtn_code == 200:
            return True, [HippoNode.from_dict(node) for node in resp]
        else:
            return False, HippoMsg.from_dict(resp)
Beispiel #4
0
    def register_service(self, res):
        """ Register a Service.
        Arguments:
            clientIP
            serviceName
            path
        Return:
            id
        """
        assert res and isinstance(res, HippoInstanceRequest)
        rtn_code, resp = self.request_post('/services', data=res.to_simple())
        self.logger.debug('rtn_code: {}'.format(rtn_code))
        self.logger.debug('resp: {}'.format(resp))

        if rtn_code == 200 or rtn_code == 201:
            return True, RegisterResponse.from_dict(resp)
        else:
            return False, HippoMsg.from_dict(resp)
Beispiel #5
0
    def get_service_status(self, res):
        """ Get a Service Status.
        Arguments:
            id
        Return:
            HippoInstance
        """
        assert res
        hippo_id = res['id'] if isinstance(res, HippoInstanceRequest) else res
        rtn_code, resp = self.request_get(
            '/services/instances/{0}'.format(hippo_id))
        self.logger.debug('rtn_code: {}'.format(rtn_code))
        self.logger.debug('resp: {}'.format(resp))

        if rtn_code == 200:
            return True, HippoInstance.from_dict(resp)
        else:
            return False, HippoMsg.from_dict(resp)
Beispiel #6
0
 def stop_service(self, res):
     """ Stop a Service.
     Arguments:
         id
     Return:
         HippoInstance
     """
     assert res
     hippo_id = res['id'] if isinstance(res, HippoInstanceRequest) else res
     rtn_code, resp = self.request_post(
         '/services/instances/{0}/stop'.format(hippo_id),
         data=res.to_simple())
     self.logger.debug('rtn_code: {}'.format(rtn_code))
     self.logger.debug('resp: {}'.format(resp))
     if rtn_code == 200:
         return True, HippoInstance.from_dict(resp)
     else:
         return False, HippoMsg.from_dict(resp)