2 * Copyright 2017 ZTE Corporation.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org.onap.aai.esr.util;
19 import java.util.ArrayList;
21 import org.onap.aai.esr.common.SystemType;
22 import org.onap.aai.esr.entity.aai.EsrSystemInfo;
23 import org.onap.aai.esr.entity.aai.CloudRegionDetail;
24 import org.onap.aai.esr.entity.aai.EsrSystemInfoList;
25 import org.onap.aai.esr.entity.rest.VimAuthInfo;
26 import org.onap.aai.esr.entity.rest.VimRegisterInfo;
29 public class VimManagerUtil {
30 private static ExtsysUtil extsysUtil = new ExtsysUtil();
32 public CloudRegionDetail vimRegisterInfo2CloudRegion(VimRegisterInfo vimRegisterInfo) {
33 CloudRegionDetail cloudRegion = new CloudRegionDetail();
34 EsrSystemInfoList esrSystemInfoList = new EsrSystemInfoList();
35 EsrSystemInfo esrSystemInfoObj = new EsrSystemInfo();
37 cloudRegion.setCloudOwner(vimRegisterInfo.getCloudOwner());
38 cloudRegion.setCloudRegionId(vimRegisterInfo.getCloudRegionId());
39 cloudRegion.setCloudType(vimRegisterInfo.getCloudType());
40 cloudRegion.setCloudRegionVersion(vimRegisterInfo.getCloudRegionVersion());
41 cloudRegion.setCloudZone(vimRegisterInfo.getCloudZone());
42 cloudRegion.setComplexName(vimRegisterInfo.getComplexName());
43 cloudRegion.setOwnerDefinedType(vimRegisterInfo.getOwnerDefinedType());
44 cloudRegion.setCloudExtraInfo(vimRegisterInfo.getCloudExtraInfo());
46 esrSystemInfoObj = vimAuthInfo2EsrSystemInfoObj(vimRegisterInfo.getVimAuthInfos());
47 esrSystemInfoObj.setSystemStatus(vimRegisterInfo.getStatus());
48 esrSystemInfoList = extsysUtil.getEsrSystemInfoListFromAuthInfo(esrSystemInfoObj);
49 cloudRegion.setEsrSystemInfoList(esrSystemInfoList);
53 private EsrSystemInfo vimAuthInfo2EsrSystemInfoObj(ArrayList<VimAuthInfo> vimAuthInfos) {
54 EsrSystemInfo esrSystemInfoObj = new EsrSystemInfo();
55 VimAuthInfo vimAuthInfo = new VimAuthInfo();
56 vimAuthInfo = vimAuthInfos.get(0);
57 esrSystemInfoObj.setCloudDomain(vimAuthInfo.getCloudDomain());
58 esrSystemInfoObj.setUserName(vimAuthInfo.getUserName());
59 esrSystemInfoObj.setPassword(vimAuthInfo.getPassword());
60 esrSystemInfoObj.setServiceUrl(vimAuthInfo.getAuthUrl());
61 esrSystemInfoObj.setSslCassert(vimAuthInfo.getSslCacert());
62 esrSystemInfoObj.setSslInsecure(vimAuthInfo.getSslInsecure());
63 esrSystemInfoObj.setEsrSystemInfoId(ExtsysUtil.generateId());
64 esrSystemInfoObj.setSystemType(SystemType.VIM.toString());
65 // esrSystemInfoObj.setSystemStatus(SystemStatus.normal.toString());
66 return esrSystemInfoObj;
69 private VimAuthInfo authInfo2VimAuthInfo(EsrSystemInfo authInfo) {
70 VimAuthInfo vimAuthInfo = new VimAuthInfo();
71 vimAuthInfo.setAuthUrl(authInfo.getServiceUrl());
72 vimAuthInfo.setCloudDomain(authInfo.getCloudDomain());
73 vimAuthInfo.setPassword(authInfo.getPassword());
74 vimAuthInfo.setSslCacert(authInfo.getSslCassert());
75 vimAuthInfo.setSslInsecure(authInfo.getSslInsecure());
76 vimAuthInfo.setUserName(authInfo.getUserName());
80 public VimRegisterInfo cloudRegion2VimRegisterInfo(CloudRegionDetail cloudRegion) {
81 VimRegisterInfo vimRegisterInfo = new VimRegisterInfo();
82 VimAuthInfo vimAuthInfo = new VimAuthInfo();
83 ArrayList<VimAuthInfo> vimAuthInfos = new ArrayList<VimAuthInfo>();
84 vimAuthInfo = authInfo2VimAuthInfo(cloudRegion.getEsrSystemInfoList().getEsrSystemInfo().get(0));
85 vimAuthInfos.add(vimAuthInfo);
86 vimRegisterInfo.setVimAuthInfos(vimAuthInfos);
87 vimRegisterInfo.setCloudExtraInfo(cloudRegion.getCloudExtraInfo());
88 vimRegisterInfo.setCloudOwner(cloudRegion.getCloudOwner());
89 vimRegisterInfo.setCloudRegionId(cloudRegion.getCloudRegionId());
90 vimRegisterInfo.setCloudType(cloudRegion.getCloudType());
91 vimRegisterInfo.setCloudZone(cloudRegion.getCloudZone());
92 vimRegisterInfo.setComplexName(cloudRegion.getComplexName());
93 vimRegisterInfo.setCloudRegionVersion(cloudRegion.getCloudRegionVersion());
94 vimRegisterInfo.setOwnerDefinedType(cloudRegion.getOwnerDefinedType());
95 vimRegisterInfo.setStatus(cloudRegion.getEsrSystemInfoList().getEsrSystemInfo().get(0).getSystemStatus());
96 return vimRegisterInfo;