예제 #1
0
    def create_bgpvpn(self, context, bgpvpn):
        bgpvpn = bgpvpn['bgpvpn']

        # Check that route_targets is not empty
        if (not bgpvpn['route_targets']):
            raise bgpvpn_ext.BGPVPNMissingRouteTarget
        else:
            rt = utils.rtrd_list2str(bgpvpn['route_targets'])
            i_rt = utils.rtrd_list2str(bgpvpn['import_targets'])
            e_rt = utils.rtrd_list2str(bgpvpn['export_targets'])
            rd = utils.rtrd_list2str(bgpvpn.get('route_distinguishers', ''))

        tenant_id = self._get_tenant_id_for_create(context, bgpvpn)

        with context.session.begin(subtransactions=True):
            bgpvpn_db = BGPVPN(
                id=uuidutils.generate_uuid(),
                tenant_id=tenant_id,
                name=bgpvpn['name'],
                type=bgpvpn['type'],
                route_targets=rt,
                import_targets=i_rt,
                export_targets=e_rt,
                route_distinguishers=rd,
                auto_aggregate=bgpvpn['auto_aggregate']
            )
            context.session.add(bgpvpn_db)

        return self._make_bgpvpn_dict(bgpvpn_db)
예제 #2
0
 def update_bgpvpn(self, context, id, bgpvpn):
     bgpvpn_db = self._get_bgpvpn(context, id)
     if bgpvpn:
         # Format Route Target lists to string
         if 'route_targets' in bgpvpn:
             rt = utils.rtrd_list2str(bgpvpn['route_targets'])
             bgpvpn['route_targets'] = rt
         if 'import_targets' in bgpvpn:
             i_rt = utils.rtrd_list2str(bgpvpn['import_targets'])
             bgpvpn['import_targets'] = i_rt
         if 'export_targets' in bgpvpn:
             e_rt = utils.rtrd_list2str(bgpvpn['export_targets'])
             bgpvpn['export_targets'] = e_rt
         if 'route_distinguishers' in bgpvpn:
             rd = utils.rtrd_list2str(bgpvpn['route_distinguishers'])
             bgpvpn['route_distinguishers'] = rd
         bgpvpn_db.update(bgpvpn)
     return self._make_bgpvpn_dict(bgpvpn_db)
예제 #3
0
    def create_bgpvpn(self, context, bgpvpn):
        rt = utils.rtrd_list2str(bgpvpn['route_targets'])
        i_rt = utils.rtrd_list2str(bgpvpn['import_targets'])
        e_rt = utils.rtrd_list2str(bgpvpn['export_targets'])
        rd = utils.rtrd_list2str(bgpvpn.get('route_distinguishers', ''))

        with context.session.begin(subtransactions=True):
            bgpvpn_db = BGPVPN(id=uuidutils.generate_uuid(),
                               tenant_id=bgpvpn['tenant_id'],
                               name=bgpvpn['name'],
                               type=bgpvpn['type'],
                               route_targets=rt,
                               import_targets=i_rt,
                               export_targets=e_rt,
                               route_distinguishers=rd)
            context.session.add(bgpvpn_db)

        return self._make_bgpvpn_dict(bgpvpn_db)
예제 #4
0
    def create_bgpvpn(self, context, bgpvpn):
        rt = utils.rtrd_list2str(bgpvpn['route_targets'])
        i_rt = utils.rtrd_list2str(bgpvpn['import_targets'])
        e_rt = utils.rtrd_list2str(bgpvpn['export_targets'])
        rd = utils.rtrd_list2str(bgpvpn.get('route_distinguishers', ''))

        with context.session.begin(subtransactions=True):
            bgpvpn_db = BGPVPN(
                id=uuidutils.generate_uuid(),
                tenant_id=bgpvpn['tenant_id'],
                name=bgpvpn['name'],
                type=bgpvpn['type'],
                route_targets=rt,
                import_targets=i_rt,
                export_targets=e_rt,
                route_distinguishers=rd
            )
            context.session.add(bgpvpn_db)

        return self._make_bgpvpn_dict(bgpvpn_db)
예제 #5
0
    def create_bgpvpn(self, context, bgpvpn):
        rt = utils.rtrd_list2str(bgpvpn['route_targets'])
        i_rt = utils.rtrd_list2str(bgpvpn['import_targets'])
        e_rt = utils.rtrd_list2str(bgpvpn['export_targets'])
        rd = utils.rtrd_list2str(bgpvpn.get('route_distinguishers', ''))

        bgpvpn_db = BGPVPN(
            id=uuidutils.generate_uuid(),
            tenant_id=bgpvpn['tenant_id'],
            name=bgpvpn['name'],
            type=bgpvpn['type'],
            route_targets=rt,
            import_targets=i_rt,
            export_targets=e_rt,
            route_distinguishers=rd,
            vni=bgpvpn.get(bgpvpn_vni_def.VNI),
            local_pref=bgpvpn.get(bgpvpn_rc_def.LOCAL_PREF_KEY),
        )
        context.session.add(bgpvpn_db)
        return self._make_bgpvpn_dict(bgpvpn_db)
예제 #6
0
    def update_bgpvpn(self, context, id, bgpvpn):
        fields = None
        with context.session.begin(subtransactions=True):
            bgpvpn_db = self._get_bgpvpn(context, id)
            if bgpvpn:
                # Format Route Target lists to string
                if 'route_targets' in bgpvpn:
                    rt = utils.rtrd_list2str(bgpvpn['route_targets'])
                    bgpvpn['route_targets'] = rt
                if 'import_targets' in bgpvpn:
                    i_rt = utils.rtrd_list2str(bgpvpn['import_targets'])
                    bgpvpn['import_targets'] = i_rt
                if 'export_targets' in bgpvpn:
                    e_rt = utils.rtrd_list2str(bgpvpn['export_targets'])
                    bgpvpn['export_targets'] = e_rt
                if 'route_distinguishers' in bgpvpn:
                    rd = utils.rtrd_list2str(bgpvpn['route_distinguishers'])
                    bgpvpn['route_distinguishers'] = rd

                bgpvpn_db.update(bgpvpn)
        return self._make_bgpvpn_dict(bgpvpn_db, fields)
예제 #7
0
    def update_bgpvpn(self, context, id, bgpvpn):
        fields = None
        with context.session.begin(subtransactions=True):
            bgpvpn_db = self._get_bgpvpn(context, id)
            if bgpvpn:
                # Format Route Target lists to string
                if 'route_targets' in bgpvpn:
                    rt = utils.rtrd_list2str(bgpvpn['route_targets'])
                    bgpvpn['route_targets'] = rt
                if 'import_targets' in bgpvpn:
                    i_rt = utils.rtrd_list2str(bgpvpn['import_targets'])
                    bgpvpn['import_targets'] = i_rt
                if 'export_targets' in bgpvpn:
                    e_rt = utils.rtrd_list2str(bgpvpn['export_targets'])
                    bgpvpn['export_targets'] = e_rt
                if 'route_distinguishers' in bgpvpn:
                    rd = utils.rtrd_list2str(bgpvpn['route_distinguishers'])
                    bgpvpn['route_distinguishers'] = rd

                bgpvpn_db.update(bgpvpn)
        return self._make_bgpvpn_dict(bgpvpn_db, fields)