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 {
31 public CloudRegionDetail vimRegisterInfo2CloudRegion(VimRegisterInfo vimRegisterInfo) {
32 CloudRegionDetail cloudRegion = new CloudRegionDetail();
33 EsrSystemInfoList esrSystemInfoList = new EsrSystemInfoList();
34 EsrSystemInfo esrSystemInfoObj = new EsrSystemInfo();
36 cloudRegion.setCloudOwner(vimRegisterInfo.getCloudOwner());
37 cloudRegion.setCloudRegionId(vimRegisterInfo.getCloudRegionId());
38 cloudRegion.setCloudType(vimRegisterInfo.getCloudType());
39 cloudRegion.setCloudRegionVersion(vimRegisterInfo.getCloudRegionVersion());
40 cloudRegion.setCloudZone(vimRegisterInfo.getCloudZone());
41 cloudRegion.setComplexName(vimRegisterInfo.getComplexName());
42 cloudRegion.setOwnerDefinedType(vimRegisterInfo.getOwnerDefinedType());
43 cloudRegion.setCloudExtraInfo(vimRegisterInfo.getCloudExtraInfo());
45 esrSystemInfoObj = vimAuthInfo2EsrSystemInfoObj(vimRegisterInfo.getVimAuthInfos());
46 esrSystemInfoObj.setSystemStatus(vimRegisterInfo.getStatus());
47 esrSystemInfoList = ExtsysUtil.getEsrSystemInfoListFromAuthInfo(esrSystemInfoObj);
48 cloudRegion.setEsrSystemInfoList(esrSystemInfoList);
52 private EsrSystemInfo vimAuthInfo2EsrSystemInfoObj(ArrayList<VimAuthInfo> vimAuthInfos) {
53 EsrSystemInfo esrSystemInfoObj = new EsrSystemInfo();
54 VimAuthInfo vimAuthInfo = new VimAuthInfo();
55 vimAuthInfo = vimAuthInfos.get(0);
56 esrSystemInfoObj.setCloudDomain(vimAuthInfo.getCloudDomain());
57 esrSystemInfoObj.setUserName(vimAuthInfo.getUserName());
58 esrSystemInfoObj.setPassword(vimAuthInfo.getPassword());
59 esrSystemInfoObj.setServiceUrl(vimAuthInfo.getAuthUrl());
60 esrSystemInfoObj.setSslCassert(vimAuthInfo.getSslCacert());
61 esrSystemInfoObj.setSslInsecure(vimAuthInfo.getSslInsecure());
62 esrSystemInfoObj.setEsrSystemInfoId(ExtsysUtil.generateId());
63 esrSystemInfoObj.setSystemType(SystemType.VIM.toString());
64 // esrSystemInfoObj.setSystemStatus(SystemStatus.normal.toString());
65 return esrSystemInfoObj;
68 private VimAuthInfo authInfo2VimAuthInfo(EsrSystemInfo authInfo) {
69 VimAuthInfo vimAuthInfo = new VimAuthInfo();
70 vimAuthInfo.setAuthUrl(authInfo.getServiceUrl());
71 vimAuthInfo.setCloudDomain(authInfo.getCloudDomain());
72 vimAuthInfo.setPassword(authInfo.getPassword());
73 vimAuthInfo.setSslCacert(authInfo.getSslCassert());
74 vimAuthInfo.setSslInsecure(authInfo.getSslInsecure());
75 vimAuthInfo.setUserName(authInfo.getUserName());
79 public VimRegisterInfo cloudRegion2VimRegisterInfo(CloudRegionDetail cloudRegion) {
80 VimRegisterInfo vimRegisterInfo = new VimRegisterInfo();
81 VimAuthInfo vimAuthInfo = new VimAuthInfo();
82 ArrayList<VimAuthInfo> vimAuthInfos = new ArrayList<VimAuthInfo>();
83 vimAuthInfo = authInfo2VimAuthInfo(cloudRegion.getEsrSystemInfoList().getEsrSystemInfo().get(0));
84 vimAuthInfos.add(vimAuthInfo);
85 vimRegisterInfo.setVimAuthInfos(vimAuthInfos);
86 vimRegisterInfo.setCloudExtraInfo(cloudRegion.getCloudExtraInfo());
87 vimRegisterInfo.setCloudOwner(cloudRegion.getCloudOwner());
88 vimRegisterInfo.setCloudRegionId(cloudRegion.getCloudRegionId());
89 vimRegisterInfo.setCloudType(cloudRegion.getCloudType());
90 vimRegisterInfo.setCloudZone(cloudRegion.getCloudZone());
91 vimRegisterInfo.setComplexName(cloudRegion.getComplexName());
92 vimRegisterInfo.setCloudRegionVersion(cloudRegion.getCloudRegionVersion());
93 vimRegisterInfo.setOwnerDefinedType(cloudRegion.getOwnerDefinedType());
94 vimRegisterInfo.setStatus(cloudRegion.getEsrSystemInfoList().getEsrSystemInfo().get(0).getSystemStatus());
95 return vimRegisterInfo;