diff options
author | Ravi Pendurty <ravi.pendurty@highstreet-technologies.com> | 2021-04-19 12:46:16 +0200 |
---|---|---|
committer | Michael DÜrre <michael.duerre@highstreet-technologies.com> | 2021-04-20 08:01:27 +0200 |
commit | 05fe114a5969727c32cd9f1051cd7b9fde0344d5 (patch) | |
tree | 4cb505cd98ddb5b9c6f188f9febe93b07cf743db /sdnr/wt/devicemanager-onap/adapter-manager/provider/src | |
parent | 6ae7e8a1bae83d407b22d8b066dd0bcca730e1bb (diff) |
Reorganization of devicemanager directory structure
Organized into core, onap and o-ran-sc directories
Issue-ID: CCSDK-3242
Signed-off-by: Ravi Pendurty <ravi.pendurty@highstreet-technologies.com>
Change-Id: I3c23710f990a2d96ba01104c97315fc8c6b1921b
Signed-off-by: Ravi Pendurty <ravi.pendurty@highstreet-technologies.com>
Signed-off-by: Michael DÜrre <michael.duerre@highstreet-technologies.com>
Diffstat (limited to 'sdnr/wt/devicemanager-onap/adapter-manager/provider/src')
12 files changed, 1377 insertions, 0 deletions
diff --git a/sdnr/wt/devicemanager-onap/adapter-manager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/adaptermanager/impl/AdapterManagerNetworkElementFactory.java b/sdnr/wt/devicemanager-onap/adapter-manager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/adaptermanager/impl/AdapterManagerNetworkElementFactory.java new file mode 100644 index 000000000..0ed856fb1 --- /dev/null +++ b/sdnr/wt/devicemanager-onap/adapter-manager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/adaptermanager/impl/AdapterManagerNetworkElementFactory.java @@ -0,0 +1,43 @@ +/* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. All rights reserved. + * ================================================================================================= + * 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. + * ============LICENSE_END========================================================================== + */ + +package org.onap.ccsdk.features.sdnr.wt.devicemanager.adaptermanager.impl; + +import java.util.Optional; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.factory.NetworkElementFactory; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.service.NetworkElement; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.network.topology.simulator.rev191025.SimulatorStatus; +import org.opendaylight.yang.gen.v1.urn.o.ran.sc.params.xml.ns.yang.nts.manager.rev201006.simulation.NetworkFunctions; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class AdapterManagerNetworkElementFactory implements NetworkElementFactory { + + private static final Logger log = LoggerFactory.getLogger(AdapterManagerNetworkElementFactory.class); + + @Override + public Optional<NetworkElement> create(NetconfAccessor acessor, DeviceManagerServiceProvider serviceProvider) { + if (acessor.getCapabilites().isSupportingNamespace(SimulatorStatus.QNAME) || acessor.getCapabilites().isSupportingNamespace(NetworkFunctions.QNAME)) { + log.info("Create device {} ", NtsNetworkElement.class.getName()); + return Optional.of(new NtsNetworkElement(acessor, serviceProvider.getDataProvider())); + } + return Optional.empty(); + } +} diff --git a/sdnr/wt/devicemanager-onap/adapter-manager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/adaptermanager/impl/DeviceManagerAdapterManagerImpl.java b/sdnr/wt/devicemanager-onap/adapter-manager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/adaptermanager/impl/DeviceManagerAdapterManagerImpl.java new file mode 100644 index 000000000..3a7aa8f40 --- /dev/null +++ b/sdnr/wt/devicemanager-onap/adapter-manager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/adaptermanager/impl/DeviceManagerAdapterManagerImpl.java @@ -0,0 +1,86 @@ +/* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. All rights reserved. + * ================================================================================================= + * 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. + * ============LICENSE_END========================================================================== + */ +package org.onap.ccsdk.features.sdnr.wt.devicemanager.adaptermanager.impl; + +import org.onap.ccsdk.features.sdnr.wt.common.database.HtDatabaseClient; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.factory.FactoryRegistration; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.NetconfNetworkElementService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class DeviceManagerAdapterManagerImpl implements AutoCloseable { + + private static final Logger LOG = LoggerFactory.getLogger(DeviceManagerAdapterManagerImpl.class); + private static final String APPLICATION_NAME = "DeviceManagerAdapterManager"; + + private NetconfNetworkElementService netconfNetworkElementService; + + private HtDatabaseClient htDatabaseClient; + private Boolean devicemanagerInitializationOk = false; + private FactoryRegistration<AdapterManagerNetworkElementFactory> resAdapterManager; + + // Blueprint begin + public DeviceManagerAdapterManagerImpl() { + LOG.info("Creating provider for {}", APPLICATION_NAME); + resAdapterManager = null; + } + + public void setNetconfNetworkElementService(NetconfNetworkElementService netconfNetworkElementService) { + this.netconfNetworkElementService = netconfNetworkElementService; + } + + public void init() throws Exception { + + LOG.info("Session Initiated start {}", APPLICATION_NAME); + + resAdapterManager = netconfNetworkElementService.registerBindingNetworkElementFactory(new AdapterManagerNetworkElementFactory()); + + + netconfNetworkElementService.writeToEventLog(APPLICATION_NAME, "startup", "done"); + this.devicemanagerInitializationOk = true; + + LOG.info("Session Initiated end. Initialization done {}", devicemanagerInitializationOk); + } + // Blueprint end + + @Override + public void close() throws Exception { + LOG.info("closing ..."); + close(htDatabaseClient); + close(resAdapterManager); + LOG.info("closing done"); + } + + /** + * Used to close all Services, that should support AutoCloseable Pattern + * + * @param toClose + * @throws Exception + */ + private void close(AutoCloseable... toCloseList) { + for (AutoCloseable element : toCloseList) { + if (element != null) { + try { + element.close(); + } catch (Exception e) { + LOG.warn("Fail during close: ", e); + } + } + } + } +} diff --git a/sdnr/wt/devicemanager-onap/adapter-manager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/adaptermanager/impl/NtsNetworkElement.java b/sdnr/wt/devicemanager-onap/adapter-manager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/adaptermanager/impl/NtsNetworkElement.java new file mode 100644 index 000000000..d73d82412 --- /dev/null +++ b/sdnr/wt/devicemanager-onap/adapter-manager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/adaptermanager/impl/NtsNetworkElement.java @@ -0,0 +1,77 @@ +/* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. All rights reserved. + * ================================================================================================= + * 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. + * ============LICENSE_END========================================================================== + */ +package org.onap.ccsdk.features.sdnr.wt.devicemanager.adaptermanager.impl; + +import java.util.Optional; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.service.NetworkElement; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.service.NetworkElementService; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.NetworkElementDeviceType; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author herbert + * + */ +public class NtsNetworkElement implements NetworkElement { + + private static final Logger LOG = LoggerFactory.getLogger(NtsNetworkElement.class); + + private final NetconfAccessor netconfAccessor; + + @SuppressWarnings("unused") + private final DataProvider databaseService; + + NtsNetworkElement(NetconfAccessor netconfAccess, DataProvider databaseService) { + LOG.info("Create {}", NtsNetworkElement.class.getSimpleName()); + this.netconfAccessor = netconfAccess; + this.databaseService = databaseService; + } + + @Override + public void deregister() {} + + @Override + public NodeId getNodeId() { + return netconfAccessor.getNodeId(); + } + + @Override + public <L extends NetworkElementService> Optional<L> getService(Class<L> clazz) { + return Optional.empty(); + } + + @Override + public void warmstart() {} + + @Override + public void register() {} + + @Override + public NetworkElementDeviceType getDeviceType() { + return NetworkElementDeviceType.NtsManager; + } + + @Override + public Optional<NetconfAccessor> getAcessor() { + return Optional.of(this.netconfAccessor); + } +} diff --git a/sdnr/wt/devicemanager-onap/adapter-manager/provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml b/sdnr/wt/devicemanager-onap/adapter-manager/provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml new file mode 100644 index 000000000..a0b20b3d3 --- /dev/null +++ b/sdnr/wt/devicemanager-onap/adapter-manager/provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ~ ============LICENSE_START======================================================= + ~ ONAP : ccsdk features + ~ ================================================================================ + ~ Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. + ~ All rights reserved. + ~ ================================================================================ + ~ Update Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. + ~ ================================================================================ + ~ 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. + ~ ============LICENSE_END======================================================= + ~ + --> + +<blueprint xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0" + xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" odl:use-default-for-reference-types="true"> + + <reference id="netconfNetworkElementService" + availability="mandatory" activation="eager" + interface="org.onap.ccsdk.features.sdnr.wt.devicemanager.service.NetconfNetworkElementService"/> + + <bean id="provider" + class="org.onap.ccsdk.features.sdnr.wt.devicemanager.adaptermanager.impl.DeviceManagerAdapterManagerImpl" + init-method="init" destroy-method="close"> + <property name="netconfNetworkElementService" ref="netconfNetworkElementService"/> + </bean> +</blueprint> diff --git a/sdnr/wt/devicemanager-onap/adapter-manager/provider/src/main/resources/version.properties b/sdnr/wt/devicemanager-onap/adapter-manager/provider/src/main/resources/version.properties new file mode 100644 index 000000000..6638c04f9 --- /dev/null +++ b/sdnr/wt/devicemanager-onap/adapter-manager/provider/src/main/resources/version.properties @@ -0,0 +1,24 @@ +# +# ============LICENSE_START======================================================= +# ONAP : ccsdk features +# ================================================================================ +# Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# 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. +# ============LICENSE_END======================================================= +# +# + +# Properties filled in by maven during build process +version = ${project.version} +build = ${buildtime} diff --git a/sdnr/wt/devicemanager-onap/adapter-manager/provider/src/main/yang/network-topology-simulator.yang b/sdnr/wt/devicemanager-onap/adapter-manager/provider/src/main/yang/network-topology-simulator.yang new file mode 100644 index 000000000..ac2cf8dd3 --- /dev/null +++ b/sdnr/wt/devicemanager-onap/adapter-manager/provider/src/main/yang/network-topology-simulator.yang @@ -0,0 +1,297 @@ +module network-topology-simulator { + yang-version 1.1; + namespace "urn:onf:params:xml:ns:yang:network-topology-simulator"; + prefix network-topology-simulator; + + import ietf-inet-types { + prefix inet; + } + + organization + "Melacon"; + contact + "Web: <https://github.com/Melacon> + Editors: Alex Stancu + <mailto:stancu.liviualex@gmail.com>"; + description + "This module contains a collection of YANG definitions for managing the Network Topology Simulator."; + + revision 2019-10-25 { + description + "Modify notifications. Add VES message configuration options."; + reference + "O-RAN SC SIM project"; + } + revision 2019-06-07 { + description + "Modify controller details."; + reference + "O-RAN SC SIM project"; + } + revision 2019-03-07 { + description + "Initial version"; + reference + "O-RAN SC SIM project"; + } + + typedef operational-state-type { + type enumeration { + enum not-specified { + description + "none"; + } + enum running { + description + "none"; + } + enum created { + description + "none"; + } + enum exited { + description + "none"; + } + } + description + "The operation state of the simulated device."; + } + + typedef authentication-method-type { + type enumeration { + enum no-auth { + description + "no security (http)"; + } + enum cert-only { + description + "auth by certificate (https)"; + } + enum basic-auth { + description + "auth by basic auth username and password (https)"; + } + enum cert-basic-auth { + description + "auth by certificate and basic auth username / password (https)"; + } + } + description + "The authentication method for VES messaging."; + } + + typedef percent { + type decimal64 { + fraction-digits 2; + range "0 .. 100"; + } + description + "Percentage"; + } + + grouping controller-details-type-g { + leaf controller-ip { + type inet:ip-address; + description + "The IP Address of the SDN Controller."; + } + leaf controller-port { + type inet:port-number; + description + "The Port of the SDN Controller."; + } + leaf controller-username { + type string; + description + "The Username of the SDN Controller."; + } + leaf controller-password { + type string; + description + "The Password of the SDN Controller."; + } + description + "none"; + } + + grouping simulated-devices-type-g { + leaf uuid { + type string; + description + "The UUID of the simulated device."; + } + leaf device-ip { + type string; + description + "The IP Address of the simulated device."; + } + leaf-list device-port { + type uint32; + description + "A NETCONF endpoint (port) of the simulated device."; + } + leaf is-mounted { + type boolean; + description + "Specifies if the simulated device is mounted in the SDN Controller."; + } + leaf operational-state { + type operational-state-type; + description + "Specifies the operational state of the simulated device."; + } + description + "none"; + } + + container simulator-config { + description + "Configuration container of the simulator."; + leaf simulated-devices { + type uint32; + default "0"; + description + "The number of devices to be simulated."; + } + leaf mounted-devices { + type uint32; + default "0"; + description + "The number of devices to be mounted in ODL. The configured number should not exceed the number of mounted devices."; + } + container notification-config { + leaf fault-notification-delay-period { + type uint32; + default "0"; + description + "Interval in seconds between two consecutive notifications. If the attribute is set to 0, nofitications are not generated."; + } + leaf ves-heartbeat-period { + type uint32; + default "0"; + description + "Interval in seconds between two VES heartbeat messages. If the attribute is set to 0, heartbeat messages are not generated."; + } + leaf is-netconf-available { + type boolean; + default "true"; + description + "If set to 'true', NETCONF notifications will be generated."; + } + leaf is-ves-available { + type boolean; + default "true"; + description + "If set to 'true', VES messages will be generated."; + } + description + "none"; + } + container controller-details { + uses controller-details-type-g; + description + "The connectivity details of the SDN Controller where we want to mount our simulated devices."; + } + container ves-endpoint-details { + must 'ves-registration = "false" or ../mounted-devices = 0' { + error-message "VES registration cannot be active while devices are still mounted to ODL not via VES."; + } + leaf ves-endpoint-ip { + type inet:ip-address; + description + "The IP Address of the VES Endpoint."; + } + leaf ves-endpoint-port { + type inet:port-number; + description + "The Port of the VES Endpoint."; + } + leaf ves-endpoint-auth-method { + type authentication-method-type; + default "no-auth"; + description + "The type of the authentication to be used with the VES Endpoint."; + } + leaf ves-endpoint-username { + when "../ves-endpoint-auth-method = 'basic-auth' or ../ves-endpoint-auth-method = 'cert-basic-auth'"; + type string; + description + "The Username to be used to authenticate to the VES Endpoint."; + } + leaf ves-endpoint-password { + when "../ves-endpoint-auth-method = 'basic-auth' or ../ves-endpoint-auth-method = 'cert-basic-auth'"; + type string; + description + "The Password to be used to authenticate to the VES Endpoint."; + } + leaf ves-endpoint-certificate { + when "../ves-endpoint-auth-method = 'cert-only' or ../ves-endpoint-auth-method = 'cert-basic-auth'"; + type string; + description + "The Certificate to be used to authenticate to the VES Endpoint."; + } + leaf ves-registration { + type boolean; + default "false"; + description + "If this is set to 'True', the simulated devices will automatically send a pnfRegistration VES message when they start. This cannot be set to 'True' if we already have 'mounted-devices' greater that 0, because we already mounted the devices directly to ODL."; + } + description + "none"; + } + } + container simulator-status { + config false; + container simulation-usage-details { + config false; + leaf running-simulated-devices { + type uint32; + description + "The current number of running simulated devices."; + } + leaf running-mounted-devices { + type uint32; + description + "The current number of running simulated devices that are mounted in ODL."; + } + leaf base-netconf-port { + type uint32; + default "30000"; + description + "The starting port number for the NETCONF connections exposed."; + } + leaf cpu-usage { + type percent; + description + "Specifies the CPU load generated by this simulated device."; + } + leaf mem-usage { + type uint32; + description + "Specifies the RAM in MB used by this simulated device."; + } + description + "The details about the simulation, including resources consumed."; + } + list simulated-devices-list { + key "uuid"; + config false; + uses simulated-devices-type-g; + description + "The list of the devices that are currently simulated."; + } + description + "State data container of the simulator."; + } + + rpc restart-simulation { + description + "Operation to restart all the simulated devices with the new configuration of the simulator."; + } + + rpc add-key-pair-to-odl { + description + "Operation to add a key pair signed by the NTS to OpenDaylight, such that it can connect to devices using TLS."; + } +} diff --git a/sdnr/wt/devicemanager-onap/adapter-manager/provider/src/main/yang/nts-common.yang b/sdnr/wt/devicemanager-onap/adapter-manager/provider/src/main/yang/nts-common.yang new file mode 100644 index 000000000..ea7e60b91 --- /dev/null +++ b/sdnr/wt/devicemanager-onap/adapter-manager/provider/src/main/yang/nts-common.yang @@ -0,0 +1,354 @@ +module nts-common { + yang-version 1.1; + namespace "urn:o-ran-sc:params:xml:ns:yang:nts:common"; + prefix ntsc; + + import ietf-inet-types { + prefix inet; + } + + organization + "O-RAN-SC"; + contact + " Web: <https://wiki.o-ran-sc.org/display/SIM/SIM> + Editors: + Alex Stancu <mailto:alexandru.stancu@highstreet-technologies.com> + Adrian Lita <mailto:adrian.lita@highstreet-technologies.com> + Martin Skorupski <mailto:martin.skorupski@highstreet-technologies.com>"; + description + "This module contains common yang definitions YANG definitions for the Network Topology Simulator."; + + revision 2020-11-20 { + description + "Add feature-type for the Web cut through feature."; + reference + "O-RAN-SC SIM project"; + } + + revision 2020-10-22 { + description + "Add feature-type for the NETCONF Call Home feature."; + reference + "O-RAN-SC SIM project"; + } + + revision 2020-10-13 { + description + "Add feature-type typedef containing the features that can be activated in the Network Function."; + reference + "O-RAN-SC SIM project"; + } + + revision 2020-09-07 { + description + "Initial revision for the Network Topology Simulator - Next Generation common types."; + reference + "O-RAN-SC SIM project"; + } + + feature faults-status { + description + "This means that the server supports reporting back the number of faults that were generated"; + } + + typedef authentication-method-type { + type enumeration { + enum no-auth { + description + "no security (http)"; + } + enum cert-only { + description + "auth by certificate (https)"; + } + enum basic-auth { + description + "auth by basic auth username and password (https)"; + } + enum cert-basic-auth { + description + "auth by certificate and basic auth username / password (https)"; + } + } + description + "The authentication method for VES messaging."; + } + + typedef feature-type { + type bits { + bit ves-file-ready { + position 0; + description + "Controls the ves-file-ready feature."; + } + bit ves-heartbeat { + position 1; + description + "Controls the ves-heartbeat feature."; + } + bit ves-pnf-registration { + position 2; + description + "Controls the ves-pnf-registration feature."; + } + bit manual-notification-generation { + position 3; + description + "Controls the manual notification generation feature."; + } + bit netconf-call-home { + position 4; + description + "Controls the NETCONF Call Home feature."; + } + bit web-cut-through { + position 5; + description + "Controls the Web Cut Through feature."; + } + } + description + "Describes the features that can be enabled/disabled in the Network Function."; + } + + identity NTS_FUNCTION_TYPE_BASE { + description + "The reference of each identity represents the name of the associated docker image."; + } + + grouping mount-point-details-g { + leaf mount-point-addressing-method { + type enumeration { + enum host-mapping { + description + "Uses IP and port mapped to the host machine to address the nework function."; + } + enum docker-mapping { + description + "Uses Docker IP and port to address the nework function."; + } + } + default docker-mapping; + description + "Specifies how to address the simulated network function: via the host machine or via docker."; + } + description + "Groups details about mount point"; + } + + grouping fault-delay-period-g { + list fault-delay-list { + key index; + ordered-by user; + leaf index { + type uint16; + description + "The index of the list."; + } + leaf delay-period { + type uint16; + units s; + description + "The amount of seconds before the next event."; + } + description + "The list defining the pattern for generating events."; + } + description + "For reusing the same fault-delay-period."; + } + + grouping fault-count-g { + container fault-count { + if-feature faults-status; + config false; + leaf normal { + type uint32; + description + "Number of normal (non-alarmed) events."; + } + leaf warning { + type uint32; + description + "Number of warning events."; + } + leaf minor { + type uint32; + description + "Number of minor events."; + } + leaf major { + type uint32; + description + "Number of major events."; + } + leaf critical { + type uint32; + description + "Number of critical events."; + } + description + "Container which groups the number of fault events, by severity."; + } + description + "Grouping for counting the fault events, grouped by severity."; + } + + grouping faults-g { + container fault-generation { + uses fault-delay-period-g; + uses fault-count-g; + description + "Groups the fault generation configuration and status."; + } + description + "Grouping for fault generation"; + } + + grouping faults-enabled-g { + leaf faults-enabled { + type boolean; + description + "For enabling the fault generation."; + } + description + "Groups the enabling of faults."; + } + + grouping netconf-config-g { + container netconf { + uses faults-enabled-g; + leaf call-home { + type boolean; + description + "For enabling the NETCONF Call Home feature. If set to 'true', each simulated device, when booting up, will try to Call Home to the SDN Controller."; + } + description + "Container for describing the NETCONF details."; + } + description + "Groups the configuration and status of NETCONF Fault notifications."; + } + + grouping ves-config-g { + container ves { + uses faults-enabled-g; + leaf pnf-registration { + type boolean; + description + "For enabling the PNF Registration messages. If set to 'true', each simulated device, when booting up, will send a PNF Registration message to the VES Collector."; + } + leaf heartbeat-period { + type uint16; + description + "The number of seconds between VES heartbeat messages."; + } + description + "Container for describing the VES details."; + } + description + "Groups the configuration and status of VES Fault notifications."; + } + + grouping controller-g { + leaf controller-ip { + type inet:ip-address; + description + "The IP address of the SDN Controller."; + } + leaf controller-port { + type inet:port-number; + description + "The port exposed by the SDN Controller."; + } + leaf controller-netconf-call-home-port { + type inet:port-number; + description + "The port exposed by the SDN Controller for NETCONF Call Home."; + } + leaf controller-username { + type string; + description + "The username for accessing the SDN Controller."; + } + leaf controller-password { + type string; + description + "The password for accessing the SDN Controller."; + } + description + "Groups information about the SDN Controller."; + } + + grouping ves-endpoint-g { + leaf ves-endpoint-protocol { + type enumeration { + enum http { + description + "HTTP protocol will be used to connect to the VES Collector."; + } + enum https { + description + "HTTPS protocol will be used to connect to the VES Collector."; + } + } + default https; + description + "The protocol (HTTP / HTTPS) to be used to address the VES Collector."; + } + leaf ves-endpoint-ip { + type inet:ip-address; + description + "The IP address of the VES Collector."; + } + leaf ves-endpoint-port { + type inet:port-number; + description + "The port exposed by the VES Collector."; + } + leaf ves-endpoint-auth-method { + type authentication-method-type; + default "no-auth"; + description + "The type of the authentication to be used with the VES Collector."; + } + leaf ves-endpoint-username { + type string; + description + "The username for accessing the VES Collector."; + } + leaf ves-endpoint-password { + type string; + description + "The password for accessing the VES Collector."; + } + leaf ves-endpoint-certificate { + type string; + description + "The Certificate to be used to authenticate to the VES Collector."; + } + description + "Groups information about the VES Collector."; + } + + grouping rpc-status-g { + leaf status { + type enumeration { + enum SUCCESS { + description + "The RPC was successfully invoked."; + } + enum ERROR { + description + "An error was encountered when invoking the RPC."; + } + } + mandatory true; + description + "The status of the RPC."; + } + description + "RPC output grouping."; + } + +} //end module
\ No newline at end of file diff --git a/sdnr/wt/devicemanager-onap/adapter-manager/provider/src/main/yang/nts-manager.yang b/sdnr/wt/devicemanager-onap/adapter-manager/provider/src/main/yang/nts-manager.yang new file mode 100644 index 000000000..08214d52c --- /dev/null +++ b/sdnr/wt/devicemanager-onap/adapter-manager/provider/src/main/yang/nts-manager.yang @@ -0,0 +1,202 @@ +module nts-manager { + yang-version 1.1; + namespace "urn:o-ran-sc:params:xml:ns:yang:nts:manager"; + prefix nts-mng; + + import ietf-inet-types { + prefix inet; + } + + import nts-common { + prefix ntsc; + revision-date 2020-11-20; + } + + organization + "O-RAN-SC"; + contact + " Web: <https://wiki.o-ran-sc.org/display/SIM/SIM> + Editors: + Alex Stancu <mailto:alexandru.stancu@highstreet-technologies.com> + Adrian Lita <mailto:adrian.lita@highstreet-technologies.com> + Martin Skorupski <mailto:martin.skorupski@highstreet-technologies.com>"; + description + "This module contains YANG definitions for the Network Topology Simulator - Manager."; + + revision 2020-10-06 { + description + "Initial revision for the Network Topology Simulator - Next Generation"; + reference + "O-RAN-SC SIM project"; + } + + typedef percent { + type decimal64 { + fraction-digits 2; + range "0 .. 100"; + } + description + "Percentage"; + } + + grouping instance-g { + leaf name { + type string; + description + "The name of the running instance. It is the same as the docker container name which exposes this network function."; + } + container networking { + leaf docker-ip { + type inet:ip-address; + description + "The IP address of the docker container implementing the network function instance."; + } + leaf-list docker-port { + type inet:port-number; + description + "The ports which are exposed inside the docker container implementing the network function instance."; + } + leaf host-ip { + type inet:ip-address; + description + "The Host machine IP address pointing to the docker container implementing the network function instance."; + } + leaf-list host-port { + type inet:port-number; + description + "The Host machine ports mapped to the docker container implementing the network function instance."; + } + description + "Groups the details about networking information."; + } + description + "An instance of a network function which is running. The equivalent on the host machine is a docker container."; + } + grouping network-function-g { + leaf function-type { + type identityref { + base ntsc:NTS_FUNCTION_TYPE_BASE; + } + description "Type of network function to be simulated."; + } + leaf started-instances { + type uint16; + mandatory true; + description + "How many instances of this type are started."; + } + leaf mounted-instances { + type uint16; + must '. <= ../started-instances' { + error-message + "The number of mounted instances cannot be greater that the number of started instances."; + } + mandatory true; + description + "How many instances of this type are mounted in the SDN Controller."; + } + + uses ntsc:mount-point-details-g; + + leaf docker-instance-name { + type string; + mandatory true; + description + "The prefix of each docker container being started."; + } + + leaf docker-version-tag { + type string; + mandatory true; + description + "The version tag of the docker image to be started."; + } + + leaf docker-repository { + type string; + mandatory true; + description + "The prefix containing the docker repository information, if needed."; + } + uses ntsc:faults-g; + uses ntsc:netconf-config-g; + uses ntsc:ves-config-g; + container instances { + config false; + list instance { + key "name"; + uses ntsc:mount-point-details-g; + uses instance-g; + description + "Describes a running instance."; + } + description + "Groups details about instances which are running."; + } + description + "Contains all the details of a simulated device."; + } + grouping simulation-information-g { + leaf base-port { + type inet:port-number; + config false; + description + "The base Host machine port from where the simulation can allocate ports incrementally."; + } + leaf ssh-connections { + type uint8; + config false; + description + "The number of SSH Endpoints each network function instance exposes."; + } + leaf tls-connections { + type uint8; + config false; + description + "The number of TLS Endpoints each network function instance exposes."; + } + leaf cpu-usage { + type percent; + config false; + description + "Specifies the CPU load generated by the simulation."; + } + leaf mem-usage { + type uint32; + config false; + description + "Specifies the RAM in MB used by the simulation."; + } + description + "Groups information about the simulation status."; + } + + container simulation { + container network-functions { + list network-function { + key "function-type"; + unique "docker-instance-name"; + uses network-function-g; + description + "List containing different simulated network function types and their details."; + } + description + "Container which encompasses all simulated network functions."; + } + container sdn-controller { + uses ntsc:controller-g; + description + "Groups details about the SDN Controller."; + } + container ves-endpoint { + uses ntsc:ves-endpoint-g; + description + "Groups details about the VES Collector endpoint."; + } + uses simulation-information-g; + description + "Root level container which controls the NTS."; + } + + +} //end module
\ No newline at end of file diff --git a/sdnr/wt/devicemanager-onap/adapter-manager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/adaptermanager/test/TestAdapterManagerNetworkElement.java b/sdnr/wt/devicemanager-onap/adapter-manager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/adaptermanager/test/TestAdapterManagerNetworkElement.java new file mode 100644 index 000000000..d067d538f --- /dev/null +++ b/sdnr/wt/devicemanager-onap/adapter-manager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/adaptermanager/test/TestAdapterManagerNetworkElement.java @@ -0,0 +1,81 @@ +/* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. All rights reserved. + * ================================================================================================= + * 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. + * ============LICENSE_END========================================================================== + */ +package org.onap.ccsdk.features.sdnr.wt.devicemanager.adaptermanager.test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; +import java.io.IOException; +import java.util.Optional; +import org.junit.After; +import org.junit.BeforeClass; +import org.junit.Test; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.adaptermanager.impl.AdapterManagerNetworkElementFactory; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.service.NetworkElement; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.Capabilities; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfBindingAccessor; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.TransactionUtils; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.network.topology.simulator.rev191025.SimulatorStatus; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; +import org.opendaylight.yangtools.yang.common.QName; + +public class TestAdapterManagerNetworkElement { + + static NetconfBindingAccessor accessor; + static DeviceManagerServiceProvider serviceProvider; + static Capabilities capabilities; + QName qCapability; + + @BeforeClass + public static void init() throws InterruptedException, IOException { + capabilities = mock(Capabilities.class); + //accessor = mock(NetconfAccessorMock.class); + accessor = mock(NetconfBindingAccessor.class); //spy(new NetconfAccessorMock(null, null, null, null)); + serviceProvider = mock(DeviceManagerServiceProvider.class); + + NodeId nNodeId = new NodeId("nSky"); + when(accessor.getCapabilites()).thenReturn(capabilities); + when(accessor.getNodeId()).thenReturn(nNodeId); + when(accessor.getTransactionUtils()).thenReturn(mock(TransactionUtils.class)); + + DataProvider dataProvider = mock(DataProvider.class); + when(serviceProvider.getDataProvider()).thenReturn(dataProvider); + } + + @Test + public void test() { + Optional<NetworkElement> adapterManagerNe; + when(accessor.getCapabilites().isSupportingNamespace(SimulatorStatus.QNAME)).thenReturn(true); + AdapterManagerNetworkElementFactory factory = new AdapterManagerNetworkElementFactory(); + adapterManagerNe = factory.create(accessor, serviceProvider); + assertTrue(factory.create(accessor, serviceProvider).isPresent()); + adapterManagerNe.get().register(); + adapterManagerNe.get().deregister(); + adapterManagerNe.get().getAcessor(); + adapterManagerNe.get().getDeviceType(); + assertEquals(adapterManagerNe.get().getNodeId().getValue(), "nSky"); + } + + @After + public void cleanUp() throws Exception { + + } +} diff --git a/sdnr/wt/devicemanager-onap/adapter-manager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/adaptermanager/test/TestAdapterManagerNetworkElementFactory.java b/sdnr/wt/devicemanager-onap/adapter-manager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/adaptermanager/test/TestAdapterManagerNetworkElementFactory.java new file mode 100644 index 000000000..fce5f6b88 --- /dev/null +++ b/sdnr/wt/devicemanager-onap/adapter-manager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/adaptermanager/test/TestAdapterManagerNetworkElementFactory.java @@ -0,0 +1,72 @@ +/* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. All rights reserved. + * ================================================================================================= + * 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. + * ============LICENSE_END========================================================================== + */ +package org.onap.ccsdk.features.sdnr.wt.devicemanager.adaptermanager.test; + +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; +import java.io.IOException; +import org.junit.After; +import org.junit.BeforeClass; +import org.junit.Test; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.adaptermanager.impl.AdapterManagerNetworkElementFactory; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.Capabilities; +import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfBindingAccessor; +import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.network.topology.simulator.rev191025.SimulatorStatus; +import org.opendaylight.yangtools.yang.common.QName; + +public class TestAdapterManagerNetworkElementFactory { + + static NetconfBindingAccessor accessor; + static DeviceManagerServiceProvider serviceProvider; + static Capabilities capabilities; + QName qCapability; + + @BeforeClass + public static void init() throws InterruptedException, IOException { + capabilities = mock(Capabilities.class); + accessor = mock(NetconfBindingAccessor.class); + serviceProvider = mock(DeviceManagerServiceProvider.class); + + when(accessor.getCapabilites()).thenReturn(capabilities); + when(serviceProvider.getDataProvider()).thenReturn(null); + + + } + + @Test + public void testCreateSimulator() throws Exception { + when(accessor.getCapabilites().isSupportingNamespace(SimulatorStatus.QNAME)).thenReturn(true); + AdapterManagerNetworkElementFactory factory = new AdapterManagerNetworkElementFactory(); + assertTrue(factory.create(accessor, serviceProvider).isPresent()); + } + + @Test + public void testCreateNone() throws Exception { + when(accessor.getCapabilites().isSupportingNamespace(SimulatorStatus.QNAME)).thenReturn(false); + AdapterManagerNetworkElementFactory factory = new AdapterManagerNetworkElementFactory(); + assertTrue(!(factory.create(accessor, serviceProvider).isPresent())); + } + + @After + public void cleanUp() throws Exception { + + } +} + diff --git a/sdnr/wt/devicemanager-onap/adapter-manager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/adaptermanager/test/TestDeviceManagerAdapterManagerImpl.java b/sdnr/wt/devicemanager-onap/adapter-manager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/adaptermanager/test/TestDeviceManagerAdapterManagerImpl.java new file mode 100644 index 000000000..3f53abfa8 --- /dev/null +++ b/sdnr/wt/devicemanager-onap/adapter-manager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/adaptermanager/test/TestDeviceManagerAdapterManagerImpl.java @@ -0,0 +1,42 @@ +/* + * ============LICENSE_START======================================================================== + * ONAP : ccsdk feature sdnr wt + * ================================================================================================= + * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. All rights reserved. + * ================================================================================================= + * 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. + * ============LICENSE_END========================================================================== + */ +package org.onap.ccsdk.features.sdnr.wt.devicemanager.adaptermanager.test; + +import static org.mockito.Mockito.mock; +import org.junit.After; +import org.junit.Test; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.adaptermanager.impl.DeviceManagerAdapterManagerImpl; +import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.NetconfNetworkElementService; + +public class TestDeviceManagerAdapterManagerImpl { + DeviceManagerAdapterManagerImpl devMgrAdapterManager; + + @Test + public void test() throws Exception { + devMgrAdapterManager = new DeviceManagerAdapterManagerImpl(); + NetconfNetworkElementService netConfNetworkElementService = mock(NetconfNetworkElementService.class); + + devMgrAdapterManager.setNetconfNetworkElementService(netConfNetworkElementService); + devMgrAdapterManager.init(); + } + + @After + public void cleanUp() throws Exception { + devMgrAdapterManager.close(); + } + } diff --git a/sdnr/wt/devicemanager-onap/adapter-manager/provider/src/test/resources/simplelogger.properties b/sdnr/wt/devicemanager-onap/adapter-manager/provider/src/test/resources/simplelogger.properties new file mode 100644 index 000000000..9af26dc96 --- /dev/null +++ b/sdnr/wt/devicemanager-onap/adapter-manager/provider/src/test/resources/simplelogger.properties @@ -0,0 +1,61 @@ +# +# ============LICENSE_START======================================================= +# ONAP : ccsdk features +# ================================================================================ +# Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# 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. +# ============LICENSE_END======================================================= +# +# + +# SLF4J's SimpleLogger configuration file +# Simple implementation of Logger that sends all enabled log messages, for all defined loggers, to System.err. + +# Default logging detail level for all instances of SimpleLogger. +# Must be one of ("trace", "debug", "info", "warn", or "error"). +# If not specified, defaults to "info". +org.slf4j.simpleLogger.defaultLogLevel=info + +# Logging detail level for a SimpleLogger instance named "xxx.yyy.zzz". +# Must be one of ("trace", "debug", "info", "warn", or "error"). +# If not specified, the default logging detail level is used. +# org.slf4j.simpleLogger.log.xxx.yyy=debug +org.slf4j.simpleLogger.log.org.onap.ccsdk.features.sdnr.wt.devicemanager=info +org.slf4j.simpleLogger.log.org.onap.ccsdk.features.sdnr.wt.devicemanager.test=debug +org.slf4j.simpleLogger.log.org.onap.ccsdk.features.sdnr.wt.database=debug +org.slf4j.simpleLogger.log.org.onap.ccsdk.features.sdnr.wt.devicemanager.archiveservice=info +org.slf4j.simpleLogger.log.org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.Resources=info +org.slf4j.simpleLogger.log.org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.container=info + +# Set to true if you want the current date and time to be included in output messages. +# Default is false, and will output the number of milliseconds elapsed since startup. +#org.slf4j.simpleLogger.showDateTime=false + +# The date and time format to be used in the output messages. +# The pattern describing the date and time format is the same that is used in java.text.SimpleDateFormat. +# If the format is not specified or is invalid, the default format is used. +# The default format is yyyy-MM-dd HH:mm:ss:SSS Z. +#org.slf4j.simpleLogger.dateTimeFormat=yyyy-MM-dd HH:mm:ss:SSS Z + +# Set to true if you want to output the current thread name. +# Defaults to true. +#org.slf4j.simpleLogger.showThreadName=true + +# Set to true if you want the Logger instance name to be included in output messages. +# Defaults to true. +#org.slf4j.simpleLogger.showLogName=true + +# Set to true if you want the last component of the name to be included in output messages. +# Defaults to false. +#org.slf4j.simpleLogger.showShortLogName=false |