def update_bgpvpn(self, context, id, new_bgpvpn): LOG.debug("update_bgpvpn called with %s for %s" % (new_bgpvpn, id)) oc_client = self._get_opencontrail_api_client(context) old_bgpvpn = self.get_bgpvpn(context, id) networks = old_bgpvpn.get('networks', []) bgpvpn = old_bgpvpn.copy() bgpvpn.update(new_bgpvpn) (added_keys, removed_keys, changed_keys) = \ utils.get_bgpvpn_differences(bgpvpn, old_bgpvpn) if not (added_keys or removed_keys or changed_keys): return utils.make_bgpvpn_dict(bgpvpn) # Does not support to update route distinguisher if 'route_distinguishers' in added_keys | removed_keys | changed_keys: raise bgpvpn_ext.BGPVPNRDNotSupported( driver=OPENCONTRAIL_BGPVPN_DRIVER_NAME) rt_keys = set(['route_targets', 'import_targets', 'export_targets']) if (rt_keys & added_keys or rt_keys & changed_keys or rt_keys & removed_keys): self._set_bgpvpn_association(oc_client, 'DELETE', old_bgpvpn, networks) self._set_bgpvpn_association(oc_client, 'ADD', bgpvpn, networks) oc_client.kv_store('STORE', key=id, value={'bgpvpn': bgpvpn}) return utils.make_bgpvpn_dict(bgpvpn)
def create_bgpvpn(self, context, bgpvpn): LOG.debug("create_bgpvpn_ called with %s" % bgpvpn) # Only support l3 technique if not bgpvpn['type']: bgpvpn['type'] = constants.BGPVPN_L3 elif bgpvpn['type'] != constants.BGPVPN_L3: raise bgpvpn_ext.BGPVPNTypeNotSupported( driver=OPENCONTRAIL_BGPVPN_DRIVER_NAME, type=bgpvpn['type']) # Does not support to set route distinguisher if 'route_distinguishers' in bgpvpn and bgpvpn['route_distinguishers']: raise bgpvpn_ext.BGPVPNRDNotSupported( driver=OPENCONTRAIL_BGPVPN_DRIVER_NAME) oc_client = self._get_opencontrail_api_client(context) # Check if tenant ID exists; # if not, it sends an exception self._check_tenant_id(oc_client, bgpvpn['tenant_id']) bgpvpn['id'] = uuidutils.generate_uuid() oc_client.kv_store('STORE', key=bgpvpn['id'], value={'bgpvpn': bgpvpn}) return utils.make_bgpvpn_dict(bgpvpn)
def update_bgpvpn_precommit(self, ctx, old_bgpvpn, bgpvpn): if (bgpvpn.get('route_distinguishers') is not None and old_bgpvpn['route_distinguishers'] != bgpvpn['route_distinguishers']): raise bgpvpn_ext.BGPVPNRDNotSupported(driver=DR_DRIVER_NAME) if (bgpvpn.get('vni') is not None and old_bgpvpn['vni'] != bgpvpn['vni']): raise bgpvpn_ext.BGPVPNVNINotSupported(driver=DR_DRIVER_NAME)
def update_bgpvpn(self, context, id, bgpvpn): if 'route_distinguishers' in bgpvpn: raise bgpvpn_ext.BGPVPNRDNotSupported( driver=CONTRAIL_BGPVPN_DRIVER_NAME) try: bgpvpn_obj = self._vnc_api.bgpvpn_read(id=id) except vnc_exc.NoIdError: raise bgpvpn_ext.BGPVPNNotFound(id=id) bgpvpn_obj = self._neutron_dict_to_bgpvpn(bgpvpn_obj, bgpvpn) try: self._vnc_api.bgpvpn_update(bgpvpn_obj) except vnc_exc.BadRequest as e: raise neutron_exc.BadRequest(resource='bgpvpn', msg=str(e)) return self._bgpvpn_to_neutron_dict(bgpvpn_obj)
def create_bgpvpn(self, context, bgpvpn): LOG.debug("create_bgpvpn called with: %s" % bgpvpn) # Does not support to set route distinguisher if 'route_distinguishers' in bgpvpn and bgpvpn['route_distinguishers']: raise bgpvpn_ext.BGPVPNRDNotSupported( driver=CONTRAIL_BGPVPN_DRIVER_NAME) project_obj = self._project_read(bgpvpn['tenant_id']) id_perms_obj = vnc_api.IdPermsType(enable=True) bgpvpn_obj = self._neutron_dict_to_bgpvpn( vnc_api.Bgpvpn(bgpvpn['name'], project_obj, id_perms=id_perms_obj), bgpvpn) self._resource_create('bgpvpn', bgpvpn_obj) return self._bgpvpn_to_neutron_dict(bgpvpn_obj)
def _common_precommit_checks(self, bgpvpn): # No support yet for specifying route distinguishers if bgpvpn.get('route_distinguishers', None): raise bgpvpn_ext.BGPVPNRDNotSupported(driver=BAGPIPE_DRIVER_NAME)
def _is_bgpvpn_rd_empty(self, bgpvpn): if bgpvpn.get('route_distinguishers', None) is None: raise bgpvpn_ext.BGPVPNRDNotSupported(driver=DR_DRIVER_NAME)