Example #1
0
    def add_function_to_ledger(self, payload, corr_id, func_id, topic):
        """
        This method adds new functions with their specifics to the ledger,
        so other functions can use this information.

        :param payload: the payload of the received message
        :param corr_id: the correlation id of the received message
        :param func_id: the instance uuid of the function defined by SLM.
        """

        # Add the function to the ledger and add instance ids
        self.functions[func_id] = {}
        self.functions[func_id]['vnfd'] = payload['vnfd']
        self.functions[func_id]['id'] = func_id

        # Add the topic of the call
        self.functions[func_id]['topic'] = topic

        # Add to correlation id to the ledger
        self.functions[func_id]['orig_corr_id'] = corr_id

        # Add payload to the ledger
        self.functions[func_id]['payload'] = payload

        # Add the service uuid that this function belongs to
        self.functions[func_id]['serv_id'] = payload['serv_id']

        # Add the VIM uuid
        self.functions[func_id]['vim_uuid'] = payload['vim_uuid']

        # Create the function schedule
        self.functions[func_id]['schedule'] = []

        # Create the FSM dict if FSMs are defined in VNFD
        fsm_dict = tools.get_fsm_from_vnfd(payload['vnfd'])
        self.functions[func_id]['fsm'] = fsm_dict

        print(self.functions[func_id]['fsm'])

        # Create the chain pause and kill flag

        self.functions[func_id]['pause_chain'] = False
        self.functions[func_id]['kill_chain'] = False

        # Create payload fields for FSMs
        self.functions[func_id]['start'] = None
        self.functions[func_id]['stop'] = None
        self.functions[func_id]['configure'] = None

        self.functions[func_id]['act_corr_id'] = None
        self.functions[func_id]['message'] = None

        # Add error field
        self.functions[func_id]['error'] = None

        # Add keys
        self.functions[func_id]['public_key'] = payload['public_key']
        self.functions[func_id]['private_key'] = payload['private_key']

        return func_id
Example #2
0
    def add_function_to_ledger(self, payload, corr_id, func_id, topic):
        """
        This method adds new functions with their specifics to the ledger,
        so other functions can use this information.

        :param payload: the payload of the received message
        :param corr_id: the correlation id of the received message
        :param func_id: the instance uuid of the function defined by SLM.
        """

        # Add the function to the ledger and add instance ids
        self.functions[func_id] = {}
        self.functions[func_id]['vnfd'] = payload['vnfd']
        self.functions[func_id]['id'] = func_id

        # Add the topic of the call
        self.functions[func_id]['topic'] = topic

        # Add to correlation id to the ledger
        self.functions[func_id]['orig_corr_id'] = corr_id

        # Add payload to the ledger
        self.functions[func_id]['payload'] = payload

        # Add the service uuid that this function belongs to
        self.functions[func_id]['serv_id'] = payload['serv_id']

        # Add the VIM uuid
        self.functions[func_id]['vim_uuid'] = payload['vim_uuid']

        # Create the function schedule
        self.functions[func_id]['schedule'] = []

        # Create the FSM dict if FSMs are defined in VNFD
        fsm_dict = tools.get_fsm_from_vnfd(payload['vnfd'])
        self.functions[func_id]['fsm'] = fsm_dict

        print(self.functions[func_id]['fsm'])

        # Create the chain pause and kill flag

        self.functions[func_id]['pause_chain'] = False
        self.functions[func_id]['kill_chain'] = False

        # Create payload fields for FSMs
        self.functions[func_id]['start'] = None
        self.functions[func_id]['stop'] = None
        self.functions[func_id]['configure'] = None

        self.functions[func_id]['act_corr_id'] = None
        self.functions[func_id]['message'] = None

        # Add error field
        self.functions[func_id]['error'] = None

        # Add keys
        self.functions[func_id]['public_key'] = payload['public_key']
        self.functions[func_id]['private_key'] = payload['private_key']

        return func_id
Example #3
0
    def recreate_ledger(self, payload, corr_id, func_id, topic):
        """
        This method adds already existing functions with their specifics
        back to the ledger, so other methods can use this information.

        :param payload: the payload of the received message
        :param corr_id: the correlation id of the received message
        :param func_id: the instance uuid of the function defined by SLM.
        """

        # Add the function to the ledger and add instance ids
        self.functions[func_id] = {}
        self.functions[func_id]['act_corr_id'] = None
        self.functions[func_id]['error'] = None

        # Get VNFR
        get_vnfr = tools.getRestData(t.vnfr_path + '/', func_id)
        if get_vnfr['error'] is not None:
            error = get_vnfr['error'] + ': ' + get_vnfr['content']
            self.functions[func_id]['error'] = error
            return False
        self.functions[func_id]['vnfr'] = get_vnfr['content']
        self.functions[func_id]['vnfr']['id'] = func_id
        del self.functions[func_id]['vnfr']['created_at']
        del self.functions[func_id]['vnfr']['updated_at']
        del self.functions[func_id]['vnfr']['uuid']

        # GET VNFD
        vnfd_id = self.functions[func_id]['vnfr']['descriptor_reference']
        LOG.info(str(t.vnfd_path + '/' + vnfd_id))
        head = {"Content-type": "application/json"}
        get_vnfd = tools.getRestData(t.vnfd_path + '/', vnfd_id, head=head)
        if get_vnfd['error'] is not None:
            error = str(get_vnfd['error']) + ': ' + str(get_vnfd['content'])
            LOG.info(str(error))
            self.functions[func_id]['error'] = error
            return False
        self.functions[func_id]['vnfd'] = get_vnfd['content']['vnfd']
        LOG.info(str(self.functions[func_id]['vnfd']))

        self.functions[func_id]['id'] = func_id

        # Add the topic of the call
        self.functions[func_id]['topic'] = topic

        # Add to correlation id to the ledger
        self.functions[func_id]['orig_corr_id'] = corr_id

        # Add payload to the ledger
        self.functions[func_id]['payload'] = payload

        # Add the service uuid that this function belongs to
        self.functions[func_id]['serv_id'] = payload['serv_id']

        # Add the VIM uuid
        if 'vim_id' in payload.keys():
            self.functions[func_id]['vim_uuid'] = payload['vim_id']
        else:
            vdus = self.functions[func_id]['vnfr']['virtual_deployment_units']
            vim_id = vdus[0]['vnfc_instance'][0]['vim_id']
            self.functions[func_id]['vim_uuid'] = vim_id

        # Create the function schedule
        self.functions[func_id]['schedule'] = []

        # Create the FSM dict if FSMs are defined in VNFD
        fsm_dict = tools.get_fsm_from_vnfd(self.functions[func_id]['vnfd'])
        LOG.info(str(fsm_dict))
        self.functions[func_id]['fsm'] = fsm_dict

        # Setup broker connection with the SSMs of this service.
        if bool(fsm_dict) and func_id not in self.fsm_connections.keys():
            url = self.fsm_url_base + 'fsm-' + func_id
            fsm_conn = messaging.ManoBrokerRequestResponseConnection(self.name,
                                                                     url=url)

            self.fsm_connections[func_id] = fsm_conn

        # Create the chain pause and kill flag

        self.functions[func_id]['pause_chain'] = False
        self.functions[func_id]['kill_chain'] = False

        # Create payload fields for FSMs
        self.functions[func_id]['start'] = None
        self.functions[func_id]['stop'] = None
        self.functions[func_id]['configure'] = None
        self.functions[func_id]['message'] = None

        return True
Example #4
0
    def recreate_ledger(self, payload, corr_id, func_id, topic):
        """
        This method adds already existing functions with their specifics
        back to the ledger, so other methods can use this information.

        :param payload: the payload of the received message
        :param corr_id: the correlation id of the received message
        :param func_id: the instance uuid of the function defined by SLM.
        """

        # Add the function to the ledger and add instance ids
        self.functions[func_id] = {}

        # TODO: add the real vnfr here
        vnfr = {}
        self.functions[func_id]['vnfr'] = vnfr

        if 'vnfd' in payload.keys():
            vnfd = payload['vnfd']
        else:
            # TODO: retrieve VNFD from CAT based on func_id
            vnfd = {}
        self.functions[func_id]['vnfd'] = vnfd

        self.functions[func_id]['id'] = func_id

        # Add the topic of the call
        self.functions[func_id]['topic'] = topic

        # Add to correlation id to the ledger
        self.functions[func_id]['orig_corr_id'] = corr_id

        # Add payload to the ledger
        self.functions[func_id]['payload'] = payload

        # Add the service uuid that this function belongs to
        self.functions[func_id]['serv_id'] = payload['serv_id']

        # Add the VIM uuid
        self.functions[func_id]['vim_uuid'] = ''

        # Create the function schedule
        self.functions[func_id]['schedule'] = []

        # Create the FSM dict if FSMs are defined in VNFD
        fsm_dict = tools.get_fsm_from_vnfd(vnfd)
        self.functions[func_id]['fsm'] = fsm_dict

        # Create the chain pause and kill flag

        self.functions[func_id]['pause_chain'] = False
        self.functions[func_id]['kill_chain'] = False

        # Create payload fields for FSMs
        self.functions[func_id]['start'] = None
        self.functions[func_id]['stop'] = None
        self.functions[func_id]['configure'] = None
        self.functions[func_id]['act_corr_id'] = None
        self.functions[func_id]['message'] = None

        # Add error field
        self.functions[func_id]['error'] = None

        return func_id
Example #5
0
    def recreate_ledger(self, payload, corr_id, func_id, topic):
        """
        This method adds already existing functions with their specifics
        back to the ledger, so other methods can use this information.

        :param payload: the payload of the received message
        :param corr_id: the correlation id of the received message
        :param func_id: the instance uuid of the function defined by SLM.
        """

        # Add the function to the ledger and add instance ids
        self.functions[func_id] = {}

        # TODO: add the real vnfr here
        vnfr = {}
        self.functions[func_id]['vnfr'] = vnfr

        if 'vnfd' in payload.keys():
            vnfd = payload['vnfd']
        else:
            # TODO: retrieve VNFD from CAT based on func_id
            vnfd = {}
        self.functions[func_id]['vnfd'] = vnfd

        self.functions[func_id]['id'] = func_id

        # Add the topic of the call
        self.functions[func_id]['topic'] = topic

        # Add to correlation id to the ledger
        self.functions[func_id]['orig_corr_id'] = corr_id

        # Add payload to the ledger
        self.functions[func_id]['payload'] = payload

        # Add the service uuid that this function belongs to
        self.functions[func_id]['serv_id'] = payload['serv_id']

        # Add the VIM uuid
        self.functions[func_id]['vim_uuid'] = ''

        # Create the function schedule
        self.functions[func_id]['schedule'] = []

        # Create the FSM dict if FSMs are defined in VNFD
        fsm_dict = tools.get_fsm_from_vnfd(vnfd)
        self.functions[func_id]['fsm'] = fsm_dict

        # Create the chain pause and kill flag

        self.functions[func_id]['pause_chain'] = False
        self.functions[func_id]['kill_chain'] = False

        # Create payload fields for FSMs
        self.functions[func_id]['start'] = None
        self.functions[func_id]['stop'] = None
        self.functions[func_id]['configure'] = None
        self.functions[func_id]['act_corr_id'] = None
        self.functions[func_id]['message'] = None

        # Add error field
        self.functions[func_id]['error'] = None

        return func_id
Example #6
0
    def recreate_ledger(self, payload, corr_id, func_id, topic):
        """
        This method adds already existing functions with their specifics
        back to the ledger, so other methods can use this information.

        :param payload: the payload of the received message
        :param corr_id: the correlation id of the received message
        :param func_id: the instance uuid of the function defined by SLM.
        """

        # Add the function to the ledger and add instance ids
        self.functions[func_id] = {}
        self.functions[func_id]['act_corr_id'] = None
        self.functions[func_id]['error'] = None

        # Get VNFR
        get_vnfr = tools.getRestData(t.vnfr_path + '/', func_id)
        if get_vnfr['error'] is not None:
            error = get_vnfr['error'] + ': ' + get_vnfr['content']
            self.functions[func_id]['error'] = error
            return False
        self.functions[func_id]['vnfr'] = get_vnfr['content']
        self.functions[func_id]['vnfr']['id'] = func_id
        del self.functions[func_id]['vnfr']['created_at']
        del self.functions[func_id]['vnfr']['updated_at']
        del self.functions[func_id]['vnfr']['uuid']

        # GET VNFD
        vnfd_id = self.functions[func_id]['vnfr']['descriptor_reference']
        LOG.info(str(t.vnfd_path + '/' + vnfd_id))
        head = {"Content-type": "application/json"}
        get_vnfd = tools.getRestData(t.vnfd_path + '/', vnfd_id, head=head)
        if get_vnfd['error'] is not None:
            error = str(get_vnfd['error']) + ': ' + str(get_vnfd['content'])
            LOG.info(str(error))
            self.functions[func_id]['error'] = error
            return False
        self.functions[func_id]['vnfd'] = get_vnfd['content']['vnfd']
        LOG.info(str(self.functions[func_id]['vnfd']))

        self.functions[func_id]['id'] = func_id

        # Add the topic of the call
        self.functions[func_id]['topic'] = topic

        # Add to correlation id to the ledger
        self.functions[func_id]['orig_corr_id'] = corr_id

        # Add payload to the ledger
        self.functions[func_id]['payload'] = payload

        # Add the service uuid that this function belongs to
        self.functions[func_id]['serv_id'] = payload['serv_id']

        # Add the VIM uuid
        if 'vim_id' in payload.keys():
            self.functions[func_id]['vim_uuid'] = payload['vim_id']
        else:
            if 'virtual_deployment_units' in self.functions[func_id]['vnfr']:
                vdus = self.functions[func_id]['vnfr']['virtual_deployment_units']
                vim_id = vdus[0]['vnfc_instance'][0]['vim_id']
                self.functions[func_id]['vim_uuid'] = vim_id
                self.functions[func_id]['type'] = 'vm'
            if 'cloudnative_deployment_units' in self.functions[func_id]['vnfr']:
                cdus = self.functions[func_id]['vnfr']['cloudnative_deployment_units']
                vim_id = cdus[0]['vim_id']
                self.functions[func_id]['vim_uuid'] = vim_id
                self.functions[func_id]['type'] = 'container'

        # Create the function schedule
        self.functions[func_id]['schedule'] = []

        # Create the FSM dict if FSMs are defined in VNFD
        fsm_dict = tools.get_fsm_from_vnfd(self.functions[func_id]['vnfd'])
        LOG.info(str(fsm_dict))
        self.functions[func_id]['fsm'] = fsm_dict

        # Setup broker connection with the SSMs of this service.
        if bool(fsm_dict) and func_id not in self.fsm_connections.keys():
            url = self.fsm_url_base + 'fsm-' + func_id
            fsm_conn = messaging.ManoBrokerRequestResponseConnection(self.name,
                                                                     url=url)

            self.fsm_connections[func_id] = fsm_conn

        # Create the chain pause and kill flag

        self.functions[func_id]['pause_chain'] = False
        self.functions[func_id]['kill_chain'] = False

        # Create payload fields for FSMs
        self.functions[func_id]['start'] = None
        self.functions[func_id]['stop'] = None
        self.functions[func_id]['configure'] = None
        self.functions[func_id]['message'] = None

        return True