コード例 #1
0
ファイル: func.py プロジェクト: fagan2888/web_server_pecan
 def __init__(self, project_id, fn_urn, action, node_id):
     self.project_id = project_id
     super(FunctionMgrActionController, self).__init__()
     self.func_mgr = FunctionClient()
     self.fn_urn = fn_urn
     self.action = action
     self.node_id = node_id
コード例 #2
0
ファイル: func.py プロジェクト: fagan2888/web_server_pecan
class FunctionMgrRuntimeController(base.BaseController):
    def __init__(self, project_id):
        self.project_id = project_id
        super(FunctionMgrRuntimeController, self).__init__()
        self.func_mgr = FunctionClient()

    def post(self, lib_body):
        pass

    @pecan.expose(funcmgr_types.RuntimeMgrResponse)
    @return_api_resp(to_type=funcmgr_types.RuntimeMgrResponse)
    def get_one(self, *args):
        """Gets a single runtime details."""
        if len(args) == 2:
            language = args[0]
            version = args[1]
            return self.func_mgr.get_runtime(self.project_id, language,
                                             version)

    def put(self, id, body):
        pass

    @wsme_pecan.wsexpose([funcmgr_types.RuntimeMgrResponse])
    @return_api_resp(to_type=funcmgr_types.RuntimeMgrResponse)
    def get_all(self):
        """Gets all libraries details."""

        return self.func_mgr.list_runtimes(self.project_id)

    def delete(self, id):
        pass
コード例 #3
0
ファイル: func.py プロジェクト: fagan2888/web_server_pecan
class FunctionMgrController(base.BaseController):
    def __init__(self, project_id):
        self.project_id = project_id
        super(FunctionMgrController, self).__init__()
        self.func_mgr = FunctionClient()

    @wsme_pecan.wsexpose(funcmgr_types.FunctionMgrResponse,
                         wtypes.text,
                         body=funcmgr_types.FunctionMgrPost,
                         status_code=200)
    @return_api_resp(to_type=funcmgr_types.FunctionMgrResponse)
    def post(self, id, function_body):

        return self.func_mgr.create_function(self.project_id, id,
                                             function_body)

    @wsme_pecan.wsexpose(funcmgr_types.FunctionMgrResponse, wtypes.text)
    @return_api_resp(to_type=funcmgr_types.FunctionMgrResponse)
    def get_one(self, id):
        """Gets a single function details."""

        return self.func_mgr.get_function(self.project_id, id)

    @wsme_pecan.wsexpose([funcmgr_types.FunctionMgrResponse])
    @return_api_resp(to_type=funcmgr_types.FunctionMgrResponse)
    def get_all(self):
        """Gets all function details."""

        return self.func_mgr.list_functions(self.project_id)

    @wsme_pecan.wsexpose(None, wtypes.text, status_code=204)
    def delete(self, id):

        LOG.debug("Delete a function: %s", id)
        self.func_mgr.delete_function(self.project_id, id)

    @pecan.expose()
    def _lookup(self, fn_id, *remainder):
        if fn_id and len(remainder) and remainder[0] == 'force':
            return FunctionMgrForceController(project_id=self.project_id), ''

        if fn_id and len(remainder) and remainder[0] == 'libraries':
            return FunctionLibraryController(project_id=self.project_id,
                                             fn_urn=fn_id), ''
コード例 #4
0
ファイル: func.py プロジェクト: fagan2888/web_server_pecan
class FunctionMgrForceController(FunctionMgrController):
    def __init__(self, project_id):
        self.project_id = project_id
        super(FunctionMgrForceController, self).__init__(project_id)
        self.func_mgr = FunctionClient()

    @wsme_pecan.wsexpose(None, wtypes.text, status_code=204)
    def delete(self, id):
        LOG.debug("Force delete a function: %s", id)
        return self.func_mgr.delete_function_force(self.project_id, id)
コード例 #5
0
ファイル: func.py プロジェクト: fagan2888/web_server_pecan
class FunctionNodeController(base.BaseController):
    def __init__(self, project_id, node_id, fn_urn=None):
        super(FunctionNodeController, self).__init__()
        self.project_id = project_id
        self.node_id = node_id
        self.func_mgr = FunctionClient()
        self.fn_urn = fn_urn

    @wsme_pecan.wsexpose([funcmgr_types.FunctionMgrResponse])
    @return_api_resp(to_type=funcmgr_types.FunctionMgrResponse)
    def get_all(self):
        """list functions in node details."""

        return self.func_mgr.list_fn_in_node(project_id=self.project_id,
                                             node_id=self.node_id)

    @wsme_pecan.wsexpose(funcmgr_types.FunctionActionResponce, status_code=200)
    @return_api_resp(to_type=funcmgr_types.FunctionActionResponce)
    def post(self):
        id = self.fn_urn

        self.func_mgr.assign_function_to_node(self.project_id, id,
                                              self.node_id)
        return json.dumps({
            "action": "assign function in node",
            "node_id": self.node_id,
            "function_urn": self.fn_urn,
            "result": "success"
        })

    @wsme_pecan.wsexpose(None, status_code=204)
    @return_api_resp(to_type=funcmgr_types.FunctionActionResponce)
    def delete(self):
        id = self.fn_urn

        self.func_mgr.delete_fn_from_node(self.project_id, id, self.node_id)
        return json.dumps({
            "action": "delete function in node",
            "node_id": self.node_id,
            "function_urn": self.fn_urn,
            "result": "success"
        })
コード例 #6
0
ファイル: func.py プロジェクト: fagan2888/web_server_pecan
class FunctionMgrLibraryController(base.BaseController):
    def __init__(self, project_id):
        self.project_id = project_id
        super(FunctionMgrLibraryController, self).__init__()
        self.func_mgr = FunctionClient()

    @wsme_pecan.wsexpose(wtypes.text,
                         wtypes.text,
                         body=funcmgr_types.LibraryMgrRootPost,
                         status_code=200)
    @return_api_resp(to_type=funcmgr_types.LibraryMgrResponse)
    def post(self, lib_body):
        return self.func_mgr.create_library(self.project_id, lib_body)

    @wsme_pecan.wsexpose(funcmgr_types.LibraryMgrResponse, wtypes.text)
    @return_api_resp(to_type=funcmgr_types.LibraryMgrResponse)
    def get_one(self, id):
        """Gets a single library details."""

        return self.func_mgr.get_library(self.project_id, id)

    @wsme_pecan.wsexpose(funcmgr_types.LibraryMgrResponse,
                         wtypes.text,
                         body=funcmgr_types.LibraryMgrRootPost,
                         status_code=200)
    @return_api_resp(to_type=funcmgr_types.LibraryMgrResponse)
    def put(self, id, body):
        """Put a single library details."""

        return self.func_mgr.update_library(self.project_id, id, body)

    @wsme_pecan.wsexpose([funcmgr_types.LibraryMgrResponse])
    @return_api_resp(to_type=funcmgr_types.LibraryMgrResponse)
    def get_all(self):
        """Gets all libraries details."""

        return self.func_mgr.list_libraries(self.project_id)

    @wsme_pecan.wsexpose(None, wtypes.text, status_code=204)
    def delete(self, id):
        LOG.debug("Delete a library: %s", id)
        return self.func_mgr.delete_library(self.project_id, id)
コード例 #7
0
ファイル: func.py プロジェクト: fagan2888/web_server_pecan
class FunctionDeployController(base.BaseController):
    def __init__(self, project_id, node_id):
        super(FunctionDeployController, self).__init__()
        self.project_id = project_id
        self.node_id = node_id
        self.func_mgr = FunctionClient()

    @wsme_pecan.wsexpose(funcmgr_types.DeployStatusResponse, status_code=200)
    @return_api_resp(to_type=funcmgr_types.DeployStatusResponse)
    def post(self):
        return self.func_mgr.deploy_single_node(self.project_id, self.node_id)
コード例 #8
0
ファイル: func.py プロジェクト: fagan2888/web_server_pecan
class FunctionMgrActionController(base.BaseController):
    def __init__(self, project_id, fn_urn, action, node_id):
        self.project_id = project_id
        super(FunctionMgrActionController, self).__init__()
        self.func_mgr = FunctionClient()
        self.fn_urn = fn_urn
        self.action = action
        self.node_id = node_id

    @wsme_pecan.wsexpose(funcmgr_types.FunctionActionResponce, status_code=200)
    @return_api_resp()
    def post(self):
        self.func_mgr.function_action(project_id=self.project_id,
                                      node_id=self.node_id,
                                      fn_urn=self.fn_urn,
                                      action=self.action)
        result = funcmgr_types.FunctionActionResponce(result="success")
        result.node_id = self.node_id
        result.action = self.action
        result.function_urn = self.fn_urn
        return result
コード例 #9
0
ファイル: func.py プロジェクト: fagan2888/web_server_pecan
class FunctionLibraryController(FunctionMgrController):
    def __init__(self, project_id, fn_urn):
        super(FunctionLibraryController, self).__init__(project_id)
        self.fn_urn = fn_urn
        self.project_id = project_id
        self.func_mgr = FunctionClient()

    @wsme_pecan.wsexpose([funcmgr_types.LibraryMgrResponse])
    @return_api_resp(to_type=funcmgr_types.LibraryMgrResponse)
    def get_all(self):
        """Gets all libraries by function details."""

        return self.func_mgr.get_library_by_function(self.project_id,
                                                     self.fn_urn)
コード例 #10
0
ファイル: func.py プロジェクト: fagan2888/web_server_pecan
class FunctionStatController(base.BaseController):
    def __init__(self, project_id, node_id, fn_urn):
        super(FunctionStatController, self).__init__()
        self.project_id = project_id
        self.node_id = node_id
        self.func_mgr = FunctionClient()
        self.fn_urn = fn_urn

    @wsme_pecan.wsexpose(funcmgr_types.FunctionStatResponse)
    @return_api_resp(to_type=funcmgr_types.FunctionStatResponse)
    def get_all(self):
        """get functions status in node details."""

        return self.func_mgr.get_function_ins_status(
            project_id=self.project_id,
            node_id=self.node_id,
            fn_urn=self.fn_urn)
コード例 #11
0
ファイル: func.py プロジェクト: fagan2888/web_server_pecan
 def __init__(self, project_id):
     self.project_id = project_id
     super(FunctionMgrController, self).__init__()
     self.func_mgr = FunctionClient()
コード例 #12
0
ファイル: func.py プロジェクト: fagan2888/web_server_pecan
 def __init__(self, project_id, node_id, deploy_id):
     super(FunctionDeployStatusController, self).__init__()
     self.project_id = project_id
     self.node_id = node_id
     self.depoly_id = deploy_id
     self.func_mgr = FunctionClient()
コード例 #13
0
ファイル: func.py プロジェクト: fagan2888/web_server_pecan
 def __init__(self, project_id, node_id, fn_urn=None):
     super(FunctionNodeController, self).__init__()
     self.project_id = project_id
     self.node_id = node_id
     self.func_mgr = FunctionClient()
     self.fn_urn = fn_urn
コード例 #14
0
ファイル: func.py プロジェクト: fagan2888/web_server_pecan
 def __init__(self, project_id, fn_urn):
     super(FunctionLibraryController, self).__init__(project_id)
     self.fn_urn = fn_urn
     self.project_id = project_id
     self.func_mgr = FunctionClient()