Пример #1
0
    def IA_deploy_response(self, ch, method, prop, payload):
        """
        This method handles the response from the IA on the
        vnf deploy request.
        """

        LOG.info("Response from IA on vnf deploy call received.")
        LOG.debug("Payload of request: " + str(payload))

        inc_message = yaml.load(payload)

        func_id = tools.funcid_from_corrid(self.functions, prop.correlation_id)

        self.functions[func_id]['status'] = inc_message['request_status']

        if inc_message['request_status'] == "COMPLETED":
            LOG.info("Vnf deployed correctly")
            self.functions[func_id]["ia_vnfr"] = inc_message["vnfr"]
            self.functions[func_id]["error"] = None

        else:
            LOG.info("Deployment failed: " + inc_message["message"])
            self.functions[func_id]["error"] = inc_message["message"]
            topic = self.functions[func_id]['topic']
            self.flm_error(func_id, topic)
            return

        self.start_next_task(func_id)
Пример #2
0
    def IA_deploy_response(self, ch, method, prop, payload):
        """
        This method handles the response from the IA on the
        vnf deploy request.
        """

        LOG.info("Response from IA on vnf deploy call received.")
        LOG.debug("Payload of request: " + str(payload))

        inc_message = yaml.load(payload)

        func_id = tools.funcid_from_corrid(self.functions, prop.correlation_id)

        self.functions[func_id]['status'] = inc_message['request_status']

        if inc_message['request_status'] == "COMPLETED":
            LOG.info("Vnf deployed correctly")
            self.functions[func_id]["ia_vnfr"] = inc_message["vnfr"]
            self.functions[func_id]["error"] = None

        else:
            LOG.info("Deployment failed: " + inc_message["message"])
            self.functions[func_id]["error"] = inc_message["message"]
            topic = self.functions[func_id]['topic']
            self.flm_error(func_id, topic)
            return

        self.start_next_task(func_id)
Пример #3
0
    def fsm_generic_response(self, ch, method, prop, payload):
        """
        This method handles a response to a generic FSM trigger call
        """
        response = yaml.load(payload)

        func_id = tools.funcid_from_corrid(self.functions, prop.correlation_id)
        function = self.functions[func_id]
        fsm_type = function['active_fsm']

        LOG.info("Response from " + fsm_type + " FSM received")

        if response['status'] == "COMPLETED":
            LOG.info("FSM finished successfully")
            if response.get('persist'):
                self.functions[func_id]['message'] = response['persist']
            else:
                self.functions[func_id]['message'] = "FSM finished successfully"
            if 'envs' in response.keys():
                if function['type'] is not 'container':
                    msg = 'type is not container, ignoring envs from fsm'
                    LOG.info("Function " + func_id + msg)
                else:
                    if type(response['envs']) == list:
                        if 'envs' not in function.keys():
                            function['envs'] = response['envs']
                        else:
                            for cdu1 in response['envs']:
                                for cdu2 in function['envs']:
                                    if cdu1['cdu_id'] == cdu2['cdu_id']:
                                        new = cdu2['envs'].copy()
                                        new.update(cdu1['envs'])
                                        cdu2['envs'] = new
                                        break
                        if 'func_ia_configure' not in function['schedule']:
                            function['schedule'].insert(0, 'func_ia_configure')
                    else:
                        message = 'envs is not a list'
                        function["error"] = message
                        self.flm_error(func_id)
        else:
            LOG.info(fsm_type + " FSM failed: " + response['error'])
            function["error"] = response['error']
            self.flm_error(func_id)
            return

        self.start_next_task(func_id)
Пример #4
0
    def fsm_generic_response(self, ch, method, prop, payload):
        """
        This method handles a response to a generic FSM trigger call
        """
        response = yaml.load(payload)

        func_id = tools.funcid_from_corrid(self.functions, prop.correlation_id)
        function = self.functions[func_id]
        fsm_type = function['active_fsm']

        LOG.info("Response from " + fsm_type + " FSM received")

        if response['status'] == "COMPLETED":
            LOG.info("FSM finished successfully")
            self.functions[func_id]['message'] = "FSM finished successfully"
            if 'envs' in response.keys():
                if function['type'] is not 'container':
                    msg = 'type is not container, ignoring envs from fsm'
                    LOG.info("Function " + func_id + msg)
                else:
                    if type(response['envs']) == list:
                        if 'envs' not in function.keys():
                            function['envs'] = response['envs']
                        else:
                            for cdu1 in response['envs']:
                                for cdu2 in function['envs']:
                                    if cdu1['cdu_id'] == cdu2['cdu_id']:
                                        new = cdu2['envs'].copy()
                                        new.update(cdu1['envs'])
                                        cdu2['envs'] = new
                                        break
                        if 'func_ia_configure' not in function['schedule']:
                            function['schedule'].insert(0, 'func_ia_configure')
                    else:
                        message = 'envs is not a list'
                        function["error"] = message
                        self.flm_error(func_id)
        else:
            LOG.info(fsm_type + " FSM failed: " + response['error'])
            function["error"] = response['error']
            self.flm_error(func_id)
            return

        self.start_next_task(func_id)
Пример #5
0
    def fsm_generic_response(self, ch, method, prop, payload):
        """
        This method handles a response to a generic FSM trigger call
        """
        response = yaml.load(payload)

        func_id = tools.funcid_from_corrid(self.functions, prop.correlation_id)
        fsm_type = self.functions[func_id]['active_fsm']

        LOG.info("Response from " + fsm_type + " FSM received")

        if response['status'] == "COMPLETED":
            LOG.info("FSM finished successfully")

        else:
            LOG.info(fsm_type + " FSM failed: " + response['error'])
            self.functions[func_id]["error"] = response['error']
            self.flm_error(func_id)
            return

        self.start_next_task(func_id)
Пример #6
0
    def fsm_task_response(self, ch, method, prop, payload):
        """
        This method handles a response from a task FSM.
        """
        response = yaml.load(response)

        func_id = tools.funcid_from_corrid(self.functions, prop.correlation_id)

        LOG.info("Response from task FSM received")

        if response['status'] == "COMPLETED":
            LOG.info("FSM finished successfully")
            self.functions[func_id]['schedule'] = response['schedule']

        else:
            LOG.info("task FSM failed: " + response['error'])
            self.functions[func_id]["error"] = response['error']
            self.flm_error(func_id)
            return

        self.start_next_task(func_id)
Пример #7
0
    def ia_configure_response(self, ch, method, prop, payload):
        """
        This method handles a response to a generic FSM trigger call
        """
        response = yaml.load(payload)

        func_id = tools.funcid_from_corrid(self.functions, prop.correlation_id)

        msg = 'Response received from IA on configure call'
        LOG.info("Function " + func_id + msg)

        if response['request_status'] == 'ERROR':
            msg = ': CNF configure event failed: ' + response['message']
            LOG.info("Function " + func_id + msg)
            function["error"] = response['message']
            self.flm_error(func_id)
            return

        self.functions[func_id]['message'] = "Env injection successful"

        self.start_next_task(func_id)
Пример #8
0
    def fsm_task_response(self, ch, method, prop, payload):
        """
        This method handles a response from a task FSM.
        """
        response = yaml.load(response)

        func_id = tools.funcid_from_corrid(self.functions, prop.correlation_id)

        LOG.info("Response from task FSM received")

        if response['status'] == "COMPLETED":
            LOG.info("FSM finished successfully")
            self.functions[func_id]['schedule'] = response['schedule']

        else:
            LOG.info("task FSM failed: " + response['error'])
            self.functions[func_id]["error"] = response['error']
            self.flm_error(func_id)
            return

        self.start_next_task(func_id)
Пример #9
0
    def fsm_generic_response(self, ch, method, prop, payload):
        """
        This method handles a response to a generic FSM trigger call
        """
        response = yaml.load(payload)

        func_id = tools.funcid_from_corrid(self.functions, prop.correlation_id)
        fsm_type = self.functions[func_id]['active_fsm']

        LOG.info("Response from " + fsm_type + " FSM received")

        if response['status'] == "COMPLETED":
            LOG.info("FSM finished successfully")

        else:
            LOG.info(fsm_type + " FSM failed: " + response['error'])
            self.functions[func_id]["error"] = response['error']
            self.flm_error(func_id)
            return

        self.start_next_task(func_id)
Пример #10
0
    def resp_onboard(self, ch, method, prop, payload):
        """
        This method handles the response from the SMR on the fsm onboard call
        """

        func_id = tools.funcid_from_corrid(self.functions, prop.correlation_id)
        LOG.info("Function " + func_id + ": Onboard resp received from SMR.")

        message = yaml.load(payload)

        for key in message.keys():
            if message[key]['error'] == 'None':
                LOG.info("Function " + func_id + ": FSMs onboarding succesful")
            else:
                msg = ": FSM onboarding failed: " + message[key]['error']
                LOG.info("Function " + func_id + msg)
                self.fm_error(func_id,
                              t.GK_CREATE,
                              error=message[key]['error'])

        # Continue with the scheduled tasks
        self.start_next_task(func_id)
Пример #11
0
    def ia_configure_response(self, ch, method, prop, payload):
        """
        This method handles a response to a generic FSM trigger call
        """
        response = yaml.load(payload)

        func_id = tools.funcid_from_corrid(self.functions, prop.correlation_id)

        msg = ': Response received from IA on configure call'
        LOG.info("Function " + func_id + msg)
        LOG.info("Function " + func_id + ': corr_id ' + str(prop.correlation_id))

        if response['request_status'] == 'ERROR':
            msg = ': CNF configure event failed: ' + response['message']
            LOG.info("Function " + func_id + msg)
            function["error"] = response['message']
            self.flm_error(func_id)
            return

        self.functions[func_id]['message'] = "Env injection successful"

        self.start_next_task(func_id)
Пример #12
0
    def resp_onboard(self, ch, method, prop, payload):
        """
        This method handles the response from the SMR on the fsm onboard call
        """

        func_id = tools.funcid_from_corrid(self.functions, prop.correlation_id)
        LOG.info("Function " + func_id + ": Onboard resp received from SMR.")

        message = yaml.load(payload)

        for key in message.keys():
            if message[key]['error'] == 'None':
                LOG.info("Function " + func_id + ": FSMs onboarding succesful")
            else:
                msg = ": FSM onboarding failed: " + message[key]['error']
                LOG.info("Function " + func_id + msg)
                self.fm_error(func_id,
                              t.GK_CREATE,
                              error=message[key]['error'])

        # Continue with the scheduled tasks
        self.start_next_task(func_id)
Пример #13
0
    def ia_remove_response(self, ch, method, prop, payload):
        """
        This method handles responses on IA VNF remove requests.
        """
        inc_message = yaml.load(payload)

        func_id = tools.funcid_from_corrid(self.functions, prop.correlation_id)

        msg = "Response from IA on vnf remove call received."
        LOG.info("Function " + func_id + msg)

        if inc_message['request_status'] == "COMPLETED":
            LOG.info("Vnf removal successful")
            self.functions[func_id]["vnfr"]["status"] = "terminated"

        else:
            msg = "Removal failed: " + inc_message["message"]
            LOG.info("Function " + func_id + msg)
            self.functions[func_id]["error"] = inc_message["message"]
            self.flm_error(func_id, self.functions[func_id]['topic'])
            return

        self.start_next_task(func_id)
Пример #14
0
    def ia_remove_response(self, ch, method, prop, payload):
        """
        This method handles responses on IA VNF remove requests.
        """
        inc_message = yaml.load(payload)

        func_id = tools.funcid_from_corrid(self.functions, prop.correlation_id)

        msg = "Response from IA on vnf remove call received."
        LOG.info("Function " + func_id + msg)

        if inc_message['request_status'] == "COMPLETED":
            LOG.info("Vnf removal successful")
            self.functions[func_id]["vnfr"]["status"] = "terminated"

        else:
            msg = "Removal failed: " + inc_message["message"]
            LOG.info("Function " + func_id + msg)
            self.functions[func_id]["error"] = inc_message["message"]
            self.flm_error(func_id, self.functions[func_id]['topic'])
            return

        self.start_next_task(func_id)
Пример #15
0
    def IA_deploy_response(self, ch, method, prop, payload):
        """
        This method handles the response from the IA on the
        vnf deploy request.
        """

        LOG.info("Payload of request: " + str(payload))

        inc_message = yaml.load(payload)

        func_id = tools.funcid_from_corrid(self.functions, prop.correlation_id)

        msg = "Response from IA on vnf deploy call received."
        LOG.info("Function " + func_id + msg)

        self.functions[func_id]['status'] = inc_message['request_status']

        if inc_message['request_status'] == "COMPLETED":
            LOG.info("Vnf deployed correctly")
            self.functions[func_id]["ia_vnfr"] = inc_message["vnfr"]
            self.functions[func_id]["error"] = None

            # TODO:Temporary fix for the HSP case, needs fixing in longterm
            if "ip_mapping" in inc_message.keys():
                mapping = inc_message["ip_mapping"]
                self.functions[func_id]["ip_mapping"] = mapping
            else:
                self.functions[func_id]["ip_mapping"] = []

        else:
            LOG.info("Deployment failed: " + inc_message["message"])
            self.functions[func_id]["error"] = inc_message["message"]
            topic = self.functions[func_id]['topic']
            self.flm_error(func_id, topic)
            return

        self.start_next_task(func_id)
Пример #16
0
    def IA_deploy_response(self, ch, method, prop, payload):
        """
        This method handles the response from the IA on the
        vnf deploy request.
        """

        LOG.info("Payload of request: " + str(payload))

        inc_message = yaml.load(payload)

        func_id = tools.funcid_from_corrid(self.functions, prop.correlation_id)

        msg = "Response from IA on vnf deploy call received."
        LOG.info("Function " + func_id + msg)

        self.functions[func_id]['status'] = inc_message['request_status']

        if inc_message['request_status'] == "COMPLETED":
            LOG.info("Vnf deployed correctly")
            self.functions[func_id]["ia_vnfr"] = inc_message["vnfr"]
            self.functions[func_id]["error"] = None

            # TODO:Temporary fix for the HSP case, needs fixing in longterm
            if "ip_mapping" in inc_message.keys():
                mapping = inc_message["ip_mapping"]
                self.functions[func_id]["ip_mapping"] = mapping
            else:
                self.functions[func_id]["ip_mapping"] = []

        else:
            LOG.info("Deployment failed: " + inc_message["message"])
            self.functions[func_id]["error"] = inc_message["message"]
            topic = self.functions[func_id]['topic']
            self.flm_error(func_id, topic)
            return

        self.start_next_task(func_id)
Пример #17
0
    def resp_instant(self, ch, method, prop, payload):
        """
        This method handles responses to a request to onboard the fsms
        of a new function.
        """

        # Retrieve the function uuid
        func_id = tools.funcid_from_corrid(self.functions, prop.correlation_id)
        msg = ": Instantiating response received from SMR."
        LOG.info("Function " + func_id + msg)
        LOG.debug(payload)

        message = yaml.load(payload)
        for fsm_type in self.functions[func_id]['fsm'].keys():
            fsm = self.functions[func_id]['fsm'][fsm_type]
            response = message[fsm['id']]
            fsm['instantiated'] = False
            if response['error'] == 'None':
                LOG.info("Function " + func_id + ": FSM instantiated correct.")
                fsm['instantiated'] = True
            else:
                msg = ": FSM instantiation failed: " + response['error']
                LOG.info("Function " + func_id + msg)
                self.flm_error(func_id, error=response['error'])

            fsm['uuid'] = response['uuid']

        # Setup broker connection with the SSMs of this service.
        url = self.fsm_url_base + 'fsm-' + func_id
        fsm_conn = messaging.ManoBrokerRequestResponseConnection(self.name,
                                                                 url=url)

        self.fsm_connections[func_id] = fsm_conn

        # Continue with the scheduled tasks
        self.start_next_task(func_id)
Пример #18
0
    def resp_instant(self, ch, method, prop, payload):
        """
        This method handles responses to a request to onboard the fsms
        of a new function.
        """

        # Retrieve the function uuid
        func_id = tools.funcid_from_corrid(self.functions, prop.correlation_id)
        msg = ": Instantiating response received from SMR."
        LOG.info("Function " + func_id + msg)
        LOG.debug(payload)

        message = yaml.load(payload)
        for fsm_type in self.functions[func_id]['fsm'].keys():
            fsm = self.functions[func_id]['fsm'][fsm_type]
            response = message[fsm['id']]
            fsm['instantiated'] = False
            if response['error'] == 'None':
                LOG.info("Function " + func_id + ": FSM instantiated correct.")
                fsm['instantiated'] = True
            else:
                msg = ": FSM instantiation failed: " + response['error']
                LOG.info("Function " + func_id + msg)
                self.flm_error(func_id, error=response['error'])

            fsm['uuid'] = response['uuid']

        # Setup broker connection with the SSMs of this service.
        url = self.fsm_url_base + 'fsm-' + func_id
        fsm_conn = messaging.ManoBrokerRequestResponseConnection(self.name,
                                                                 url=url)

        self.fsm_connections[func_id] = fsm_conn

        # Continue with the scheduled tasks
        self.start_next_task(func_id)