url = url + "/"
self.url = url + "onos/v1/network/configuration"
+ self.hosts_url = url + "onos/v1/hosts"
self.logger.info("ONOS VPLS Connector Initialized.")
def check_credentials(self):
"Exception posting onos network config: {}".format(e)
)
+ def _delete_onos_hosts(self, onos_host_list):
+ try:
+ for host_id in onos_host_list:
+ url = f"{self.hosts_url}/{host_id}"
+ onos_resp = requests.delete(
+ url, auth=HTTPBasicAuth(self.user, self.password)
+ )
+ status_code = onos_resp.status_code
+
+ if status_code != requests.codes.ok:
+ self.logger.info(
+ "Error deleting ONOS host, status code: {}".format(status_code)
+ )
+
+ raise SdnConnectorError(
+ "Error deleting ONOS host, status code: {}".format(status_code),
+ http_code=status_code,
+ )
+ except requests.exceptions.ConnectionError as e:
+ self.logger.info("Exception connecting to onos: %s", e)
+
+ raise SdnConnectorError("Error connecting to onos: {}".format(e))
+ except Exception as e:
+ self.logger.info("Exception posting onos network config: %s", e)
+
+ raise SdnConnectorError(
+ "Exception posting onos network config: {}".format(e)
+ )
+
def create_connectivity_service(self, service_type, connection_points, **kwargs):
self.logger.debug(
"create_connectivity_service, service_type: {}, connection_points: {}".format(
created_ifs = conn_info.get("interfaces", [])
# Obtain current config
onos_config = self._get_onos_netconfig()
+ conn_service_host_list = []
try:
# Removes ports used by network from onos config
+ # In addition, it stores host identifiers (e.g. "FA:16:3E:43:9F:4A/1001")
+ # in conn_service_host_list to be deleted by self._delete_onos_hosts
for vpls in (
onos_config.get("apps", {})
.get("org.onosproject.vpls", {})
.get("vplsList", {})
):
if vpls["name"] == service_uuid:
+ self.logger.debug(f"vpls service to be deleted: {vpls}")
# iterate interfaces to check if must delete them
for interface in vpls["interfaces"]:
for port in onos_config["ports"].values():
)
)
port["interfaces"].remove(port_interface)
+ # TODO: store host_id
+ # host_id = ""
+ # conn_service_host_list.append(f"{host_id}")
onos_config["apps"]["org.onosproject.vpls"]["vpls"][
"vplsList"
].remove(vpls)
self._pop_last_update_time(onos_config)
self._post_onos_netconfig(onos_config)
+ self._delete_onos_hosts(conn_service_host_list)
self.logger.debug(
"deleted connectivity service uuid: {}".format(service_uuid)
)
--- /dev/null
+#######################################################################################
+# Copyright ETSI Contributors and Others.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#######################################################################################
+---
+fixes:
+ - |
+ Fixing Bug 2019: This patch deletes the hosts in ONOS associated to a VPLS service.
+ Hosts are identified by its MAC and VLAN.