示例#1
0
    def _delete_vnffg_post(self, context, vnffg_id, error):
        vnffg = self.get_vnffg(context, vnffg_id)
        nfp = self.get_nfp(context, vnffg['forwarding_paths'])
        chain = self.get_sfc(context, nfp['chain_id'])
        classifiers = [
            self.get_classifier(context, classifier_id)
            for classifier_id in nfp['classifier_ids']
        ]
        fc_queries = []
        match_queries = []
        with context.session.begin(subtransactions=True):
            vnffg_query = (self._model_query(
                context, Vnffg).filter(Vnffg.id == vnffg['id']).filter(
                    Vnffg.status == constants.PENDING_DELETE))
            nfp_query = (self._model_query(
                context, VnffgNfp).filter(VnffgNfp.id == nfp['id']).filter(
                    VnffgNfp.status == constants.PENDING_DELETE))
            sfc_query = (self._model_query(
                context,
                VnffgChain).filter(VnffgChain.id == chain['id']).filter(
                    VnffgChain.status == constants.PENDING_DELETE))
            for classifier in classifiers:
                fc_queries.append(
                    (self._model_query(context, VnffgClassifier).filter(
                        VnffgClassifier.id == classifier['id']).filter(
                            VnffgClassifier.status == constants.PENDING_DELETE)
                     ))
                match_queries.append(
                    (self._model_query(context, ACLMatchCriteria).filter(
                        ACLMatchCriteria.vnffgc_id == classifier['id'])))
            if error:
                vnffg_query.update({'status': constants.ERROR})
                nfp_query.update({'status': constants.ERROR})
                sfc_query.update({'status': constants.ERROR})
                for fc_query in fc_queries:
                    fc_query.update({'status': constants.ERROR})
            else:
                for match_query in match_queries:
                    match_query.delete()
                for fc_query in fc_queries:
                    fc_query.delete()
                sfc_query.delete()
                nfp_query.delete()
                vnffg_query.delete()

            vnffgd_id = vnffg.get('vnffgd_id')
            template_db = self._get_resource(context, VnffgTemplate, vnffgd_id)

            if template_db.get('template_source') == 'inline':
                self.delete_vnffgd(context, vnffgd_id)
示例#2
0
    def _create_vnffg_pre(self, context, vnffg):
        vnffg = vnffg['vnffg']
        LOG.debug('vnffg %s', vnffg)
        tenant_id = self._get_tenant_id_for_create(context, vnffg)
        name = vnffg.get('name')
        vnffg_id = vnffg.get('id') or uuidutils.generate_uuid()
        template_id = vnffg['vnffgd_id']
        symmetrical = vnffg['symmetrical']

        with context.session.begin(subtransactions=True):
            template_db = self._get_resource(context, VnffgTemplate,
                                             template_id)
            LOG.debug('vnffg template %s', template_db)

            if vnffg.get('attributes') and \
                    vnffg['attributes'].get('param_values'):
                vnffg_param = vnffg['attributes']
                vnffgd_topology_template = \
                    template_db.template['vnffgd']['topology_template']
                self._process_parameterized_template(vnffg_param,
                                                     vnffgd_topology_template)
                template_db.template['vnffgd']['topology_template'] = \
                    vnffgd_topology_template

            vnf_members = self._get_vnffg_property(template_db.template,
                                                   'constituent_vnfs')
            LOG.debug('Constituent VNFs: %s', vnf_members)
            vnf_mapping = self._get_vnf_mapping(context,
                                                vnffg.get('vnf_mapping'),
                                                vnf_members)
            LOG.debug('VNF Mapping: %s', vnf_mapping)
            # create NFP dict
            nfp_dict = self._create_nfp_pre(template_db)
            LOG.debug('NFP: %s', nfp_dict)
            vnffg_db = Vnffg(id=vnffg_id,
                             tenant_id=tenant_id,
                             name=name,
                             description=template_db.description,
                             vnf_mapping=vnf_mapping,
                             vnffgd_id=template_id,
                             attributes=template_db.get('template'),
                             status=constants.PENDING_CREATE)
            context.session.add(vnffg_db)

            nfp_id = uuidutils.generate_uuid()
            sfc_id = uuidutils.generate_uuid()
            classifier_id = uuidutils.generate_uuid()

            nfp_db = VnffgNfp(id=nfp_id,
                              vnffg_id=vnffg_id,
                              tenant_id=tenant_id,
                              name=nfp_dict['name'],
                              status=constants.PENDING_CREATE,
                              path_id=nfp_dict['path_id'],
                              symmetrical=symmetrical)
            context.session.add(nfp_db)

            chain = self._create_port_chain(context, vnf_mapping, template_db,
                                            nfp_dict['name'])
            LOG.debug('chain: %s', chain)
            sfc_db = VnffgChain(id=sfc_id,
                                tenant_id=tenant_id,
                                status=constants.PENDING_CREATE,
                                symmetrical=symmetrical,
                                chain=chain,
                                nfp_id=nfp_id,
                                path_id=nfp_dict['path_id'])

            context.session.add(sfc_db)

            sfcc_db = VnffgClassifier(id=classifier_id,
                                      tenant_id=tenant_id,
                                      status=constants.PENDING_CREATE,
                                      nfp_id=nfp_id,
                                      chain_id=sfc_id)
            context.session.add(sfcc_db)

            match = self._policy_to_acl_criteria(context, template_db,
                                                 nfp_dict['name'], vnf_mapping)
            LOG.debug('acl_match %s', match)

            match_db_table = ACLMatchCriteria(id=uuidutils.generate_uuid(),
                                              vnffgc_id=classifier_id,
                                              **match)

            context.session.add(match_db_table)

        return self._make_vnffg_dict(vnffg_db)
示例#3
0
    def _create_vnffg_pre(self, context, vnffg):
        vnffg = vnffg['vnffg']
        LOG.debug(_('vnffg %s'), vnffg)
        tenant_id = self._get_tenant_id_for_create(context, vnffg)
        name = vnffg.get('name')
        vnffg_id = vnffg.get('id') or str(uuid.uuid4())
        template_id = vnffg['vnffgd_id']
        symmetrical = vnffg['symmetrical']

        with context.session.begin(subtransactions=True):
            template_db = self._get_resource(context, VnffgTemplate,
                                             template_id)
            LOG.debug(_('vnffg template %s'), template_db)
            vnf_members = self._get_vnffg_property(template_db,
                                                   'constituent_vnfs')
            LOG.debug(_('Constituent VNFs: %s'), vnf_members)
            vnf_mapping = self._get_vnf_mapping(context, vnffg.get(
                                                'vnf_mapping'), vnf_members)
            LOG.debug(_('VNF Mapping: %s'), vnf_mapping)
            # create NFP dict
            nfp_dict = self._create_nfp_pre(template_db)
            vnffg_db = Vnffg(id=vnffg_id,
                             tenant_id=tenant_id,
                             name=name,
                             description=template_db.description,
                             vnf_mapping=vnf_mapping,
                             vnffgd_id=template_id,
                             status=constants.PENDING_CREATE)
            context.session.add(vnffg_db)

            nfp_id = str(uuid.uuid4())
            sfc_id = str(uuid.uuid4())
            classifier_id = str(uuid.uuid4())

            nfp_db = VnffgNfp(id=nfp_id, vnffg_id=vnffg_id,
                              tenant_id=tenant_id,
                              name=nfp_dict['name'],
                              status=constants.PENDING_CREATE,
                              path_id=nfp_dict['path_id'],
                              symmetrical=symmetrical)
            context.session.add(nfp_db)

            chain = self._create_port_chain(context, vnf_mapping, template_db,
                                            nfp_dict['name'])
            LOG.debug(_('chain: %s'), chain)
            sfc_db = VnffgChain(id=sfc_id,
                                tenant_id=tenant_id,
                                status=constants.PENDING_CREATE,
                                symmetrical=symmetrical,
                                chain=chain,
                                nfp_id=nfp_id,
                                path_id=nfp_dict['path_id'])

            context.session.add(sfc_db)

            sfcc_db = VnffgClassifier(id=classifier_id,
                                      tenant_id=tenant_id,
                                      status=constants.PENDING_CREATE,
                                      nfp_id=nfp_id,
                                      chain_id=sfc_id)
            context.session.add(sfcc_db)

            match = self._policy_to_acl_criteria(context, template_db,
                                                 nfp_dict['name'],
                                                 vnf_mapping)
            LOG.debug(_('acl_match %s'), match)

            match_db_table = ACLMatchCriteria(
                id=str(uuid.uuid4()),
                vnffgc_id=classifier_id,
                **match)

            context.session.add(match_db_table)

        return self._make_vnffg_dict(vnffg_db)
示例#4
0
    def _create_vnffg_pre(self, context, vnffg):
        vnffg = vnffg['vnffg']
        LOG.debug(_('vnffg %s'), vnffg)
        tenant_id = self._get_tenant_id_for_create(context, vnffg)
        name = vnffg.get('name')
        vnffg_id = vnffg.get('id') or str(uuid.uuid4())
        template_id = vnffg['vnffgd_id']
        symmetrical = vnffg['symmetrical']

        with context.session.begin(subtransactions=True):
            template_db = self._get_resource(context, VnffgTemplate,
                                             template_id)
            LOG.debug(_('vnffg template %s'), template_db)
            vnf_members = self._get_vnffg_property(template_db,
                                                   'constituent_vnfs')
            LOG.debug(_('Constituent VNFs: %s'), vnf_members)
            vnf_mapping = self._get_vnf_mapping(context,
                                                vnffg.get('vnf_mapping'),
                                                vnf_members)
            LOG.debug(_('VNF Mapping: %s'), vnf_mapping)
            # create NFP dict
            nfp_dict = self._create_nfp_pre(template_db)
            vnffg_db = Vnffg(id=vnffg_id,
                             tenant_id=tenant_id,
                             name=name,
                             description=template_db.description,
                             vnf_mapping=vnf_mapping,
                             vnffgd_id=template_id,
                             status=constants.PENDING_CREATE)
            context.session.add(vnffg_db)

            nfp_id = str(uuid.uuid4())
            sfc_id = str(uuid.uuid4())
            classifier_id = str(uuid.uuid4())

            nfp_db = VnffgNfp(id=nfp_id,
                              vnffg_id=vnffg_id,
                              tenant_id=tenant_id,
                              name=nfp_dict['name'],
                              status=constants.PENDING_CREATE,
                              path_id=nfp_dict['path_id'],
                              symmetrical=symmetrical)
            context.session.add(nfp_db)

            chain = self._create_port_chain(context, vnf_mapping, template_db,
                                            nfp_dict['name'])
            LOG.debug(_('chain: %s'), chain)
            sfc_db = VnffgChain(id=sfc_id,
                                tenant_id=tenant_id,
                                status=constants.PENDING_CREATE,
                                symmetrical=symmetrical,
                                chain=chain,
                                nfp_id=nfp_id,
                                path_id=nfp_dict['path_id'])

            context.session.add(sfc_db)

            sfcc_db = VnffgClassifier(id=classifier_id,
                                      tenant_id=tenant_id,
                                      status=constants.PENDING_CREATE,
                                      nfp_id=nfp_id,
                                      chain_id=sfc_id)
            context.session.add(sfcc_db)

            match = self._policy_to_acl_criteria(context, template_db,
                                                 nfp_dict['name'], vnf_mapping)
            LOG.debug(_('acl_match %s'), match)

            match_db_table = ACLMatchCriteria(id=str(uuid.uuid4()),
                                              vnffgc_id=classifier_id,
                                              **match)

            context.session.add(match_db_table)

        return self._make_vnffg_dict(vnffg_db)