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 org.onap.aai.esr.common.SystemStatus;
20 import org.onap.aai.esr.common.SystemType;
21 import org.onap.aai.esr.entity.aai.EsrSystemInfo;
22 import org.onap.aai.esr.entity.aai.CloudRegionDetail;
23 import org.onap.aai.esr.entity.aai.EsrSystemInfoList;
24 import org.onap.aai.esr.entity.rest.VimAuthInfo;
25 import org.onap.aai.esr.entity.rest.VimRegisterInfo;
28 public class VimManagerUtil {
30 public static CloudRegionDetail vimRegisterInfo2CloudRegion(VimRegisterInfo vimRegisterInfo) {
31 CloudRegionDetail cloudRegion = new CloudRegionDetail();
32 EsrSystemInfoList esrSystemInfoList = new EsrSystemInfoList();
33 EsrSystemInfo esrSystemInfoObj = new EsrSystemInfo();
35 cloudRegion.setCloudOwner(vimRegisterInfo.getCloudOwner());
36 cloudRegion.setCloudRegionId(vimRegisterInfo.getCloudRegionId());
37 cloudRegion.setCloudType(vimRegisterInfo.getCloudType());
38 cloudRegion.setCloudRegionVersion(vimRegisterInfo.getCloudRegionVersion());
39 cloudRegion.setCloudZone(vimRegisterInfo.getCloudZone());
40 cloudRegion.setComplexName(vimRegisterInfo.getComplexName());
41 cloudRegion.setOwnerDefinedType(vimRegisterInfo.getOwnerDefinedType());
42 cloudRegion.setCloudExtraInfo(vimRegisterInfo.getCloudExtraInfo());
44 esrSystemInfoObj = vimAuthInfo2EsrSystemInfoObj(vimRegisterInfo.getVimAuthInfo());
45 esrSystemInfoList = ExtsysUtil.getEsrSystemInfoListFromAuthInfo(esrSystemInfoObj);
46 cloudRegion.setEsrSystemInfoList(esrSystemInfoList);
50 private static EsrSystemInfo vimAuthInfo2EsrSystemInfoObj(VimAuthInfo vimAuthInfo) {
51 EsrSystemInfo esrSystemInfoObj = new EsrSystemInfo();
52 esrSystemInfoObj.setCloudDomain(vimAuthInfo.getCloudDomain());
53 esrSystemInfoObj.setUserName(vimAuthInfo.getUserName());
54 esrSystemInfoObj.setPassword(vimAuthInfo.getPassword());
55 esrSystemInfoObj.setServiceUrl(vimAuthInfo.getAuthUrl());
56 esrSystemInfoObj.setSslCassert(vimAuthInfo.getSslCacert());
57 esrSystemInfoObj.setSslInsecure(vimAuthInfo.getSslInsecure());
58 esrSystemInfoObj.setEsrSystemInfoId(ExtsysUtil.generateId());
59 esrSystemInfoObj.setSystemType(SystemType.VIM.toString());
60 esrSystemInfoObj.setSystemStatus(SystemStatus.normal.toString());
61 return esrSystemInfoObj;
64 private static VimAuthInfo authInfo2VimAuthInfo(EsrSystemInfo authInfo) {
65 VimAuthInfo vimAuthInfo = new VimAuthInfo();
66 vimAuthInfo.setAuthUrl(authInfo.getServiceUrl());
67 vimAuthInfo.setCloudDomain(authInfo.getCloudDomain());
68 vimAuthInfo.setPassword(authInfo.getPassword());
69 vimAuthInfo.setSslCacert(authInfo.getSslCassert());
70 vimAuthInfo.setSslInsecure(authInfo.getSslInsecure());
71 vimAuthInfo.setUserName(authInfo.getUserName());
75 public static VimRegisterInfo cloudRegion2VimRegisterInfo(CloudRegionDetail cloudRegion) {
76 VimRegisterInfo vimRegisterInfo = new VimRegisterInfo();
77 VimAuthInfo vimAuthInfo = new VimAuthInfo();
78 vimAuthInfo = authInfo2VimAuthInfo(cloudRegion.getEsrSystemInfoList().getEsrSystemInfo().get(0));
79 vimRegisterInfo.setVimAuthInfo(vimAuthInfo);
80 vimRegisterInfo.setCloudExtraInfo(cloudRegion.getCloudExtraInfo());
81 vimRegisterInfo.setCloudOwner(cloudRegion.getCloudOwner());
82 vimRegisterInfo.setCloudRegionId(cloudRegion.getCloudRegionId());
83 vimRegisterInfo.setCloudType(cloudRegion.getCloudType());
84 vimRegisterInfo.setCloudZone(cloudRegion.getCloudZone());
85 vimRegisterInfo.setComplexName(cloudRegion.getComplexName());
86 vimRegisterInfo.setCloudRegionVersion(cloudRegion.getCloudRegionVersion());
87 vimRegisterInfo.setOwnerDefinedType(cloudRegion.getOwnerDefinedType());
88 return vimRegisterInfo;