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;
25 import java.util.ArrayList;
26 import java.util.List;
28 import java.util.HashMap;
30 import com.woorea.openstack.quantum.model.Network;
31 import com.woorea.openstack.quantum.model.Segment;
34 * This Java bean class relays Network details (including status) to ActiveVOS processes.
36 * This bean is returned by all Network-specific adapter operations (create, query, delete)
39 public class NetworkInfo {
40 // Set defaults for everything
41 private String name = "";
42 private String id = "";
43 private NetworkStatus status = NetworkStatus.UNKNOWN;
44 private String provider = "";
45 private List<Integer> vlans = new ArrayList<>();
46 private List<String> subnets = new ArrayList<>();
47 private String shared = "";
49 static Map<String,NetworkStatus> NetworkStatusMap;
51 NetworkStatusMap = new HashMap<>();
52 NetworkStatusMap.put("ACTIVE", NetworkStatus.ACTIVE);
53 NetworkStatusMap.put("DOWN", NetworkStatus.DOWN);
54 NetworkStatusMap.put("BUILD", NetworkStatus.BUILD);
55 NetworkStatusMap.put("ERROR", NetworkStatus.ERROR);
58 public NetworkInfo () {
61 public NetworkInfo (String name, NetworkStatus status) {
63 this.id = name; // Don't have an ID, so just use name
68 * Capture the data from a Neutron Network object.
70 * For MSO, there are assumptions regarding all networks.
71 * - Everything will be a provider network
72 * - All provider networks are VLANs
73 * - Multiple VLANs are supported, and indicated by multi-provider segments.
74 * Each will have the same physical network & network type "vlan".
78 public NetworkInfo (Network network)
80 if (network == null) {
81 this.status = NetworkStatus.NOTFOUND;
85 this.name = network.getName();
86 this.id = network.getId();
88 if (network.getStatus() == null) {
89 // Can this happen on a newly created network?
90 this.status = NetworkStatus.UNKNOWN;
91 } else if (NetworkStatusMap.containsKey(network.getStatus())) {
92 this.status = NetworkStatusMap.get(network.getStatus());
94 this.status = NetworkStatus.UNKNOWN;
97 if (network.getProviderPhysicalNetwork() != null) {
98 this.provider = network.getProviderPhysicalNetwork();
99 if ("vlan".equals(network.getProviderNetworkType())) {
100 this.vlans.add(network.getProviderSegmentationId());
103 else if (network.getSegments() != null && !network.getSegments().isEmpty()) {
104 Segment s = network.getSegments().get(0);
105 this.provider = s.getProviderPhysicalNetwork();
106 if ("vlan".equals(s.getProviderNetworkType())) {
107 for (Segment s1 : network.getSegments()) {
108 this.vlans.add(s1.getProviderSegmentationId());
112 this.subnets = network.getSubnets();
115 public String getName() {
119 public void setName (String name) {
123 public String getId() {
127 public void setId (String id) {
131 public NetworkStatus getStatus() {
135 public void setStatus (NetworkStatus status) {
136 this.status = status;
139 public String getProvider() {
143 public void setProvider (String provider) {
144 this.provider = provider;
147 public List<Integer> getVlans () {
151 public void setVlans (List<Integer> vlans) {
155 public List<String> getSubnets () {
159 public void setSubnets (List<String> subnets) {
160 this.subnets = subnets;
163 public String getShared() {
167 public void setShared(String shared) {
168 this.shared = shared;
172 public String toString () {
173 return "Network: name=" + name + ",id=" + id + ",status=" + status +
174 ",provider=" + provider + ",vlans=" + vlans + ",subnets=" + subnets + ",shared=" + shared;