More publish-target-list pruning; including removal of Huawei drivers
Change-Id: Ice7c9a8141ea6d65fdbf45a706ba5d6918fa121d
diff --git a/drivers/huawei/BUILD b/drivers/huawei/BUILD
deleted file mode 100644
index bb473bc..0000000
--- a/drivers/huawei/BUILD
+++ /dev/null
@@ -1,45 +0,0 @@
-COMPILE_DEPS = CORE_DEPS + ONOS_YANG + [
- "@onos_yang_runtime//jar",
- "//models/l3vpn:onos-models-l3vpn",
- "//models/huawei:onos-models-huawei",
- "//drivers/utilities:onos-drivers-utilities",
- "//protocols/netconf/api:onos-protocols-netconf-api",
- "//apps/l3vpn:onos-apps-l3vpn",
- "//apps/config:onos-apps-config",
- "//apps/yang:onos-apps-yang",
- "//models/common:onos-models-common",
-]
-
-APPS = [
- "org.onosproject.yang",
- "org.onosproject.yang-gui",
- "org.onosproject.config",
- "org.onosproject.restconf",
- "org.onosproject.protocols.restconfserver",
- "org.onosproject.netconf",
- "org.onosproject.netconfsb",
- "org.onosproject.models.common",
- "org.onosproject.models.l3vpn",
- "org.onosproject.l3vpn",
- "org.onosproject.models.huawei",
-]
-
-TEST_DEPS = TEST_ADAPTERS + [
- "//utils/osgi:onlab-osgi-tests",
-]
-
-osgi_jar_with_tests(
- resources = glob(["src/main/resources/**"]),
- resources_root = "src/main/resources",
- test_deps = TEST_DEPS,
- deps = COMPILE_DEPS,
-)
-
-onos_app(
- app_name = "org.onosproject.drivers.huawei",
- category = "Drivers",
- description = "Adds support for Huawei devices.",
- required_apps = APPS,
- title = "Huawei Drivers",
- url = "http://onosproject.org",
-)
diff --git a/drivers/huawei/src/main/java/org/onosproject/drivers/huawei/BgpConstructionUtil.java b/drivers/huawei/src/main/java/org/onosproject/drivers/huawei/BgpConstructionUtil.java
deleted file mode 100644
index b385252..0000000
--- a/drivers/huawei/src/main/java/org/onosproject/drivers/huawei/BgpConstructionUtil.java
+++ /dev/null
@@ -1,441 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * 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.
- */
-
-package org.onosproject.drivers.huawei;
-
-import org.onosproject.l3vpn.netl3vpn.BgpDriverInfo;
-import org.onosproject.l3vpn.netl3vpn.BgpInfo;
-import org.onosproject.l3vpn.netl3vpn.ModelIdLevel;
-import org.onosproject.l3vpn.netl3vpn.ProtocolInfo;
-import org.onosproject.l3vpn.netl3vpn.RouteProtocol;
-import org.onosproject.yang.gen.v1.nebgpcomm.rev20141225.nebgpcomm.DefaultDevices;
-import org.onosproject.yang.gen.v1.nebgpcomm.rev20141225.nebgpcomm.Devices;
-import org.onosproject.yang.gen.v1.nebgpcomm.rev20141225.nebgpcomm.devices.DefaultDevice;
-import org.onosproject.yang.gen.v1.nebgpcomm.rev20141225.nebgpcomm.devices.Device;
-import org.onosproject.yang.gen.v1.nebgpcomm.rev20141225.nebgpcomm.devices.DeviceKeys;
-import org.onosproject.yang.gen.v1.nebgpcomm.rev20141225.nebgpcomm.devices.device.Bgp;
-import org.onosproject.yang.gen.v1.nebgpcomm.rev20141225.nebgpcomm.devices.device.DefaultBgp;
-import org.onosproject.yang.gen.v1.nebgpcomm.rev20141225.nebgpcomm.devices.device.bgp.Bgpcomm;
-import org.onosproject.yang.gen.v1.nebgpcomm.rev20141225.nebgpcomm.devices.device.bgp.DefaultBgpcomm;
-import org.onosproject.yang.gen.v1.nebgpcomm.rev20141225.nebgpcomm.devices.device.bgp.bgpcomm.BgpVrfs;
-import org.onosproject.yang.gen.v1.nebgpcomm.rev20141225.nebgpcomm.devices.device.bgp.bgpcomm.DefaultBgpVrfs;
-import org.onosproject.yang.gen.v1.nebgpcomm.rev20141225.nebgpcomm.devices.device.bgp.bgpcomm.bgpvrfs.BgpVrf;
-import org.onosproject.yang.gen.v1.nebgpcomm.rev20141225.nebgpcomm.devices.device.bgp.bgpcomm.bgpvrfs.BgpVrfKeys;
-import org.onosproject.yang.gen.v1.nebgpcomm.rev20141225.nebgpcomm.devices.device.bgp.bgpcomm.bgpvrfs.DefaultBgpVrf;
-import org.onosproject.yang.gen.v1.nebgpcomm.rev20141225.nebgpcomm.devices.device.bgp.bgpcomm.bgpvrfs.bgpvrf.BgpVrfAfs;
-import org.onosproject.yang.gen.v1.nebgpcomm.rev20141225.nebgpcomm.devices.device.bgp.bgpcomm.bgpvrfs.bgpvrf.DefaultBgpVrfAfs;
-import org.onosproject.yang.gen.v1.nebgpcomm.rev20141225.nebgpcomm.devices.device.bgp.bgpcomm.bgpvrfs.bgpvrf.bgpvrfafs.BgpVrfAf;
-import org.onosproject.yang.gen.v1.nebgpcomm.rev20141225.nebgpcomm.devices.device.bgp.bgpcomm.bgpvrfs.bgpvrf.bgpvrfafs.BgpVrfAfKeys;
-import org.onosproject.yang.gen.v1.nebgpcomm.rev20141225.nebgpcomm.devices.device.bgp.bgpcomm.bgpvrfs.bgpvrf.bgpvrfafs.DefaultBgpVrfAf;
-import org.onosproject.yang.gen.v1.nebgpcomm.rev20141225.nebgpcomm.devices.device.bgp.bgpcomm.bgpvrfs.bgpvrf.bgpvrfafs.bgpvrfaf.DefaultImportRoutes;
-import org.onosproject.yang.gen.v1.nebgpcomm.rev20141225.nebgpcomm.devices.device.bgp.bgpcomm.bgpvrfs.bgpvrf.bgpvrfafs.bgpvrfaf.ImportRoutes;
-import org.onosproject.yang.gen.v1.nebgpcomm.rev20141225.nebgpcomm.devices.device.bgp.bgpcomm.bgpvrfs.bgpvrf.bgpvrfafs.bgpvrfaf.importroutes.DefaultImportRoute;
-import org.onosproject.yang.gen.v1.nebgpcomm.rev20141225.nebgpcomm.devices.device.bgp.bgpcomm.bgpvrfs.bgpvrf.bgpvrfafs.bgpvrfaf.importroutes.ImportRoute;
-import org.onosproject.yang.gen.v1.nebgpcommtype.rev20141225.nebgpcommtype.BgpcommImRouteProtocol;
-import org.onosproject.yang.gen.v1.nebgpcommtype.rev20141225.nebgpcommtype.bgpcommimrouteprotocol.BgpcommImRouteProtocolEnum;
-import org.onosproject.yang.model.InnerModelObject;
-import org.onosproject.yang.model.ModelObjectData;
-import org.onosproject.yang.model.ModelObjectId;
-
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-import static org.onosproject.drivers.huawei.DriverUtil.UNSUPPORTED_MODEL_LVL;
-import static org.onosproject.drivers.huawei.DriverUtil.getData;
-import static org.onosproject.yang.gen.v1.nebgpcommtype.rev20141225.nebgpcommtype.BgpcommPrefixType.of;
-import static org.onosproject.yang.gen.v1.nebgpcommtype.rev20141225.nebgpcommtype.bgpcommimrouteprotocol.BgpcommImRouteProtocolEnum.DIRECT;
-import static org.onosproject.yang.gen.v1.nebgpcommtype.rev20141225.nebgpcommtype.bgpcommimrouteprotocol.BgpcommImRouteProtocolEnum.OSPF;
-import static org.onosproject.yang.gen.v1.nebgpcommtype.rev20141225.nebgpcommtype.bgpcommimrouteprotocol.BgpcommImRouteProtocolEnum.RIP;
-import static org.onosproject.yang.gen.v1.nebgpcommtype.rev20141225.nebgpcommtype.bgpcommimrouteprotocol.BgpcommImRouteProtocolEnum.RIPNG;
-import static org.onosproject.yang.gen.v1.nebgpcommtype.rev20141225.nebgpcommtype.bgpcommimrouteprotocol.BgpcommImRouteProtocolEnum.STATIC;
-import static org.onosproject.yang.gen.v1.nebgpcommtype.rev20141225.nebgpcommtype.bgpcommprefixtype.BgpcommPrefixTypeEnum.IPV4UNI;
-import static org.onosproject.yang.gen.v1.nebgpcommtype.rev20141225.nebgpcommtype.bgpcommprefixtype.BgpcommPrefixTypeEnum.IPV6UNI;
-
-/**
- * Representation of utility for BGP creation and deletion.
- */
-public final class BgpConstructionUtil {
-
- /**
- * Error message for unsupported protocol type.
- */
- private static final String UNSUPPORTED_PRO_TYPE = "Unsupported route " +
- "protocol type is found.";
-
- // No instantiation.
- private BgpConstructionUtil() {
- }
-
- /**
- * Returns the created model object data of BGP info of huawei device
- * from the standard model object data.
- *
- * @param bgpInfo device BGP info
- * @param config BGP driver info
- * @return driver model object data
- */
- static ModelObjectData getCreateBgp(BgpInfo bgpInfo,
- BgpDriverInfo config) {
- String devId = config.devId();
- ModelIdLevel modIdLevel = config.modIdLevel();
-
- Bgp bgp = new DefaultBgp();
- Bgpcomm bgpBuilder = new DefaultBgpcomm();
- BgpVrfs bgpVrfs = new DefaultBgpVrfs();
- BgpVrf bgpVrf = new DefaultBgpVrf();
- BgpVrfAfs bgpVrfAfs = new DefaultBgpVrfAfs();
- List<BgpVrf> bgpVrfList = new LinkedList<>();
-
- bgpVrf.vrfName(bgpInfo.vpnName());
- Map<RouteProtocol, ProtocolInfo> proMap = bgpInfo.protocolInfo();
- ImportRoute route = addRouteProtocol(proMap, bgpVrfAfs);
-
- bgpVrf.bgpVrfAfs(bgpVrfAfs);
- bgpVrfList.add(bgpVrf);
- bgpVrfs.bgpVrf(bgpVrfList);
- bgpBuilder.bgpVrfs(bgpVrfs);
- bgp.bgpcomm(bgpBuilder);
- return getModObjData(modIdLevel, bgp, devId, bgpVrf, route);
- }
-
- /**
- * Adds route protocol from the standard device model to the BGP address
- * family respectively.
- * //TODO: IPV6 has to be handled.
- *
- * @param proMap protocol map
- * @param bgpVrfAfs BGP address family
- * @return import route
- */
- private static ImportRoute addRouteProtocol(Map<RouteProtocol, ProtocolInfo> proMap,
- BgpVrfAfs bgpVrfAfs) {
- BgpVrfAf ipv4 = new DefaultBgpVrfAf();
- ImportRoutes ipv4Routes = new DefaultImportRoutes();
- ipv4.afType(of(IPV4UNI));
-
- ImportRoute route = null;
-
- BgpVrfAf ipv6 = new DefaultBgpVrfAf();
- ImportRoutes ipv6Routes = new DefaultImportRoutes();
- ipv6.afType(of(IPV6UNI));
- for (Map.Entry<RouteProtocol, ProtocolInfo> info : proMap.entrySet()) {
- RouteProtocol protocol = info.getKey();
- ProtocolInfo proInfo = info.getValue();
- if (proInfo.isIpv4Af()) {
- route = addImportRoute(ipv4Routes, proInfo, protocol);
- }
- if (proInfo.isIpv6Af()) {
- addImportRoute(ipv6Routes, proInfo, protocol);
- }
- }
- if (ipv4Routes.importRoute() != null &&
- !ipv4Routes.importRoute().isEmpty()) {
- addToBgpVrf(ipv4Routes, ipv4, bgpVrfAfs);
- }
- if (ipv6Routes.importRoute() != null &&
- !ipv6Routes.importRoute().isEmpty()) {
- addToBgpVrf(ipv6Routes, ipv6, bgpVrfAfs);
- }
- return route;
- }
-
- /**
- * Adds the routes to BGP VRF in driver model.
- *
- * @param routes routes
- * @param vrfAf VRF address family
- * @param bgpVrfAfs BGP address family
- */
- private static void addToBgpVrf(ImportRoutes routes, BgpVrfAf vrfAf,
- BgpVrfAfs bgpVrfAfs) {
- List<BgpVrfAf> ipList = new LinkedList<>();
- vrfAf.importRoutes(routes);
- ipList.add(vrfAf);
- bgpVrfAfs.bgpVrfAf(ipList);
- }
-
- /**
- * Adds the import route to the routes, according to the protocol info
- * from the standard device model.
- *
- * @param routes routes object
- * @param proInfo protocol info
- * @param protocol route protocol
- * @return import route object
- */
- private static ImportRoute addImportRoute(ImportRoutes routes,
- ProtocolInfo proInfo,
- RouteProtocol protocol) {
- List<ImportRoute> routeList = new LinkedList<>();
- ImportRoute route = buildAfBgp(proInfo, protocol);
- routeList.add(route);
- routes.importRoute(routeList);
- return route;
- }
-
- /**
- * Builds the import route details from the route protocol and the
- * process id.
- *
- * @param proInfo protocol info
- * @param protocol route protocol
- * @return import route object
- */
- private static ImportRoute buildAfBgp(ProtocolInfo proInfo,
- RouteProtocol protocol) {
- BgpcommImRouteProtocolEnum rpEnum = getProtocolType(protocol);
- ImportRoute impRoute = new DefaultImportRoute();
- impRoute.importProcessId(proInfo.processId());
- impRoute.importProtocol(BgpcommImRouteProtocol.of(rpEnum));
- return impRoute;
- }
-
- /**
- * Returns the huawei route protocol corresponding to standard device
- * route protocol.
- *
- * @param protocol device route protocol
- * @return driver route protocol
- */
- private static BgpcommImRouteProtocolEnum getProtocolType(RouteProtocol protocol) {
- switch (protocol) {
- case DIRECT:
- return DIRECT;
-
- case OSPF:
- return OSPF;
-
- case RIP:
- return RIP;
-
- case RIP_NG:
- return RIPNG;
-
- case STATIC:
- return STATIC;
-
- case BGP:
- case VRRP:
- default:
- throw new IllegalArgumentException(UNSUPPORTED_PRO_TYPE);
- }
- }
-
- /**
- * Returns the driver model object data, according to the levels it has
- * to be constructed.
- *
- * @param modIdLevel model id level
- * @param bgp driver BGP object
- * @param devId device id
- * @param bgpVrf driver BGP VRF object
- * @param route import route object
- * @return model object data
- */
- public static ModelObjectData getModObjData(ModelIdLevel modIdLevel,
- Bgp bgp, String devId,
- BgpVrf bgpVrf, ImportRoute route) {
- switch (modIdLevel) {
-
- case VPN:
- return getRouteProModObj(bgpVrf.vrfName(), route, devId);
-
- case ROOT:
- return getRootModObj(bgp, devId);
-
- case DEVICES:
- return getDevicesModObj(bgp, devId);
-
- case DEVICE:
- return getDevModObj(bgpVrf, devId);
-
- default:
- throw new IllegalArgumentException(UNSUPPORTED_MODEL_LVL);
- }
- }
-
- /**
- * Returns the model object data of route protocol.
- *
- * @param vpnName VPN name
- * @param route import route
- * @param devId device id
- * @return model object data
- */
- private static ModelObjectData getRouteProModObj(String vpnName,
- ImportRoute route,
- String devId) {
- DeviceKeys key = new DeviceKeys();
- key.deviceid(devId);
- BgpVrfKeys vpnKey = new BgpVrfKeys();
- vpnKey.vrfName(vpnName);
- BgpVrfAfKeys afKey = new BgpVrfAfKeys();
- afKey.afType(of(IPV4UNI));
- ModelObjectId id = ModelObjectId.builder()
- .addChild(DefaultDevices.class)
- .addChild(DefaultDevice.class, key)
- .addChild(DefaultBgp.class)
- .addChild(DefaultBgpcomm.class)
- .addChild(DefaultBgpVrfs.class)
- .addChild(DefaultBgpVrf.class, vpnKey)
- .addChild(DefaultBgpVrfAfs.class)
- .addChild(DefaultBgpVrfAf.class, afKey)
- .addChild(DefaultImportRoutes.class).build();
- return getData(id, (InnerModelObject) route);
- }
-
- /**
- * Returns the driver model object data with device in model object id,
- * till BGP VRF.
- *
- * @param bgpVrf BGP VRF object
- * @param devId device id
- * @return model object data
- */
- private static ModelObjectData getDevModObj(BgpVrf bgpVrf, String devId) {
- DeviceKeys key = new DeviceKeys();
- key.deviceid(devId);
- ModelObjectId id = ModelObjectId.builder()
- .addChild(DefaultDevices.class)
- .addChild(DefaultDevice.class, key)
- .addChild(DefaultBgp.class)
- .addChild(DefaultBgpcomm.class)
- .addChild(DefaultBgpVrfs.class).build();
- return getData(id, (InnerModelObject) bgpVrf);
- }
-
- /**
- * Returns the driver model object data with devices in model object id.
- *
- * @param bgp BGP object
- * @param devId device id
- * @return model object data
- */
- private static ModelObjectData getDevicesModObj(Bgp bgp, String devId) {
- ModelObjectId modelId = ModelObjectId.builder()
- .addChild(DefaultDevices.class).build();
- Device device = getDevInfo(bgp, devId);
- return getData(modelId, (InnerModelObject) device);
- }
-
- /**
- * Returns the driver root model object without model object id.
- *
- * @param bgp driver BGP
- * @param devId device id
- * @return model object data
- */
- private static ModelObjectData getRootModObj(Bgp bgp, String devId) {
- Devices devices = new DefaultDevices();
- List<Device> devList = new LinkedList<>();
- Device device = getDevInfo(bgp, devId);
- devList.add(device);
- devices.device(devList);
- return getData(null, (InnerModelObject) devices);
- }
-
- /**
- * Returns the driver BGP from the device object.
- *
- * @param bgp BGP object
- * @param devId device id
- * @return device object
- */
- private static Device getDevInfo(Bgp bgp, String devId) {
- Device device = new DefaultDevice();
- device.deviceid(devId);
- device.bgp(bgp);
- return device;
- }
-
- /**
- * Returns the BGP model object data for deletion.
- *
- * @param bgpInfo BGP info
- * @param bgpConfig BGP driver config
- * @return model object data
- */
- static ModelObjectData getDeleteBgp(BgpInfo bgpInfo,
- BgpDriverInfo bgpConfig) {
- ModelIdLevel modIdLvl = bgpConfig.modIdLevel();
- switch (modIdLvl) {
- case ROOT:
- return getDelRootModObj();
-
- case DEVICES:
- return getDelDevicesModObj(bgpConfig.devId());
-
- case DEVICE:
- return getDelDeviceModObj(bgpConfig.devId(), bgpInfo.vpnName());
-
- default:
- throw new IllegalArgumentException(UNSUPPORTED_MODEL_LVL);
- }
- }
-
- /**
- * Returns the model object data with respect to device level.
- *
- * @param devId device id
- * @param vpnName VPN name
- * @return model object data
- */
- private static ModelObjectData getDelDeviceModObj(String devId,
- String vpnName) {
- DeviceKeys devKeys = new DeviceKeys();
- devKeys.deviceid(devId);
- BgpVrfKeys vpnKey = new BgpVrfKeys();
- vpnKey.vrfName(vpnName);
- ModelObjectId modelId = ModelObjectId.builder()
- .addChild(DefaultDevices.class)
- .addChild(DefaultDevice.class, devKeys)
- .addChild(DefaultBgp.class)
- .addChild(DefaultBgpcomm.class)
- .addChild(DefaultBgpVrfs.class)
- .addChild(DefaultBgpVrf.class, vpnKey).build();
- DefaultBgpVrfAfs afs = new DefaultBgpVrfAfs();
- return getData(modelId, afs);
- }
-
- /**
- * Returns the model object data with respect to root level.
- *
- * @return model object data
- */
- private static ModelObjectData getDelRootModObj() {
- DefaultDevice device = new DefaultDevice();
- ModelObjectId modelId = ModelObjectId.builder().addChild(
- DefaultDevices.class).build();
- return getData(modelId, device);
- }
-
- /**
- * Returns the model object data for devices level.
- *
- * @param id device id
- * @return model object data
- */
- private static ModelObjectData getDelDevicesModObj(String id) {
- DeviceKeys devKeys = new DeviceKeys();
- devKeys.deviceid(id);
- ModelObjectId modelId = ModelObjectId.builder()
- .addChild(DefaultDevices.class)
- .addChild(DefaultDevice.class, devKeys).build();
- DefaultBgp bgp = new DefaultBgp();
- return getData(modelId, bgp);
- }
-}
diff --git a/drivers/huawei/src/main/java/org/onosproject/drivers/huawei/DriverUtil.java b/drivers/huawei/src/main/java/org/onosproject/drivers/huawei/DriverUtil.java
deleted file mode 100644
index b7b0fae..0000000
--- a/drivers/huawei/src/main/java/org/onosproject/drivers/huawei/DriverUtil.java
+++ /dev/null
@@ -1,248 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * 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.
- */
-
-package org.onosproject.drivers.huawei;
-
-import org.onosproject.yang.gen.v1.nel3vpnapi.rev20141225.nel3vpnapi.DefaultDevices;
-import org.onosproject.yang.gen.v1.ietfinterfaces.rev20140508.ietfinterfaces.devices.DeviceKeys;
-import org.onosproject.yang.model.AtomicPath;
-import org.onosproject.yang.model.DefaultModelObjectData;
-import org.onosproject.yang.model.InnerModelObject;
-import org.onosproject.yang.model.KeyInfo;
-import org.onosproject.yang.model.ModelObject;
-import org.onosproject.yang.model.ModelObjectData;
-import org.onosproject.yang.model.ModelObjectId;
-import org.onosproject.yang.model.MultiInstanceNode;
-
-import java.util.Iterator;
-import java.util.List;
-
-import static org.onosproject.drivers.huawei.L3VpnUtil.getDevIdFromIns;
-
-/**
- * Representation of utility for huawei driver.
- */
-public final class DriverUtil {
-
- /**
- * Static constant value for devices.
- */
- static final String CONS_DEVICES = "Devices";
-
- /**
- * Error message for YANG model registry service not found.
- */
- static final String SERVICE_NOT_FOUND = "Service required for huawei " +
- "driver is not found.";
-
- /**
- * Error message for object from the standard device model being null.
- */
- static final String OBJECT_NULL = "Object from device model cannot be null";
-
- /**
- * Error message for device object under devices from the standard model
- * being null.
- */
- static final String DEVICE_NULL = "Device object from the devices of " +
- "standard device model cannot be null";
-
- /**
- * Error message for device object under devices from the standard model
- * being null.
- */
- static final String INS_NULL = "Instance object from the instances of " +
- "standard device model cannot be null";
-
- /**
- * Error message for unsupported model id level.
- */
- static final String UNSUPPORTED_MODEL_LVL = "The model id level is not " +
- "supported";
-
- /**
- * Error message for failure of device info retrieval.
- */
- static final String DEV_INFO_FAILURE = "Failed to retrieve device info.";
-
- /**
- * Error message for failure of interface info retrieval.
- */
- static final String INT_INFO_FAILURE = "Failed to retrieve Interfaces";
-
- /**
- * RPC message header.
- */
- static final String RPC_MSG = "<rpc message-id=\"101\" xmlns=\"urn:ietf:" +
- "params:xml:ns:netconf:base:1.0\">";
-
- /**
- * RPC get message.
- */
- static final String RPC_GET = "<get>";
-
- /**
- * RPC subtree filter message.
- */
- static final String RPC_FILTER = "<filter type=\"subtree\">";
-
- /**
- * RPC system message with namespace.
- */
- static final String RPC_SYS = "<system xmlns=\"http://www.huawei.com/" +
- "netconf/vrp\" format-version=\"1.0\" content-version=\"1.0\"/>";
-
- /**
- * RPC ifm message with namespace.
- */
- static final String RPC_IFM = "<ifm xmlns=\"http://www.huawei.com" +
- "/netconf/vrp\" format-version=\"1.0\" content-version=\"1.0\">";
-
- /**
- * RPC interfaces message.
- */
- static final String RPC_IFS = "<interfaces><interface><ifPhyType>Ethernet" +
- "</ifPhyType><ifName></ifName><ifNumber></ifNumber>" +
- "<ifDynamicInfo></ifDynamicInfo><ifStatistics></ifStatistics>" +
- "</interface></interfaces>";
-
- /**
- * RPC ifm message.
- */
- static final String RPC_CLOSE_IFM = "</ifm>";
-
- /**
- * RPC filter close message.
- */
- static final String RPC_CLOSE_FILTER = "</filter>";
-
- /**
- * RPC close message.
- */
- static final String RPC_CLOSE = "</rpc>";
-
- /**
- * RPC get close message.
- */
- static final String RPC_CLOSE_GET = "</get>";
-
- /**
- * Static constant for slash.
- */
- static final String SLASH = "/";
-
- /**
- * Static constant for devices name.
- */
- static final String DEVICES = "devices";
-
- /**
- * Static constant for devices namespace.
- */
- static final String NAMESPACE = "ne-l3vpn-api";
-
- /**
- * Error message for model object id having more than two objects.
- */
- private static final String MODEL_OBJ_ID_LIMIT = "The model object id " +
- "must not have more than two objects.";
-
- // No instantiation.
- private DriverUtil() {
- }
-
- /**
- * Returns the device id from the model object id. If model object id is
- * not present then null is returned. If only one path is available in
- * the list then devices value is returned.
- *
- * @param id model object id
- * @param isIns if for VPN instance
- * @return device id
- */
- static String getIdFromModId(ModelObjectId id, boolean isIns) {
- if (id == null) {
- return null;
- }
- List<AtomicPath> paths = id.atomicPaths();
- int size = paths.size();
-
- switch (size) {
- case 1:
- return CONS_DEVICES;
-
- case 2:
- return getDevId(paths, isIns);
-
- default:
- throw new IllegalArgumentException(MODEL_OBJ_ID_LIMIT);
- }
- }
-
- /**
- * Returns the device id from the model object id's key info.
- *
- * @param paths atomic path list
- * @param isIns if VPN instance
- * @return device id
- */
- private static String getDevId(List<AtomicPath> paths, boolean isIns) {
- MultiInstanceNode info = (MultiInstanceNode) paths.get(1);
- KeyInfo key = info.key();
- if (!isIns) {
- return ((DeviceKeys) key).deviceid();
- }
- return getDevIdFromIns(key);
- }
-
- /**
- * Returns the first object from the model object data. If no objects are
- * present then it returns null.
- *
- * @param modData model object data
- * @return object
- */
- static Object getObjFromModData(ModelObjectData modData) {
- List<ModelObject> obj = modData.modelObjects();
- Iterator<ModelObject> it = obj.iterator();
- if (it.hasNext()) {
- return it.next();
- }
- return null;
- }
-
- /**
- * Returns the model object id for with the devices object added to it.
- *
- * @return model object id
- */
- static ModelObjectId getModObjIdDriDevices() {
- return ModelObjectId.builder().addChild(DefaultDevices.class).build();
- }
-
- /**
- * Returns model object data built from the object that has to be added
- * and the model object id.
- *
- * @param id model object id
- * @param obj object
- * @return model object data
- */
- static ModelObjectData getData(ModelObjectId id, InnerModelObject obj) {
- return DefaultModelObjectData.builder().addModelObject(obj)
- .identifier(id).build();
- }
-}
diff --git a/drivers/huawei/src/main/java/org/onosproject/drivers/huawei/HuaweiDeviceDescription.java b/drivers/huawei/src/main/java/org/onosproject/drivers/huawei/HuaweiDeviceDescription.java
deleted file mode 100644
index 5162b48..0000000
--- a/drivers/huawei/src/main/java/org/onosproject/drivers/huawei/HuaweiDeviceDescription.java
+++ /dev/null
@@ -1,203 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * 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.
- */
-
-package org.onosproject.drivers.huawei;
-
-import com.google.common.collect.ImmutableList;
-import org.apache.commons.lang.StringUtils;
-import org.onosproject.net.Device;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.device.DefaultDeviceDescription;
-import org.onosproject.net.device.DeviceDescription;
-import org.onosproject.net.device.DeviceDescriptionDiscovery;
-import org.onosproject.net.device.DeviceService;
-import org.onosproject.net.device.PortDescription;
-import org.onosproject.net.device.PortStatistics;
-import org.onosproject.net.device.PortStatisticsDiscovery;
-import org.onosproject.net.driver.AbstractHandlerBehaviour;
-import org.onosproject.netconf.NetconfController;
-import org.onosproject.netconf.NetconfException;
-import org.onosproject.netconf.NetconfSession;
-import org.slf4j.Logger;
-
-import java.util.Collection;
-import java.util.List;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.onosproject.drivers.huawei.DriverUtil.DEV_INFO_FAILURE;
-import static org.onosproject.drivers.huawei.DriverUtil.RPC_CLOSE;
-import static org.onosproject.drivers.huawei.DriverUtil.RPC_CLOSE_FILTER;
-import static org.onosproject.drivers.huawei.DriverUtil.RPC_CLOSE_GET;
-import static org.onosproject.drivers.huawei.DriverUtil.RPC_CLOSE_IFM;
-import static org.onosproject.drivers.huawei.DriverUtil.RPC_FILTER;
-import static org.onosproject.drivers.huawei.DriverUtil.RPC_GET;
-import static org.onosproject.drivers.huawei.DriverUtil.RPC_IFM;
-import static org.onosproject.drivers.huawei.DriverUtil.RPC_IFS;
-import static org.onosproject.drivers.huawei.DriverUtil.RPC_MSG;
-import static org.onosproject.drivers.huawei.DriverUtil.RPC_SYS;
-import static org.onosproject.net.Device.Type.ROUTER;
-import static org.slf4j.LoggerFactory.getLogger;
-
-/**
- * Representation of device information and ports via NETCONF for huawei
- * routers.
- */
-public class HuaweiDeviceDescription extends AbstractHandlerBehaviour
- implements PortStatisticsDiscovery, DeviceDescriptionDiscovery {
-
- private final Logger log = getLogger(getClass());
-
- /**
- * Constructs huawei device description.
- */
- public HuaweiDeviceDescription() {
- }
-
- /**
- * Discovers device details, for huawei device by getting the system
- * information.
- *
- * @return device description
- */
- @Override
- public DeviceDescription discoverDeviceDetails() {
- NetconfSession session = getNetconfSession();
- String sysInfo;
- try {
- sysInfo = session.get(getVersionReq());
- } catch (NetconfException e) {
- throw new IllegalArgumentException(
- new NetconfException(DEV_INFO_FAILURE));
- }
-
- String[] details = parseSysInfoXml(sysInfo);
- DeviceService devSvc = checkNotNull(handler().get(DeviceService.class));
- DeviceId devId = handler().data().deviceId();
- Device dev = devSvc.getDevice(devId);
- return new DefaultDeviceDescription(dev.id().uri(), ROUTER,
- details[0], details[1],
- details[2], details[3],
- dev.chassisId());
- }
-
- /**
- * Discovers interface details, for huawei device.
- *
- * @return port list
- */
- @Override
- public List<PortDescription> discoverPortDetails() {
- return ImmutableList.copyOf(parseInterfaceXml(getInterfaces()));
- }
-
- /**
- * Returns the NETCONF session of the device.
- *
- * @return session
- */
- private NetconfSession getNetconfSession() {
- NetconfController controller = checkNotNull(
- handler().get(NetconfController.class));
- return controller.getDevicesMap().get(handler().data().deviceId())
- .getSession();
- }
-
- /**
- * Returns the rpc request message for fetching system details in huawei
- * device.
- *
- * @return rpc request message
- */
- private String getVersionReq() {
- StringBuilder rpc = new StringBuilder(RPC_MSG);
- rpc.append(RPC_GET);
- rpc.append(RPC_FILTER);
- rpc.append(RPC_SYS);
- rpc.append(RPC_CLOSE_FILTER);
- rpc.append(RPC_CLOSE_GET);
- rpc.append(RPC_CLOSE);
- return rpc.toString();
- }
-
- /**
- * Parses system info received from huawei device.
- *
- * @param sysInfo system info
- * @return parsed values
- */
- private String[] parseSysInfoXml(String sysInfo) {
- HuaweiXmlParser parser = new HuaweiXmlParser(sysInfo);
- parser.parseSysInfo();
- return parser.getInfo();
- }
-
- /**
- * Returns the rpc request message for fetching interface details in
- * huawei device.
- *
- * @return rpc request message
- */
- private String getInterfacesReq() {
- StringBuilder rpc = new StringBuilder(RPC_MSG);
- rpc.append(RPC_GET);
- rpc.append(RPC_FILTER);
- rpc.append(RPC_IFM);
- rpc.append(RPC_IFS);
- rpc.append(RPC_CLOSE_IFM);
- rpc.append(RPC_CLOSE_FILTER);
- rpc.append(RPC_CLOSE_GET);
- rpc.append(RPC_CLOSE);
- return rpc.toString();
- }
-
- /**
- * Parses interfaces received from huawei device.
- *
- * @param interfaces interfaces
- * @return port list
- */
- private List<PortDescription> parseInterfaceXml(String interfaces) {
- HuaweiXmlParser parser = new HuaweiXmlParser(interfaces);
- parser.parseInterfaces();
- return parser.getPorts();
- }
-
- @Override
- public Collection<PortStatistics> discoverPortStatistics() {
- String interfaces = getInterfaces();
- if (StringUtils.isNotBlank(interfaces)) {
- Collection<PortStatistics> portStats = getPortStatistics(interfaces);
- return ImmutableList.copyOf(portStats);
- }
- return null;
- }
-
- private String getInterfaces() {
- NetconfSession session = getNetconfSession();
- String interfaces = null;
- try {
- interfaces = session.get(getInterfacesReq());
- } catch (NetconfException e) {
- log.info("Failed to retrive interface {} ", e.getMessage());
- }
- return interfaces;
- }
-
- private Collection<PortStatistics> getPortStatistics(String ifs) {
- HuaweiXmlParser parser = new HuaweiXmlParser(ifs);
- return parser.parsePortsStatistics(handler().data().deviceId());
- }
-}
diff --git a/drivers/huawei/src/main/java/org/onosproject/drivers/huawei/HuaweiDriversLoader.java b/drivers/huawei/src/main/java/org/onosproject/drivers/huawei/HuaweiDriversLoader.java
deleted file mode 100644
index 79f1b9e..0000000
--- a/drivers/huawei/src/main/java/org/onosproject/drivers/huawei/HuaweiDriversLoader.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * 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.
- */
-
-package org.onosproject.drivers.huawei;
-
-import org.osgi.service.component.annotations.Component;
-import org.onosproject.net.driver.AbstractDriverLoader;
-
-/**
- * Loader for Huawei device drivers.
- */
-@Component(immediate = true)
-public class HuaweiDriversLoader extends AbstractDriverLoader {
- public HuaweiDriversLoader() {
- super("/huawei-drivers.xml");
- }
-}
diff --git a/drivers/huawei/src/main/java/org/onosproject/drivers/huawei/HuaweiL3VpnConfig.java b/drivers/huawei/src/main/java/org/onosproject/drivers/huawei/HuaweiL3VpnConfig.java
deleted file mode 100644
index 2c08d36..0000000
--- a/drivers/huawei/src/main/java/org/onosproject/drivers/huawei/HuaweiL3VpnConfig.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * 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.
- */
-
-package org.onosproject.drivers.huawei;
-
-import org.onlab.osgi.ServiceNotFoundException;
-import org.onosproject.config.DynamicConfigService;
-import org.onosproject.config.FailedException;
-import org.onosproject.l3vpn.netl3vpn.BgpDriverInfo;
-import org.onosproject.l3vpn.netl3vpn.BgpInfo;
-import org.onosproject.l3vpn.netl3vpn.L3VpnConfig;
-import org.onosproject.l3vpn.netl3vpn.TunnelInfo;
-import org.onosproject.net.driver.AbstractHandlerBehaviour;
-import org.onosproject.yang.model.DataNode;
-import org.onosproject.yang.model.ModelObjectData;
-import org.onosproject.yang.model.ResourceId;
-import org.onosproject.yang.runtime.YangModelRegistry;
-
-import static org.onosproject.drivers.huawei.BgpConstructionUtil.getCreateBgp;
-import static org.onosproject.drivers.huawei.BgpConstructionUtil.getDeleteBgp;
-import static org.onosproject.drivers.huawei.DriverUtil.DEVICES;
-import static org.onosproject.drivers.huawei.DriverUtil.NAMESPACE;
-import static org.onosproject.drivers.huawei.DriverUtil.SERVICE_NOT_FOUND;
-import static org.onosproject.drivers.huawei.DriverUtil.SLASH;
-import static org.onosproject.drivers.huawei.InsConstructionUtil.getCreateVpnIns;
-import static org.onosproject.drivers.huawei.InsConstructionUtil.getDeleteVpnIns;
-import static org.onosproject.drivers.huawei.IntConstructionUtil.getCreateInt;
-import static org.onosproject.drivers.huawei.TnlConstructionUtil.getBindTnl;
-import static org.onosproject.drivers.huawei.TnlConstructionUtil.getCreateTnl;
-import static org.onosproject.drivers.huawei.TnlConstructionUtil.getCreateTnlDev;
-import static org.onosproject.drivers.huawei.TnlConstructionUtil.getCreateTnlPol;
-import static org.onosproject.drivers.huawei.TnlConstructionUtil.getDeleteTnl;
-
-/**
- * Configures l3vpn on Huawei devices.
- */
-public class HuaweiL3VpnConfig extends AbstractHandlerBehaviour
- implements L3VpnConfig {
-
- /**
- * YANG model registry.
- */
- protected YangModelRegistry modelRegistry;
-
- /**
- * Dynamic config service.
- */
- protected DynamicConfigService configService;
-
- /**
- * Constructs huawei L3VPN config.
- */
- public HuaweiL3VpnConfig() {
- }
-
- /**
- * Takes the YANG model registry service and registers the driver YANG.
- * If service is not available it throws exception.
- */
- private void init() {
- try {
- modelRegistry = handler().get(YangModelRegistry.class);
- configService = handler().get(DynamicConfigService.class);
- } catch (ServiceNotFoundException e) {
- throw new ServiceNotFoundException(SERVICE_NOT_FOUND);
- }
- }
-
- @Override
- public ModelObjectData createInstance(ModelObjectData objectData) {
- if (modelRegistry == null) {
- init();
- }
- return getCreateVpnIns(objectData, isDevicesPresent());
- }
-
- @Override
- public ModelObjectData bindInterface(ModelObjectData objectData) {
- return getCreateInt(objectData);
- }
-
- @Override
- public ModelObjectData createBgpInfo(BgpInfo bgpInfo,
- BgpDriverInfo bgpConfig) {
- return getCreateBgp(bgpInfo, bgpConfig);
- }
-
- @Override
- public ModelObjectData createTnlDev(TunnelInfo tnlInfo) {
- return getCreateTnlDev(tnlInfo);
- }
-
- @Override
- public ModelObjectData createTnlPol(TunnelInfo tnlInfo) {
- return getCreateTnlPol(tnlInfo);
- }
-
- @Override
- public ModelObjectData createTnl(TunnelInfo tnlInfo) {
- return getCreateTnl(tnlInfo);
- }
-
- @Override
- public ModelObjectData bindTnl(TunnelInfo tnlInfo) {
- return getBindTnl(tnlInfo);
- }
-
- @Override
- public ModelObjectData deleteInstance(ModelObjectData objectData) {
- return getDeleteVpnIns(objectData);
- }
-
- @Override
- public ModelObjectData unbindInterface(ModelObjectData objectData) {
- //TODO:To be committed.
- return null;
- }
-
- @Override
- public ModelObjectData deleteTnl(TunnelInfo tnlInfo) {
- return getDeleteTnl(tnlInfo);
- }
-
- @Override
- public ModelObjectData deleteBgpInfo(BgpInfo bgpInfo,
- BgpDriverInfo bgpConfig) {
- return getDeleteBgp(bgpInfo, bgpConfig);
- }
-
- /**
- * Returns true if devices, which is the root node present in store;
- * false otherwise.
- *
- * @return true if devices available; false otherwise
- */
- private boolean isDevicesPresent() {
- ResourceId resId = ResourceId.builder()
- .addBranchPointSchema(SLASH, null)
- .addBranchPointSchema(DEVICES, NAMESPACE).build();
- try {
- DataNode node = configService.readNode(resId, null);
- if (node != null) {
- return true;
- }
- } catch (FailedException e) {
- return false;
- }
- return false;
- }
-}
diff --git a/drivers/huawei/src/main/java/org/onosproject/drivers/huawei/HuaweiXmlParser.java b/drivers/huawei/src/main/java/org/onosproject/drivers/huawei/HuaweiXmlParser.java
deleted file mode 100644
index 159d180..0000000
--- a/drivers/huawei/src/main/java/org/onosproject/drivers/huawei/HuaweiXmlParser.java
+++ /dev/null
@@ -1,277 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * 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.
- */
-
-package org.onosproject.drivers.huawei;
-
-import com.google.common.collect.Lists;
-import org.dom4j.Document;
-import org.dom4j.DocumentException;
-import org.dom4j.DocumentHelper;
-import org.dom4j.Element;
-import org.onosproject.net.DefaultAnnotations;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.PortNumber;
-import org.onosproject.net.device.DefaultPortDescription;
-import org.onosproject.net.device.DefaultPortStatistics;
-import org.onosproject.net.device.PortDescription;
-import org.onosproject.net.device.PortStatistics;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-
-import static org.onosproject.net.AnnotationKeys.PORT_NAME;
-import static org.onosproject.net.Port.Type.COPPER;
-import static org.onosproject.net.PortNumber.portNumber;
-
-/**
- * Representation of Huawei XML parser.
- */
-public final class HuaweiXmlParser {
-
- private static final String DATA = "data";
- private static final String IFM = "ifm";
- private static final String IFS = "interfaces";
- private static final String IF = "interface";
- private static final String IF_TYPE = "ifPhyType";
- private static final String IF_STATS = "ifStatistics";
- private static final String IF_STAT = "ifPhyStatus";
- private static final String IF_NUM = "ifNumber";
- private static final String IF_SPEED = "ifOperSpeed";
- private static final String IF_NAME = "ifName";
- private static final String UP = "up";
- private static final String DYN_INFO = "ifDynamicInfo";
- private static final String DELIMITER = "/";
- private static final String SYS = "system";
- private static final String SYS_INFO = "systemInfo";
- private static final String SYS_NAME = "sysName";
- private static final String PDT_VER = "productVer";
- private static final String PLATFORM_VER = "platformVer";
- private static final String SYS_ID = "sysObjectId";
- private static final String P_RCVD = "receivePacket";
- private static final String P_SENT = "sendPacket";
- private static final String B_RCVD = "receiveByte";
- private static final String B_SENT = "sendByte";
- private static final String RX_DROP = "rcvDropPacket";
- private static final String TX_DROP = "sendDropPacket";
- private static final String RX_ERROR = "rcvErrorPacket";
- private static final String TX_ERROR = "sendErrorPacket";
-
- private static final String DEV_PARSE_ERR = "Unable to parse the received" +
- " xml reply for system details from the huawei device";
- private static final String INT_PARSE_ERR = "Unable to parse the received" +
- " xml reply for interface details from the huawei device";
- private static final String P_NAME_INVALID = "Invalid port name.";
-
- //TODO: All type of interfaces has to be added.
- private static final List INTERFACES = Arrays.asList(
- "MEth", "Ethernet", "POS", "GigabitEthernet");
-
- private List<PortDescription> ports = new ArrayList<>();
- private String xml;
- private int portInc;
- private String[] info = new String[4];
-
- /**
- * Constructs huawei XML parser with xml reply.
- *
- * @param xml xml reply
- */
- public HuaweiXmlParser(String xml) {
- this.xml = xml;
- }
-
- /**
- * Returns the system info.
- *
- * @return system info
- */
- String[] getInfo() {
- return info;
- }
-
- /**
- * Returns the port list.
- *
- * @return port list
- */
- List<PortDescription> getPorts() {
- return ports;
- }
-
- /**
- * Parses system info xml reply.
- */
- void parseSysInfo() {
- Document doc;
- try {
- doc = DocumentHelper.parseText(xml);
- } catch (DocumentException e) {
- throw new IllegalArgumentException(DEV_PARSE_ERR);
- }
-
- Element root = doc.getRootElement();
- Element parent = root.element(DATA).element(SYS).element(SYS_INFO);
- info[0] = parent.element(SYS_NAME).getText();
- info[1] = parent.element(PDT_VER).getText();
- info[2] = parent.element(PLATFORM_VER).getText();
- info[3] = parent.element(SYS_ID).getText();
- }
-
- /**
- * Parses interface xml reply and creates ports to be updated.
- */
- void parseInterfaces() {
- Iterator itr = getInterfaceIterator();
- while (itr.hasNext()) {
- Element ifElement = (Element) itr.next();
- addPorts(ifElement);
- }
- }
-
- private Iterator getInterfaceIterator() {
- Document doc;
- try {
- doc = DocumentHelper.parseText(xml);
- } catch (DocumentException e) {
- throw new IllegalArgumentException(INT_PARSE_ERR);
- }
- Element root = doc.getRootElement();
- Element parent = root.element(DATA).element(IFM).element(IFS);
- return parent.elementIterator(IF);
- }
-
- /**
- * Adds port information to the port list from the xml reply.
- *
- * @param ifElement interface element
- */
- private void addPorts(Element ifElement) {
- String ifType = ifElement.element(IF_TYPE).getText();
-
- if (INTERFACES.contains(ifType)) {
- Element info = ifElement.element(DYN_INFO);
- String status = info.element(IF_STAT).getText();
- String port = getPortNum(ifElement.element(IF_NUM).getText());
- String speed = info.element(IF_SPEED).getText();
- String ifName = ifElement.element(IF_NAME).getText();
-
- boolean isEnabled = false;
- if (status.equals(UP)) {
- isEnabled = true;
- }
-
- Long portSpeed = 0L;
- if (!speed.isEmpty()) {
- portSpeed = Long.valueOf(speed);
- }
-
- DefaultAnnotations annotations = DefaultAnnotations.builder()
- .set(PORT_NAME, ifName).build();
- ports.add(DefaultPortDescription.builder()
- .withPortNumber(portNumber(port))
- .isEnabled(isEnabled)
- .type(COPPER)
- .portSpeed(portSpeed)
- .annotations(annotations)
- .build());
- }
- }
-
- /**
- * Returns port number from the port name. As many type of port can have
- * same port number, each port number will be prepended with a incrementing
- * number to make it unique in the list.
- *
- * @param portName port name
- * @return port number
- */
- private String getPortNum(String portName) {
- String port;
- if (!portName.contains(DELIMITER)) {
- portInc++;
- port = String.valueOf(portInc) + portName;
- } else if (portName.contains(DELIMITER)) {
- try {
- port = portName.substring(
- portName.lastIndexOf(DELIMITER) + 1);
- portInc++;
- port = String.valueOf(portInc) + port;
- } catch (StringIndexOutOfBoundsException e) {
- throw new IllegalArgumentException(P_NAME_INVALID);
- }
- } else {
- throw new IllegalArgumentException(P_NAME_INVALID);
- }
- return port;
- }
-
- /**
- * Returns port statistics information for a device.
- *
- * @param deviceId device for which port statistics to be fetched
- * @return port statistics
- */
- Collection<PortStatistics> parsePortsStatistics(DeviceId deviceId) {
- Collection<PortStatistics> pss = Lists.newArrayList();
- Iterator itr = getInterfaceIterator();
- while (itr.hasNext()) {
- Element ifElement = (Element) itr.next();
- pss.add(getPortStatistics(ifElement, deviceId));
- }
- return pss;
- }
-
- private PortStatistics getPortStatistics(Element ifElement, DeviceId id) {
- String ifType = ifElement.element(IF_TYPE).getText();
-
- DefaultPortStatistics.Builder builder = DefaultPortStatistics.builder();
-
- if (INTERFACES.contains(ifType)) {
- int port = Integer.parseInt(getPortNum(ifElement.element(IF_NUM)
- .getText()));
- Element statInfo = ifElement.element(IF_STATS);
- long packetReceived = Long.parseLong(statInfo.element(P_RCVD)
- .getText());
- long packetSent = Long.parseLong(statInfo.element(P_SENT).getText());
- long bytesReceived = Long.parseLong(statInfo.element(B_RCVD)
- .getText());
- long bytesSent = Long.parseLong(statInfo.element(B_SENT).getText());
- long packetsRxDropped = Long.parseLong(statInfo.element(RX_DROP)
- .getText());
- long packetsTxDropped = Long.parseLong(statInfo.element(TX_DROP)
- .getText());
- long packetsRxErrors = Long.parseLong(statInfo.element(RX_ERROR)
- .getText());
- long packetsTxErrors = Long.parseLong(statInfo.element(TX_ERROR)
- .getText());
-
- return builder.setDeviceId(id)
- .setPort(PortNumber.portNumber(port))
- .setPacketsReceived(packetReceived)
- .setPacketsSent(packetSent)
- .setBytesReceived(bytesReceived)
- .setBytesSent(bytesSent)
- .setPacketsRxDropped(packetsRxDropped)
- .setPacketsRxErrors(packetsRxErrors)
- .setPacketsTxDropped(packetsTxDropped)
- .setPacketsTxErrors(packetsTxErrors).build();
- }
- return builder.build();
- }
-}
diff --git a/drivers/huawei/src/main/java/org/onosproject/drivers/huawei/InsConstructionUtil.java b/drivers/huawei/src/main/java/org/onosproject/drivers/huawei/InsConstructionUtil.java
deleted file mode 100644
index eb7fedf..0000000
--- a/drivers/huawei/src/main/java/org/onosproject/drivers/huawei/InsConstructionUtil.java
+++ /dev/null
@@ -1,483 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * 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.
- */
-
-package org.onosproject.drivers.huawei;
-
-import org.onosproject.yang.gen.v1.ietfbgpl3vpn.rev20160909.ietfbgpl3vpn.devices.device.networkinstances.networkinstance.DefaultAugmentedNiNetworkInstance;
-import org.onosproject.yang.gen.v1.ietfbgpl3vpn.rev20160909.ietfbgpl3vpn.l3vpnvrfparams.ipv4.Unicast;
-import org.onosproject.yang.gen.v1.ietfbgpl3vpn.rev20160909.ietfbgpl3vpn.routetargetset.Rts;
-import org.onosproject.yang.gen.v1.ietfbgpl3vpn.rev20160909.ietfbgpl3vpn.routetargetset.rts.RtTypeEnum;
-import org.onosproject.yang.gen.v1.ietfnetworkinstance.rev20160623.ietfnetworkinstance.DefaultDevices;
-import org.onosproject.yang.gen.v1.ietfnetworkinstance.rev20160623.ietfnetworkinstance.devices.Device;
-import org.onosproject.yang.gen.v1.ietfnetworkinstance.rev20160623.ietfnetworkinstance.devices.device.NetworkInstances;
-import org.onosproject.yang.gen.v1.ietfnetworkinstance.rev20160623.ietfnetworkinstance.devices.device.networkinstances.DefaultNetworkInstance;
-import org.onosproject.yang.gen.v1.ietfnetworkinstance.rev20160623.ietfnetworkinstance.devices.device.networkinstances.NetworkInstance;
-import org.onosproject.yang.gen.v1.nel3vpnapi.rev20141225.nel3vpnapi.devices.DefaultDevice;
-import org.onosproject.yang.gen.v1.nel3vpnapi.rev20141225.nel3vpnapi.devices.DeviceKeys;
-import org.onosproject.yang.gen.v1.nel3vpnapi.rev20141225.nel3vpnapi.devices.device.DefaultL3Vpn;
-import org.onosproject.yang.gen.v1.nel3vpnapi.rev20141225.nel3vpnapi.devices.device.L3Vpn;
-import org.onosproject.yang.gen.v1.nel3vpnapi.rev20141225.nel3vpnapi.devices.device.l3vpn.DefaultL3Vpncomm;
-import org.onosproject.yang.gen.v1.nel3vpnapi.rev20141225.nel3vpnapi.devices.device.l3vpn.L3Vpncomm;
-import org.onosproject.yang.gen.v1.nel3vpnapi.rev20141225.nel3vpnapi.devices.device.l3vpn.l3vpncomm.DefaultL3VpnInstances;
-import org.onosproject.yang.gen.v1.nel3vpnapi.rev20141225.nel3vpnapi.devices.device.l3vpn.l3vpncomm.L3VpnInstances;
-import org.onosproject.yang.gen.v1.nel3vpnapi.rev20141225.nel3vpnapi.devices.device.l3vpn.l3vpncomm.l3vpninstances.DefaultL3VpnInstance;
-import org.onosproject.yang.gen.v1.nel3vpnapi.rev20141225.nel3vpnapi.devices.device.l3vpn.l3vpncomm.l3vpninstances.L3VpnInstance;
-import org.onosproject.yang.gen.v1.nel3vpnapi.rev20141225.nel3vpnapi.devices.device.l3vpn.l3vpncomm.l3vpninstances.L3VpnInstanceKeys;
-import org.onosproject.yang.gen.v1.nel3vpnapi.rev20141225.nel3vpnapi.devices.device.l3vpn.l3vpncomm.l3vpninstances.l3vpninstance.DefaultVpnInstAfs;
-import org.onosproject.yang.gen.v1.nel3vpnapi.rev20141225.nel3vpnapi.devices.device.l3vpn.l3vpncomm.l3vpninstances.l3vpninstance.VpnInstAfs;
-import org.onosproject.yang.gen.v1.nel3vpnapi.rev20141225.nel3vpnapi.devices.device.l3vpn.l3vpncomm.l3vpninstances.l3vpninstance.vpninstafs.DefaultVpnInstAf;
-import org.onosproject.yang.gen.v1.nel3vpnapi.rev20141225.nel3vpnapi.devices.device.l3vpn.l3vpncomm.l3vpninstances.l3vpninstance.vpninstafs.VpnInstAf;
-import org.onosproject.yang.gen.v1.nel3vpnapi.rev20141225.nel3vpnapi.devices.device.l3vpn.l3vpncomm.l3vpninstances.l3vpninstance.vpninstafs.vpninstaf.DefaultVpnTargets;
-import org.onosproject.yang.gen.v1.nel3vpnapi.rev20141225.nel3vpnapi.devices.device.l3vpn.l3vpncomm.l3vpninstances.l3vpninstance.vpninstafs.vpninstaf.VpnTargets;
-import org.onosproject.yang.gen.v1.nel3vpnapi.rev20141225.nel3vpnapi.devices.device.l3vpn.l3vpncomm.l3vpninstances.l3vpninstance.vpninstafs.vpninstaf.vpntargets.DefaultVpnTarget;
-import org.onosproject.yang.gen.v1.nel3vpnapi.rev20141225.nel3vpnapi.devices.device.l3vpn.l3vpncomm.l3vpninstances.l3vpninstance.vpninstafs.vpninstaf.vpntargets.VpnTarget;
-import org.onosproject.yang.gen.v1.nel3vpncomm.rev20141225.nel3vpncomm.l3vpnifs.DefaultL3VpnIfs;
-import org.onosproject.yang.model.InnerModelObject;
-import org.onosproject.yang.model.ModelObjectData;
-import org.onosproject.yang.model.ModelObjectId;
-
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-
-import static org.onosproject.drivers.huawei.DriverUtil.CONS_DEVICES;
-import static org.onosproject.drivers.huawei.DriverUtil.DEVICE_NULL;
-import static org.onosproject.drivers.huawei.DriverUtil.INS_NULL;
-import static org.onosproject.drivers.huawei.DriverUtil.OBJECT_NULL;
-import static org.onosproject.drivers.huawei.DriverUtil.UNSUPPORTED_MODEL_LVL;
-import static org.onosproject.drivers.huawei.DriverUtil.getData;
-import static org.onosproject.drivers.huawei.DriverUtil.getIdFromModId;
-import static org.onosproject.drivers.huawei.DriverUtil.getModObjIdDriDevices;
-import static org.onosproject.drivers.huawei.DriverUtil.getObjFromModData;
-import static org.onosproject.drivers.huawei.ModelIdLevel.DEVICE;
-import static org.onosproject.drivers.huawei.ModelIdLevel.DEVICES;
-import static org.onosproject.drivers.huawei.ModelIdLevel.ROOT;
-import static org.onosproject.yang.gen.v1.ietfbgpl3vpn.rev20160909.ietfbgpl3vpn.routetargetset.rts.RtTypeEnum.BOTH;
-import static org.onosproject.yang.gen.v1.nel3vpncommtype.rev20141225.nel3vpncommtype.L3VpncommonL3VpnPrefixType.of;
-import static org.onosproject.yang.gen.v1.nel3vpncommtype.rev20141225.nel3vpncommtype.L3VpncommonVrfRtType.fromString;
-import static org.onosproject.yang.gen.v1.nel3vpncommtype.rev20141225.nel3vpncommtype.l3vpncommonl3vpnprefixtype.L3VpncommonL3VpnPrefixTypeEnum.IPV4UNI;
-
-/**
- * Representation of utility for instance creation and deletion.
- */
-public final class InsConstructionUtil {
-
- /**
- * Static constant for route target export.
- */
- private static final String EXP_COMM = "export_extcommunity";
-
- /**
- * Static constant for route target import.
- */
- private static final String IMP_COMM = "import_extcommunity";
-
- /**
- * Error message for unsupported RT type.
- */
- private static final String UNSUPPORTED_RT_TYPE = "The RT type is not " +
- "supported";
-
- // No instantiation.
- private InsConstructionUtil() {
- }
-
- /**
- * Returns the created model object data of VPN instance of huawei device
- * from the standard model object data.
- *
- * @param modObj model object data
- * @param isDevAvail if devices available
- * @return driver model object data
- */
- static ModelObjectData getCreateVpnIns(ModelObjectData modObj,
- boolean isDevAvail) {
- ModelIdLevel modIdLvl = DEVICE;
- String id = getIdFromModId(modObj.identifier(), true);
- Object obj = getObjFromModData(modObj);
-
- if (obj == null) {
- throw new IllegalArgumentException(OBJECT_NULL);
- }
-
- if (id == null) {
- id = getDevIdFromRootObj(obj);
- obj = getObjFromRootObj(obj);
- if (isDevAvail) {
- modIdLvl = DEVICES;
- } else {
- modIdLvl = ROOT;
- }
- } else if (id.equals(CONS_DEVICES)) {
- modIdLvl = DEVICES;
- id = ((Device) obj).deviceid();
- obj = ((Device) obj).networkInstances();
- }
- org.onosproject.yang.gen.v1.nel3vpnapi.rev20141225.nel3vpnapi
- .DefaultDevices devices = getDriverDevices(
- id, (NetworkInstances) obj);
- return getCreateModObjData(modIdLvl, id, devices);
- }
-
- /**
- * Returns the driver model object data, according to the levels it has
- * to be constructed.
- *
- * @param modIdLvl model id level
- * @param devId device id
- * @param devices devices object
- * @return model object data
- */
- private static ModelObjectData getCreateModObjData(ModelIdLevel modIdLvl,
- String devId,
- org.onosproject.yang.gen
- .v1.nel3vpnapi
- .rev20141225
- .nel3vpnapi
- .DefaultDevices
- devices) {
- ModelObjectId id;
- List<org.onosproject.yang.gen.v1.nel3vpnapi.rev20141225.nel3vpnapi
- .devices.Device> devList = devices.device();
- Iterator<org.onosproject.yang.gen.v1.nel3vpnapi.rev20141225.nel3vpnapi
- .devices.Device> it = devList.iterator();
- org.onosproject.yang.gen.v1.nel3vpnapi.rev20141225.nel3vpnapi
- .devices.Device device = it.next();
- Iterator<L3VpnInstance> instIt = device.l3Vpn().l3Vpncomm()
- .l3VpnInstances().l3VpnInstance().iterator();
- L3VpnInstance ins = instIt.next();
-
- switch (modIdLvl) {
-
- case ROOT:
- return getData(null, devices);
-
- case DEVICES:
- id = getModObjIdDriDevices();
- return getData(id, (InnerModelObject) device);
-
- case DEVICE:
- id = getModelObjIdForIns(devId).build();
- return getData(id, (InnerModelObject) ins);
-
- default:
- throw new IllegalArgumentException(UNSUPPORTED_MODEL_LVL);
- }
- }
-
- /**
- * Returns the devices object of the huawei VPN instance model. This
- * constructs all the required information in the device for L3VPN
- * instance creation.
- *
- * @param id device id
- * @param obj network instances object
- * @return driver VPN instance's devices
- */
- private static org.onosproject.yang.gen.v1.nel3vpnapi.rev20141225
- .nel3vpnapi.DefaultDevices getDriverDevices(String id,
- NetworkInstances obj) {
-
- org.onosproject.yang.gen.v1.nel3vpnapi.rev20141225.nel3vpnapi.
- DefaultDevices devices = new org.onosproject.yang.gen.v1
- .nel3vpnapi.rev20141225.nel3vpnapi.DefaultDevices();
- org.onosproject.yang.gen.v1.nel3vpnapi.rev20141225.nel3vpnapi.devices
- .Device device = new org.onosproject.yang.gen.v1.nel3vpnapi
- .rev20141225.nel3vpnapi.devices.DefaultDevice();
-
- L3Vpn l3Vpn = new DefaultL3Vpn();
- L3Vpncomm l3VpnComm = new DefaultL3Vpncomm();
- L3VpnInstances instances = new DefaultL3VpnInstances();
- L3VpnInstance ins = new DefaultL3VpnInstance();
- List<L3VpnInstance> insList = new LinkedList<>();
- List<org.onosproject.yang.gen.v1.nel3vpnapi.rev20141225.nel3vpnapi
- .devices.Device> devList = new LinkedList<>();
-
- createDriIns(obj, ins);
- insList.add(ins);
- instances.l3VpnInstance(insList);
- l3VpnComm.l3VpnInstances(instances);
- l3Vpn.l3Vpncomm(l3VpnComm);
-
- device.deviceid(id);
- device.l3Vpn(l3Vpn);
- devList.add(device);
- devices.device(devList);
- return devices;
- }
-
- /**
- * Creates driver instance value from standard device instance.
- *
- * @param ins standard device instance
- * @param driIns driver instance
- */
- private static void createDriIns(NetworkInstances ins,
- L3VpnInstance driIns) {
- NetworkInstance networkInstance = ins.networkInstance().iterator()
- .next();
- driIns.vrfName(networkInstance.name());
- DefaultAugmentedNiNetworkInstance augIns =
- ((DefaultNetworkInstance) networkInstance).augmentation(
- DefaultAugmentedNiNetworkInstance.class);
- VpnInstAfs vpnInstAfs = processL3VpnAf(augIns.l3Vpn());
- driIns.vpnInstAfs(vpnInstAfs);
- }
-
- /**
- * Returns the device id from the root object.
- *
- * @param obj root object
- * @return device id
- */
- private static String getDevIdFromRootObj(Object obj) {
- Device dev = getDevFromRootObj(obj);
- return dev.deviceid();
- }
-
- /**
- * Returns the first device from the root object. If no device is
- * present, it returns null.
- *
- * @param obj root object
- * @return device object
- */
- private static Device getDevFromRootObj(Object obj) {
- List<Device> deviceList = ((DefaultDevices) obj).device();
- Iterator<Device> it = deviceList.iterator();
- if (it.hasNext()) {
- return it.next();
- }
- throw new IllegalArgumentException(DEVICE_NULL);
- }
-
- /**
- * Returns the network instances object from the root object.
- *
- * @param obj root object
- * @return network instances
- */
- private static NetworkInstances getObjFromRootObj(Object obj) {
- Device dev = getDevFromRootObj(obj);
- return dev.networkInstances();
- }
-
- /**
- * Returns model object id builder that has to be constructed for driver
- * instance level addition, with the device id.
- *
- * @param id device id
- * @return model object id
- */
- private static ModelObjectId.Builder getModelObjIdForIns(String id) {
- ModelObjectId.Builder device = getModObjIdDriDevice(id);
- return device.addChild(DefaultL3Vpn.class)
- .addChild(DefaultL3Vpncomm.class)
- .addChild(DefaultL3VpnInstances.class);
- }
-
- /**
- * Processes standard device model L3VPN address family and returns the
- * driver L3VPN address family.
- *
- * @param l3Vpn standard device L3VPN
- * @return driver address family
- */
- private static VpnInstAfs processL3VpnAf(org.onosproject.yang.gen.v1
- .ietfbgpl3vpn.rev20160909
- .ietfbgpl3vpn.devices
- .device.networkinstances
- .networkinstance
- .augmentedninetworkinstance
- .L3Vpn l3Vpn) {
- // TODO: Need to handle the ipv6 case
- Unicast ipv4Unicast = l3Vpn.ipv4().unicast();
- VpnInstAfs vpnInstAfs = new DefaultVpnInstAfs();
- VpnInstAf vpnInstAf = new DefaultVpnInstAf();
- VpnTargets vpnTargets = new DefaultVpnTargets();
- List<VpnInstAf> afList = new LinkedList<>();
-
- vpnInstAf.vrfRd(l3Vpn.routeDistinguisher().config().rd());
- vpnInstAf.afType(of(IPV4UNI));
-
- List<Rts> rts = ipv4Unicast.routeTargets().config().rts();
- addVpnTarget(vpnTargets, rts);
-
- vpnInstAf.vpnTargets(vpnTargets);
- afList.add(vpnInstAf);
- vpnInstAfs.vpnInstAf(afList);
- return vpnInstAfs;
- }
-
- /**
- * Adds VPN target to the target list from the list of RTs available in
- * the standard device model.
- *
- * @param vpnTgts VPN targets
- * @param rts rts
- */
- private static void addVpnTarget(VpnTargets vpnTgts, List<Rts> rts) {
- List<VpnTarget> tgtList = new LinkedList<>();
- for (Rts rt : rts) {
- if (rt == null) {
- continue;
- }
- if (rt.rtType() == BOTH) {
- VpnTarget expTgt = addRt(rt.rt(), EXP_COMM);
- VpnTarget impTgt = addRt(rt.rt(), IMP_COMM);
- tgtList.add(expTgt);
- tgtList.add(impTgt);
- } else {
- String rtType = getRtVal(rt.rtType());
- VpnTarget tgt = addRt(rt.rt(), rtType);
- tgtList.add(tgt);
- }
- }
- vpnTgts.vpnTarget(tgtList);
- }
-
- /**
- * Returns the RT value according to the RT type available.
- *
- * @param type RT type
- * @return RT value
- */
- private static String getRtVal(RtTypeEnum type) {
- switch (type) {
-
- case EXPORT:
- return EXP_COMM;
-
- case IMPORT:
- return IMP_COMM;
-
- default:
- throw new IllegalArgumentException(UNSUPPORTED_RT_TYPE);
- }
- }
-
- /**
- * Adds RT to the VPN target with the RT value and RT type.
- *
- * @param rt RT value
- * @param rtType RT type
- * @return VPN target
- */
- private static VpnTarget addRt(String rt, String rtType) {
- VpnTarget vpnTarget = new DefaultVpnTarget();
- vpnTarget.vrfRtvalue(rt);
- vpnTarget.vrfRttype(fromString(rtType));
- return vpnTarget;
- }
-
- /**
- * Returns the deletable model object data of VPN instance of huawei device
- * from the standard model object data.
- *
- * @param modObj model object data
- * @return driver model object data
- */
- static ModelObjectData getDeleteVpnIns(ModelObjectData modObj) {
- ModelIdLevel modIdLvl = DEVICE;
- String id = getIdFromModId(modObj.identifier(), true);
- Object obj = getObjFromModData(modObj);
-
- if (obj == null) {
- throw new IllegalArgumentException(OBJECT_NULL);
- }
-
- if (id == null) {
- modIdLvl = ROOT;
- id = getDevIdFromRootObj(obj);
- obj = getObjFromRootObj(obj);
- } else if (id.equals(CONS_DEVICES)) {
- modIdLvl = DEVICES;
- id = ((Device) obj).deviceid();
- obj = ((Device) obj).networkInstances();
- }
- List<NetworkInstance> ins = ((NetworkInstances) obj).networkInstance();
- Iterator<NetworkInstance> it = ins.iterator();
- NetworkInstance instance;
- if (it.hasNext()) {
- instance = it.next();
- } else {
- throw new IllegalArgumentException(INS_NULL);
- }
- return getDelModObjData(modIdLvl, id, instance.name());
- }
-
- /**
- * Returns the driver model object data for delete, according to the
- * levels it has to be constructed.
- *
- * @param modIdLvl model id level
- * @param id device id
- * @param name VPN name
- * @return driver model object data
- */
- private static ModelObjectData getDelModObjData(ModelIdLevel modIdLvl,
- String id, String name) {
- ModelObjectId modId;
- switch (modIdLvl) {
- case ROOT:
- modId = getModObjIdDriDevices();
- DefaultDevice device = new DefaultDevice();
- return getData(modId, device);
-
- case DEVICES:
- DefaultL3Vpn l3Vpn = new DefaultL3Vpn();
- modId = getModObjIdDriDevice(id).build();
- return getData(modId, l3Vpn);
-
- case DEVICE:
- DefaultL3VpnIfs l3VpnIfs = new DefaultL3VpnIfs();
- modId = getModObjIdDriVpn(id, name);
- return getData(modId, l3VpnIfs);
-
- default:
- throw new IllegalArgumentException(UNSUPPORTED_MODEL_LVL);
- }
- }
-
- /**
- * Returns the model object id, with device id and VPN name.
- *
- * @param id device id
- * @param name VPN name
- * @return model object id
- */
- private static ModelObjectId getModObjIdDriVpn(String id, String name) {
- ModelObjectId.Builder ins = getModelObjIdForIns(id);
- L3VpnInstanceKeys key = new L3VpnInstanceKeys();
- key.vrfName(name);
- return ins.addChild(DefaultL3VpnInstance.class, key).build();
- }
-
- /**
- * Returns the model object id builder of the driver with respect to device.
- *
- * @param id device id
- * @return model object id builder
- */
- static ModelObjectId.Builder getModObjIdDriDevice(String id) {
- DeviceKeys key = new DeviceKeys();
- key.deviceid(id);
- return ModelObjectId.builder()
- .addChild(org.onosproject.yang.gen.v1.nel3vpnapi.rev20141225
- .nel3vpnapi.DefaultDevices.class)
- .addChild(DefaultDevice.class, key);
- }
-}
diff --git a/drivers/huawei/src/main/java/org/onosproject/drivers/huawei/IntConstructionUtil.java b/drivers/huawei/src/main/java/org/onosproject/drivers/huawei/IntConstructionUtil.java
deleted file mode 100644
index d4c7a6f..0000000
--- a/drivers/huawei/src/main/java/org/onosproject/drivers/huawei/IntConstructionUtil.java
+++ /dev/null
@@ -1,237 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * 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.
- */
-
-package org.onosproject.drivers.huawei;
-
-import org.onosproject.yang.gen.v1.ietfinterfaces.rev20140508.ietfinterfaces.DefaultDevices;
-import org.onosproject.yang.gen.v1.ietfinterfaces.rev20140508.ietfinterfaces.devices.Device;
-import org.onosproject.yang.gen.v1.ietfinterfaces.rev20140508.ietfinterfaces.devices.device.Interfaces;
-import org.onosproject.yang.gen.v1.ietfinterfaces.rev20140508.ietfinterfaces.devices.device.interfaces.DefaultYangAutoPrefixInterface;
-import org.onosproject.yang.gen.v1.ietfinterfaces.rev20140508.ietfinterfaces.devices.device.interfaces.YangAutoPrefixInterface;
-import org.onosproject.yang.gen.v1.ietfip.rev20140616.ietfip.devices.device.interfaces.yangautoprefixinterface.augmentedifinterface.Ipv4;
-import org.onosproject.yang.gen.v1.ietfip.rev20140616.ietfip.devices.device.interfaces.yangautoprefixinterface.augmentedifinterface.ipv4.Address;
-import org.onosproject.yang.gen.v1.ietfip.rev20140616.ietfip.devices.device.interfaces.yangautoprefixinterface.augmentedifinterface.ipv4.address.subnet.PrefixLength;
-import org.onosproject.yang.gen.v1.ietfnetworkinstance.rev20160623.ietfnetworkinstance.devices.device.interfaces.yangautoprefixinterface.DefaultAugmentedIfInterface;
-import org.onosproject.yang.gen.v1.nel3vpnapi.rev20141225.nel3vpnapi.devices.DeviceKeys;
-import org.onosproject.yang.gen.v1.nel3vpnapi.rev20141225.nel3vpnapi.devices.device.DefaultL3Vpn;
-import org.onosproject.yang.gen.v1.nel3vpnapi.rev20141225.nel3vpnapi.devices.device.l3vpn.DefaultL3Vpncomm;
-import org.onosproject.yang.gen.v1.nel3vpnapi.rev20141225.nel3vpnapi.devices.device.l3vpn.l3vpncomm.DefaultL3VpnInstances;
-import org.onosproject.yang.gen.v1.nel3vpnapi.rev20141225.nel3vpnapi.devices.device.l3vpn.l3vpncomm.l3vpninstances.DefaultL3VpnInstance;
-import org.onosproject.yang.gen.v1.nel3vpnapi.rev20141225.nel3vpnapi.devices.device.l3vpn.l3vpncomm.l3vpninstances.L3VpnInstanceKeys;
-import org.onosproject.yang.gen.v1.nel3vpncomm.rev20141225.nel3vpncomm.l3vpnifs.DefaultL3VpnIfs;
-import org.onosproject.yang.gen.v1.nel3vpncomm.rev20141225.nel3vpncomm.l3vpnifs.L3VpnIfs;
-import org.onosproject.yang.gen.v1.nel3vpncomm.rev20141225.nel3vpncomm.l3vpnifs.l3vpnifs.DefaultL3VpnIf;
-import org.onosproject.yang.gen.v1.nel3vpncomm.rev20141225.nel3vpncomm.l3vpnifs.l3vpnifs.L3VpnIf;
-import org.onosproject.yang.gen.v1.nel3vpncommtype.rev20141225.nel3vpncommtype.Ipv4Address;
-import org.onosproject.yang.model.InnerModelObject;
-import org.onosproject.yang.model.ModelObjectData;
-import org.onosproject.yang.model.ModelObjectId;
-
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-
-import static org.onosproject.drivers.huawei.DriverUtil.DEVICE_NULL;
-import static org.onosproject.drivers.huawei.DriverUtil.OBJECT_NULL;
-import static org.onosproject.drivers.huawei.DriverUtil.getData;
-import static org.onosproject.drivers.huawei.DriverUtil.getIdFromModId;
-import static org.onosproject.drivers.huawei.DriverUtil.getObjFromModData;
-import static org.onosproject.yang.gen.v1.nel3vpncommtype.rev20141225.nel3vpncommtype.Ipv4Address.fromString;
-
-/**
- * Representation of utility for interface creation and deletion.
- */
-public final class IntConstructionUtil {
-
- /**
- * Error message for illegal length of mask.
- */
- private static final String ILLEGAL_MASK_LENGTH = "Illegal length of mask" +
- " is not allowed.";
-
- // No instantiation.
- private IntConstructionUtil() {
- }
-
- /**
- * Returns the created model object data of VPN bounded interface of huawei
- * device from the standard model object data.
- *
- * @param modObj model object data
- * @return driver interface model object data
- */
- static ModelObjectData getCreateInt(ModelObjectData modObj) {
- boolean isModIdAvail = true;
- String id = getIdFromModId(modObj.identifier(), false);
- Object obj = getObjFromModData(modObj);
- if (id == null) {
- isModIdAvail = false;
- id = getIdFromRootObj(obj);
- obj = getObjFromDevObj(obj);
- }
- if (obj == null) {
- throw new IllegalArgumentException(OBJECT_NULL);
- }
- List<YangAutoPrefixInterface> intList = ((Interfaces) obj)
- .yangAutoPrefixInterface();
- YangAutoPrefixInterface l3Int = intList.get(0);
- DefaultAugmentedIfInterface ifInt =
- ((DefaultYangAutoPrefixInterface) l3Int).augmentation(
- DefaultAugmentedIfInterface.class);
- String insName = ifInt.bindNetworkInstanceName();
- L3VpnIfs l3VpnIfs = getDriverInterfaces(l3Int);
- return getDriModObj(id, insName, l3VpnIfs, isModIdAvail);
- }
-
- /**
- * Returns the driver model object data, according to the levels it has
- * to be constructed.
- *
- * @param id device id
- * @param insName VPN name
- * @param l3VpnIfs driver VPN if object
- * @param isModIdAvail model id availability
- * @return driver model object data
- */
- private static ModelObjectData getDriModObj(String id, String insName,
- L3VpnIfs l3VpnIfs,
- boolean isModIdAvail) {
- List<L3VpnIf> intList = l3VpnIfs.l3VpnIf();
- Iterator<L3VpnIf> it = intList.iterator();
- L3VpnIf l3VpnIf = it.next();
- ModelObjectData data;
- ModelObjectId.Builder objId = getModIdBuilder(id, insName);
- if (isModIdAvail) {
- objId.addChild(DefaultL3VpnIfs.class);
- data = getData(objId.build(), (InnerModelObject) l3VpnIf);
- } else {
- data = getData(objId.build(), (InnerModelObject) l3VpnIfs);
- }
- return data;
- }
-
- private static ModelObjectId.Builder getModIdBuilder(String id,
- String vpnName) {
- DeviceKeys key = new DeviceKeys();
- key.deviceid(id);
- L3VpnInstanceKeys insKey = new L3VpnInstanceKeys();
- insKey.vrfName(vpnName);
- return ModelObjectId.builder()
- .addChild(org.onosproject.yang.gen.v1.nel3vpnapi.rev20141225
- .nel3vpnapi.DefaultDevices.class)
- .addChild(org.onosproject.yang.gen.v1.nel3vpnapi.rev20141225
- .nel3vpnapi.devices.DefaultDevice.class, key)
- .addChild(DefaultL3Vpn.class)
- .addChild(DefaultL3Vpncomm.class)
- .addChild(DefaultL3VpnInstances.class)
- .addChild(DefaultL3VpnInstance.class, insKey);
- }
-
- /**
- * Returns the driver interfaces from the standard device model interfaces.
- *
- * @param ifs standard device model interfaces
- * @return driver interfaces
- */
- private static L3VpnIfs getDriverInterfaces(YangAutoPrefixInterface ifs) {
- L3VpnIfs l3VpnIfs = new DefaultL3VpnIfs();
- L3VpnIf l3VpnIf = new DefaultL3VpnIf();
- List<L3VpnIf> l3VpnIfList = new LinkedList<>();
- l3VpnIf.ifName(ifs.name());
- org.onosproject.yang.gen.v1.ietfip
- .rev20140616.ietfip.devices.device.interfaces
- .yangautoprefixinterface.DefaultAugmentedIfInterface ipAug =
- ((DefaultYangAutoPrefixInterface) ifs).augmentation(
- org.onosproject.yang.gen.v1.ietfip.rev20140616
- .ietfip.devices.device.interfaces
- .yangautoprefixinterface
- .DefaultAugmentedIfInterface.class);
-
- if (ipAug != null && ipAug.ipv4() != null) {
- Ipv4 ipAddress = ipAug.ipv4();
- for (Address add : ipAddress.address()) {
- Ipv4Address v4Add = fromString(add.ip().ipv4Address()
- .toString());
- Ipv4Address subnet = fromString(getSubnet(
- ((PrefixLength) add.subnet()).prefixLength()));
- l3VpnIf.ipv4Addr(v4Add);
- l3VpnIf.subnetMask(subnet);
- }
- }
- l3VpnIfList.add(l3VpnIf);
- l3VpnIfs.l3VpnIf(l3VpnIfList);
- return l3VpnIfs;
- }
-
- /**
- * Returns the device id from the root object.
- *
- * @param obj root object
- * @return device id
- */
- private static String getIdFromRootObj(Object obj) {
- Device dev = getDevFromRootObj(obj);
- return dev.deviceid();
- }
-
- /**
- * Returns the device from the root object.
- *
- * @param obj root object
- * @return device object
- */
- private static Device getDevFromRootObj(Object obj) {
- List<Device> deviceList = ((DefaultDevices) obj).device();
- Iterator<Device> it = deviceList.iterator();
- if (it.hasNext()) {
- return it.next();
- }
- throw new IllegalArgumentException(DEVICE_NULL);
- }
-
- /**
- * Returns the interfaces object from the root object.
- *
- * @param obj root object
- * @return interfaces object
- */
- private static Interfaces getObjFromDevObj(Object obj) {
- Device dev = getDevFromRootObj(obj);
- return dev.interfaces();
- }
-
- /**
- * Returns the subnet address from the mask value.
- *
- * @param mask mask value
- * @return subnet address
- */
- private static String getSubnet(short mask) {
- int value = 0xffffffff << (32 - mask);
- byte[] bytes = new byte[]{
- (byte) (value >>> 24), (byte) (value >> 16 & 0xff),
- (byte) (value >> 8 & 0xff), (byte) (value & 0xff)};
- InetAddress netAdd;
- try {
- netAdd = InetAddress.getByAddress(bytes);
- } catch (UnknownHostException e) {
- throw new IllegalArgumentException(ILLEGAL_MASK_LENGTH);
- }
- return netAdd.getHostAddress();
- }
-}
diff --git a/drivers/huawei/src/main/java/org/onosproject/drivers/huawei/L3VpnUtil.java b/drivers/huawei/src/main/java/org/onosproject/drivers/huawei/L3VpnUtil.java
deleted file mode 100644
index c072cd6..0000000
--- a/drivers/huawei/src/main/java/org/onosproject/drivers/huawei/L3VpnUtil.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * 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.
- */
-
-package org.onosproject.drivers.huawei;
-
-import org.onosproject.yang.gen.v1.ietfnetworkinstance.rev20160623.ietfnetworkinstance.devices.DeviceKeys;
-import org.onosproject.yang.model.KeyInfo;
-
-/**
- * Representation of utility for huawei driver's L3VPN.
- */
-public final class L3VpnUtil {
-
- // No instantiation.
- private L3VpnUtil() {
- }
-
- /**
- * Returns the device id from the instance key.
- *
- * @param key instance key
- * @return device id
- */
- static String getDevIdFromIns(KeyInfo key) {
- return ((DeviceKeys) key).deviceid();
- }
-}
diff --git a/drivers/huawei/src/main/java/org/onosproject/drivers/huawei/ModelIdLevel.java b/drivers/huawei/src/main/java/org/onosproject/drivers/huawei/ModelIdLevel.java
deleted file mode 100644
index 3827d0a..0000000
--- a/drivers/huawei/src/main/java/org/onosproject/drivers/huawei/ModelIdLevel.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * 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.
- */
-
-package org.onosproject.drivers.huawei;
-
-/**
- * Represents the model id level of the VPN instance.
- */
-public enum ModelIdLevel {
-
- /**
- * Requested model id level is not present, representing top node.
- */
- ROOT,
-
- /**
- * Requested model id level is devices container.
- */
- DEVICE,
-
- /**
- * Requested model id level is device list.
- */
- DEVICES
-}
diff --git a/drivers/huawei/src/main/java/org/onosproject/drivers/huawei/TnlConstructionUtil.java b/drivers/huawei/src/main/java/org/onosproject/drivers/huawei/TnlConstructionUtil.java
deleted file mode 100644
index 1ba29dd..0000000
--- a/drivers/huawei/src/main/java/org/onosproject/drivers/huawei/TnlConstructionUtil.java
+++ /dev/null
@@ -1,262 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * 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.
- */
-
-package org.onosproject.drivers.huawei;
-
-import org.onosproject.l3vpn.netl3vpn.TunnelInfo;
-import org.onosproject.yang.gen.v1.nel3vpncommtype.rev20141225.nel3vpncommtype.Ipv4Address;
-import org.onosproject.yang.gen.v1.nel3vpncommtype.rev20141225.nel3vpncommtype.L3VpncommonL3VpnPrefixType;
-import org.onosproject.yang.gen.v1.nel3vpnapi.rev20141225.nel3vpnapi.devices.device.DefaultL3Vpn;
-import org.onosproject.yang.gen.v1.nel3vpnapi.rev20141225.nel3vpnapi.devices.device.l3vpn.DefaultL3Vpncomm;
-import org.onosproject.yang.gen.v1.nel3vpnapi.rev20141225.nel3vpnapi.devices.device.l3vpn.l3vpncomm.DefaultL3VpnInstances;
-import org.onosproject.yang.gen.v1.nel3vpnapi.rev20141225.nel3vpnapi.devices.device.l3vpn.l3vpncomm.l3vpninstances.DefaultL3VpnInstance;
-import org.onosproject.yang.gen.v1.nel3vpnapi.rev20141225.nel3vpnapi.devices.device.l3vpn.l3vpncomm.l3vpninstances.L3VpnInstanceKeys;
-import org.onosproject.yang.gen.v1.nel3vpnapi.rev20141225.nel3vpnapi.devices.device.l3vpn.l3vpncomm.l3vpninstances.l3vpninstance.DefaultVpnInstAfs;
-import org.onosproject.yang.gen.v1.nel3vpnapi.rev20141225.nel3vpnapi.devices.device.l3vpn.l3vpncomm.l3vpninstances.l3vpninstance.vpninstafs.DefaultVpnInstAf;
-import org.onosproject.yang.gen.v1.nel3vpnapi.rev20141225.nel3vpnapi.devices.device.l3vpn.l3vpncomm.l3vpninstances.l3vpninstance.vpninstafs.VpnInstAfKeys;
-import org.onosproject.yang.gen.v1.netnlm.rev20141225.netnlm.DefaultDevices;
-import org.onosproject.yang.gen.v1.netnlm.rev20141225.netnlm.Devices;
-import org.onosproject.yang.gen.v1.netnlm.rev20141225.netnlm.devices.DefaultDevice;
-import org.onosproject.yang.gen.v1.netnlm.rev20141225.netnlm.devices.Device;
-import org.onosproject.yang.gen.v1.netnlm.rev20141225.netnlm.devices.DeviceKeys;
-import org.onosproject.yang.gen.v1.netnlm.rev20141225.netnlm.devices.device.DefaultTnlm;
-import org.onosproject.yang.gen.v1.netnlm.rev20141225.netnlm.devices.device.Tnlm;
-import org.onosproject.yang.gen.v1.netnlm.rev20141225.netnlm.devices.device.tnlm.DefaultTunnelPolicys;
-import org.onosproject.yang.gen.v1.netnlm.rev20141225.netnlm.devices.device.tnlm.TunnelPolicys;
-import org.onosproject.yang.gen.v1.netnlm.rev20141225.netnlm.devices.device.tnlm.tunnelpolicys.DefaultTunnelPolicy;
-import org.onosproject.yang.gen.v1.netnlm.rev20141225.netnlm.devices.device.tnlm.tunnelpolicys.TunnelPolicy;
-import org.onosproject.yang.gen.v1.netnlm.rev20141225.netnlm.devices.device.tnlm.tunnelpolicys.TunnelPolicyKeys;
-import org.onosproject.yang.gen.v1.netnlm.rev20141225.netnlm.devices.device.tnlm.tunnelpolicys.tunnelpolicy.DefaultTpNexthops;
-import org.onosproject.yang.gen.v1.netnlm.rev20141225.netnlm.devices.device.tnlm.tunnelpolicys.tunnelpolicy.TpNexthops;
-import org.onosproject.yang.gen.v1.netnlm.rev20141225.netnlm.devices.device.tnlm.tunnelpolicys.tunnelpolicy.tpnexthops.DefaultTpNexthop;
-import org.onosproject.yang.gen.v1.netnlm.rev20141225.netnlm.devices.device.tnlm.tunnelpolicys.tunnelpolicy.tpnexthops.TpNexthop;
-import org.onosproject.yang.gen.v1.netnlm.rev20141225.netnlm.devices.device.tnlm.tunnelpolicys.tunnelpolicy.tpnexthops.tpnexthop.DefaultTpTunnels;
-import org.onosproject.yang.gen.v1.netnlm.rev20141225.netnlm.devices.device.tnlm.tunnelpolicys.tunnelpolicy.tpnexthops.tpnexthop.TpTunnels;
-import org.onosproject.yang.gen.v1.netnlm.rev20141225.netnlm.devices.device.tnlm.tunnelpolicys.tunnelpolicy.tpnexthops.tpnexthop.tptunnels.DefaultTpTunnel;
-import org.onosproject.yang.gen.v1.netnlm.rev20141225.netnlm.devices.device.tnlm.tunnelpolicys.tunnelpolicy.tpnexthops.tpnexthop.tptunnels.TpTunnel;
-import org.onosproject.yang.gen.v1.netnlmtype.rev20141225.netnlmtype.tnlmbasetnlpolicytype.TnlmbaseTnlPolicyTypeEnum;
-import org.onosproject.yang.model.DefaultModelObjectData;
-import org.onosproject.yang.model.InnerModelObject;
-import org.onosproject.yang.model.LeafModelObject;
-import org.onosproject.yang.model.ModelObjectData;
-import org.onosproject.yang.model.ModelObjectId.Builder;
-
-import static org.onosproject.drivers.huawei.DriverUtil.UNSUPPORTED_MODEL_LVL;
-import static org.onosproject.drivers.huawei.DriverUtil.getData;
-import static org.onosproject.drivers.huawei.InsConstructionUtil.getModObjIdDriDevice;
-import static org.onosproject.l3vpn.netl3vpn.ModelIdLevel.TP_HOP;
-import static org.onosproject.yang.gen.v1.nel3vpncommtype.rev20141225.nel3vpncommtype.l3vpncommonl3vpnprefixtype.L3VpncommonL3VpnPrefixTypeEnum.IPV4UNI;
-import static org.onosproject.yang.gen.v1.nel3vpnapi.rev20141225.nel3vpnapi.devices.device.l3vpn.l3vpncomm.l3vpninstances.l3vpninstance.vpninstafs.VpnInstAf.LeafIdentifier.TNLPOLICYNAME;
-import static org.onosproject.yang.gen.v1.netnlmtype.rev20141225.netnlmtype.TnlmbaseTnlPolicyType.of;
-import static org.onosproject.yang.model.ModelObjectId.builder;
-
-/**
- * Representation of utility for tunnel creation and deletion.
- */
-public final class TnlConstructionUtil {
-
- /**
- * Error message for unsupported device type.
- */
- private static final String UNSUPPORTED_DEV_TYPE = "Levels other than " +
- "devices and device are not permitted.";
-
- /**
- * Error message for unsupported tunnel policy type.
- */
- private static final String UNSUPPORTED_TNL_POL_TYPE = "Levels other" +
- " than tnlm and tnl policy are not permitted.";
-
- // No instantiation.
- private TnlConstructionUtil() {
- }
-
- /**
- * Returns the created model object data of devices or device level from
- * the tunnel info.
- *
- * @param tnlInfo tunnel info
- * @return driver model object data
- */
- static ModelObjectData getCreateTnlDev(TunnelInfo tnlInfo) {
- Device device = new DefaultDevice();
- device.deviceid(tnlInfo.devId());
-
- switch (tnlInfo.level()) {
- case DEVICES:
- Devices devices = new DefaultDevices();
- devices.addToDevice(device);
- return getData(null, (InnerModelObject) devices);
-
- case DEVICE:
- Builder id = getDevicesId();
- return getData(id.build(), (InnerModelObject) device);
-
- default:
- throw new IllegalArgumentException(UNSUPPORTED_DEV_TYPE);
- }
- }
-
- /**
- * Returns the created model object data of tunnel policy from the tunnel
- * info.
- *
- * @param tnlInfo tunnel info
- * @return driver model object data
- */
- static ModelObjectData getCreateTnlPol(TunnelInfo tnlInfo) {
- Builder id = getDeviceId(tnlInfo.devId());
- TunnelPolicy tnlPol = new DefaultTunnelPolicy();
- tnlPol.tnlPolicyName(tnlInfo.polName());
- tnlPol.tnlPolicyType(of(TnlmbaseTnlPolicyTypeEnum.of(2)));
-
- switch (tnlInfo.level()) {
- case TNL_M:
- Tnlm tnlm = new DefaultTnlm();
- TunnelPolicys tnlPolicys = new DefaultTunnelPolicys();
- tnlPolicys.addToTunnelPolicy(tnlPol);
- tnlm.tunnelPolicys(tnlPolicys);
- return getData(id.build(), (InnerModelObject) tnlm);
-
- case TNL_POL:
- id = getTunnelPolicysId(id);
- return getData(id.build(), (InnerModelObject) tnlPol);
-
- default:
- throw new IllegalArgumentException(UNSUPPORTED_TNL_POL_TYPE);
- }
- }
-
- /**
- * Returns the created model object data of tunnel from the tunnel info.
- *
- * @param tnlInfo tunnel info
- * @return driver model object data
- */
- static ModelObjectData getCreateTnl(TunnelInfo tnlInfo) {
- TunnelPolicyKeys key = new TunnelPolicyKeys();
- key.tnlPolicyName(tnlInfo.polName());
-
- Builder id = getDeviceId(tnlInfo.devId());
- id = getTunnelPolicysId(id);
- id = id.addChild(DefaultTunnelPolicy.class, key);
- TpNexthop tpHop = new DefaultTpNexthop();
- TpTunnels tunnels = new DefaultTpTunnels();
- TpTunnel tunnel = new DefaultTpTunnel();
- tunnel.tunnelName(tnlInfo.tnlName());
- tunnel.autoTunnel(true);
- tunnels.addToTpTunnel(tunnel);
- tpHop.tpTunnels(tunnels);
- tpHop.nexthopIpaddr(Ipv4Address.of(tnlInfo.desIp()));
-
- if (tnlInfo.level() == TP_HOP) {
- id.addChild(DefaultTpNexthops.class);
- return getData(id.build(), (InnerModelObject) tpHop);
- } else {
- TpNexthops tpHops = new DefaultTpNexthops();
- tpHops.addToTpNexthop(tpHop);
- return getData(id.build(), (InnerModelObject) tpHops);
- }
- }
-
- /**
- * Returns the created model object data of binding the tunnel policy to
- * the VPN from the tunnel policy name and device id.
- *
- * @param tnlInfo tunnel info
- * @return driver model object data
- */
- static ModelObjectData getBindTnl(TunnelInfo tnlInfo) {
- L3VpnInstanceKeys vpnKey = new L3VpnInstanceKeys();
- vpnKey.vrfName(tnlInfo.polName());
- VpnInstAfKeys afKeys = new VpnInstAfKeys();
- afKeys.afType(L3VpncommonL3VpnPrefixType.of(IPV4UNI));
-
- Builder id = getModObjIdDriDevice(tnlInfo.devId());
- id.addChild(DefaultL3Vpn.class);
- id.addChild(DefaultL3Vpncomm.class);
- id.addChild(DefaultL3VpnInstances.class);
- id.addChild(DefaultL3VpnInstance.class, vpnKey);
- id.addChild(DefaultVpnInstAfs.class);
- id.addChild(DefaultVpnInstAf.class, afKeys);
-
- LeafModelObject leaf = new LeafModelObject();
- leaf.leafIdentifier(TNLPOLICYNAME);
- leaf.addValue(tnlInfo.polName());
- return DefaultModelObjectData.builder().addModelObject(leaf)
- .identifier(id.build()).build();
- }
-
- /**
- * Returns the driver model object data for delete, according to the
- * levels it has to be constructed for tunnel policy.
- *
- * @param tnlInfo tunnel info
- * @return driver model object data
- */
- static ModelObjectData getDeleteTnl(TunnelInfo tnlInfo) {
- Builder id = getDeviceId(tnlInfo.devId());
- switch (tnlInfo.level()) {
- case DEVICES:
- return getData(getDevicesId().build(), new DefaultDevice());
-
- case DEVICE:
- return getData(id.build(), new DefaultTnlm());
-
- case TNL_POL:
- id = getTunnelPolicysId(id);
- TunnelPolicyKeys polKey = new TunnelPolicyKeys();
- polKey.tnlPolicyName(tnlInfo.polName());
- id = id.addChild(DefaultTunnelPolicy.class, polKey);
- return getData(id.build(), new DefaultTpNexthops());
-
- default:
- throw new IllegalArgumentException(UNSUPPORTED_MODEL_LVL);
- }
- }
-
- /**
- * Returns the model object id of tunnel with devices and device.
- *
- * @param id device id
- * @return model object id
- */
- private static Builder getDeviceId(String id) {
- DeviceKeys devId = new DeviceKeys();
- devId.deviceid(id);
- return getDevicesId().addChild(DefaultDevice.class, devId);
- }
-
- /**
- * Returns the model object id of tunnel with devices.
- *
- * @return model object id
- */
- private static Builder getDevicesId() {
- return builder().addChild(DefaultDevices.class);
- }
-
- /**
- * Returns the model object id of tunnel policies.
- *
- * @param id model object id
- * @return model object id with tunnel policies
- */
- public static Builder getTunnelPolicysId(Builder id) {
- return id.addChild(DefaultTnlm.class)
- .addChild(DefaultTunnelPolicys.class);
- }
-}
diff --git a/drivers/huawei/src/main/java/org/onosproject/drivers/huawei/package-info.java b/drivers/huawei/src/main/java/org/onosproject/drivers/huawei/package-info.java
deleted file mode 100644
index b03bd5a..0000000
--- a/drivers/huawei/src/main/java/org/onosproject/drivers/huawei/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * 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.
- */
-
-/**
- * Package for Huawei device drivers.
- */
-package org.onosproject.drivers.huawei;
\ No newline at end of file
diff --git a/drivers/huawei/src/main/resources/huawei-drivers.xml b/drivers/huawei/src/main/resources/huawei-drivers.xml
deleted file mode 100644
index 0ec590d..0000000
--- a/drivers/huawei/src/main/resources/huawei-drivers.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ Copyright 2017-present Open Networking Foundation
- ~
- ~ 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.
- -->
-<drivers>
- <driver name="huawei" extends="" manufacturer="Huawei"
- hwVersion="" swVersion="">
- <behaviour api="org.onosproject.l3vpn.netl3vpn.L3VpnConfig"
- impl="org.onosproject.drivers.huawei.HuaweiL3VpnConfig"/>
- <behaviour api="org.onosproject.net.device.DeviceDescriptionDiscovery"
- impl="org.onosproject.drivers.huawei.HuaweiDeviceDescription"/>
- <behaviour api="org.onosproject.net.device.PortStatisticsDiscovery"
- impl="org.onosproject.drivers.huawei.HuaweiDeviceDescription"/>
- </driver>
-</drivers>
diff --git a/tools/build/publish-target-list b/tools/build/publish-target-list
index c27a4f5..bc73690 100644
--- a/tools/build/publish-target-list
+++ b/tools/build/publish-target-list
@@ -31,7 +31,6 @@
//protocols/grpc/utils:onos-protocols-grpc-utils
//protocols/gnmi/api:onos-protocols-gnmi-api
//protocols/gnoi/api:onos-protocols-gnoi-api
- //protocols/isis/api:onos-protocols-isis-api
//protocols/lisp/api:onos-protocols-lisp-api
//protocols/lisp/msg:onos-protocols-lisp-msg
//protocols/netconf/api:onos-protocols-netconf-api