2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.mso.openstack.beans;
23 import java.util.ArrayList;
24 import java.util.List;
26 import java.util.HashMap;
28 import com.woorea.openstack.quantum.model.Network;
29 import com.woorea.openstack.quantum.model.Segment;
32 * This Java bean class relays Network details (including status) to ActiveVOS processes.
34 * This bean is returned by all Network-specific adapter operations (create, query, delete)
36 public class NetworkInfo {
37 // Set defaults for everything
38 private String name = "";
39 private String id = "";
40 private NetworkStatus status = NetworkStatus.UNKNOWN;
41 private String provider = "";
42 private List<Integer> vlans = new ArrayList<>();
43 private List<String> subnets = new ArrayList<>();
45 static Map<String,NetworkStatus> NetworkStatusMap;
47 NetworkStatusMap = new HashMap<>();
48 NetworkStatusMap.put("ACTIVE", NetworkStatus.ACTIVE);
49 NetworkStatusMap.put("DOWN", NetworkStatus.DOWN);
50 NetworkStatusMap.put("BUILD", NetworkStatus.BUILD);
51 NetworkStatusMap.put("ERROR", NetworkStatus.ERROR);
55 * Capture the data from a Neutron Network object.
57 * For MSO, there are assumptions regarding all networks.
58 * - Everything will be a provider network
59 * - All provider networks are VLANs
60 * - Multiple VLANs are supported, and indicated by multi-provider segments.
61 * Each will have the same physical network & network type "vlan".
65 public NetworkInfo(Network network) {
66 if (network != null) {
67 initFieldsWithDataFromNetwork(network);
69 status = NetworkStatus.NOTFOUND;
73 private void initFieldsWithDataFromNetwork(Network network){
74 name = network.getName();
77 if (network.getStatus() != null && NetworkStatusMap.containsKey(network.getStatus())) {
78 status = NetworkStatusMap.get(network.getStatus());
80 if (network.getProviderPhysicalNetwork() != null) {
81 provider = network.getProviderPhysicalNetwork();
82 if ("vlan".equals(network.getProviderNetworkType())) {
83 vlans.add(network.getProviderSegmentationId());
86 else if (network.getSegments() != null && !network.getSegments().isEmpty()) {
87 Segment s = network.getSegments().get(0);
88 provider = s.getProviderPhysicalNetwork();
89 if ("vlan".equals(s.getProviderNetworkType())) {
90 network.getSegments().forEach(segment -> vlans.add(segment.getProviderSegmentationId()));
93 subnets = network.getSubnets();
96 public String getName() {
100 public void setName (String name) {
104 public String getId() {
108 public void setId (String id) {
112 public NetworkStatus getStatus() {
116 public void setStatus (NetworkStatus status) {
117 this.status = status;
120 public String getProvider() {
124 public void setProvider (String provider) {
125 this.provider = provider;
128 public List<Integer> getVlans () {
132 public void setVlans (List<Integer> vlans) {
136 public List<String> getSubnets () {
141 public String toString() {
142 return "NetworkInfo{" + "name='" + name + '\'' +
143 ", id='" + id + '\'' +
144 ", status=" + status +
145 ", provider='" + provider + '\'' +
147 ", subnets=" + subnets +