2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
22 package org.onap.ccsdk.sli.northbound.uebclient;
24 import org.openecomp.sdc.tosca.parser.api.ISdcCsarHelper;
25 import org.openecomp.sdc.tosca.parser.impl.SdcPropertyNames;
26 import org.openecomp.sdc.toscaparser.api.NodeTemplate;
27 import org.slf4j.Logger;
28 import org.slf4j.LoggerFactory;
30 public class SdncNodeModel extends SdncBaseModel {
32 private static final Logger LOG = LoggerFactory
33 .getLogger(SdncNodeModel.class);
35 private String serviceUUID = null;
36 private String ecompGeneratedNaming = null;
37 private String [] bindingUuids = null;
39 // Using ASDC TOSCA Parser 17.07
40 public SdncNodeModel(ISdcCsarHelper sdcCsarHelper, NodeTemplate nodeTemplate) {
42 super(sdcCsarHelper, nodeTemplate);
45 String ecompGeneratedNaming = extractBooleanInputDefaultValue(SdcPropertyNames.PROPERTY_NAME_SERVICENAMING_DEFAULT_ECOMPGENERATEDNAMING);
46 addParameter("ecomp_generated_naming",ecompGeneratedNaming);
47 addParameter("naming_policy", extractInputDefaultValue(SdcPropertyNames.PROPERTY_NAME_SERVICENAMING_DEFAULT_NAMINGPOLICY));
50 addParameter("network_type", extractValue (nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKTYPE));
51 addParameter("network_role", extractValue (nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKROLE));
52 addParameter("network_scope", extractValue (nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKSCOPE));
53 addParameter("network_technology", extractValue (nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKTECHNOLOGY));
55 // extract properties - network_assignments
56 addParameter("is_shared_network", extractBooleanValue (nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKASSIGNMENTS_ISSHAREDNETWORK));
57 addParameter("is_external_network", extractBooleanValue (nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKASSIGNMENTS_ISEXTERNALNETWORK));
59 // extract properties - network_assignments - ipv4_subnet_default_assignment
60 String useIpv4 = extractBooleanValue(nodeTemplate, "network_assignments#ipv4_subnet_default_assignment#use_ipv4");
61 addParameter("use_ipv4", useIpv4);
62 addParameter("ipv4_dhcp_enabled", extractBooleanValue(nodeTemplate, "network_assignments#ipv4_subnet_default_assignment#dhcp_enabled"));
63 if (useIpv4.contains("Y")) {
64 addParameter("ipv4_ip_version", "ipv4");
66 addParameter("ipv4_cidr_mask", extractValue(nodeTemplate, "network_assignments#ipv4_subnet_default_assignment#cidr_mask"));
67 addParameter("eipam_v4_address_plan", extractValue(nodeTemplate, "network_assignments#ipv4_subnet_default_assignment#ip_network_address_plan"));
69 // extract properties - network_assignments - ipv6_subnet_default_assignment
70 String useIpv6 = extractBooleanValue(nodeTemplate, "network_assignments#ipv6_subnet_default_assignment#use_ipv6");
71 addParameter("use_ipv6", useIpv6);
72 addParameter("ipv6_dhcp_enabled", extractBooleanValue(nodeTemplate, "network_assignments#ipv6_subnet_default_assignment#dhcp_enabled"));
73 if (useIpv6.contains("Y")) {
74 addParameter("ipv6_ip_version", "ipv6");
76 addParameter("ipv6_cidr_mask", extractValue(nodeTemplate, "network_assignments#ipv6_subnet_default_assignment#cidr_mask"));
77 addParameter("eipam_v6_address_plan", extractValue(nodeTemplate, "network_assignments#ipv6_subnet_default_assignment#ip_network_address_plan"));
79 // extract properties - provider_network
80 addParameter("is_provider_network", extractBooleanValue (nodeTemplate, SdcPropertyNames.PROPERTY_NAME_PROVIDERNETWORK_ISPROVIDERNETWORK));
81 addParameter("physical_network_name", extractValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_PROVIDERNETWORK_PHYSICALNETWORKNAME));
83 // extract properties - network_flows
84 addParameter("is_bound_to_vpn", extractBooleanValue (nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKFLOWS_ISBOUNDTOVPN));
86 // extract properties - network_flows - vpn_bindings
87 String vpnBindingString = extractValue (nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKFLOWS_VPNBINDING);
88 bindingUuids = vpnBindingString.split(",");
92 public String getServiceUUID() {
95 public void setServiceUUID(String serviceUUID) {
96 this.serviceUUID = serviceUUID;
99 public String getEcompGeneratedNaming() {
100 return ecompGeneratedNaming;
102 public void setEcompGeneratedNaming(String ecompGeneratedNaming) {
103 this.ecompGeneratedNaming = ecompGeneratedNaming;
104 if (ecompGeneratedNaming != null && !ecompGeneratedNaming.isEmpty()) {
105 params.put("ecomp_generated_naming", "\"" + ecompGeneratedNaming + "\"");
109 public String getSql(String model_yaml) {
111 StringBuilder sb = new StringBuilder();
112 sb.append("INSERT into NETWORK_MODEL (service_uuid, customization_uuid, model_yaml, ");
115 for (String paramKey : params.keySet()) {
118 if (paramCount < params.size()) sb.append(", ");
121 sb.append(") values (" + serviceUUID + ", " + getCustomizationUUID() + ", \"" + model_yaml + "\", ");
124 for (String paramKey : params.keySet()) {
126 String paramValue = params.get(paramKey);
127 sb.append(paramValue);
128 if (paramCount < params.size()) sb.append(", ");
132 return sb.toString();
135 public String getVpnBindingsSql() {
137 StringBuilder sb = new StringBuilder();
138 for (int i=0; i < bindingUuids.length; i++) {
139 sb.append("INSERT into VPN_BINDINGS (network_customization_uuid, binding_uuid) values (" + getCustomizationUUID() + ", \"" + bindingUuids[i] + "\"); ");
142 return sb.toString();