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;
18 import java.util.ArrayList;
20 import org.onap.aai.esr.common.SystemStatus;
21 import org.onap.aai.esr.common.SystemType;
22 import org.onap.aai.esr.entity.aai.AuthInfo;
23 import org.onap.aai.esr.entity.aai.CloudRegion;
24 import org.onap.aai.esr.entity.aai.EsrSystemInfo;
25 import org.onap.aai.esr.entity.aai.EsrSystemInfoList;
26 import org.onap.aai.esr.entity.rest.VimAuthInfo;
27 import org.onap.aai.esr.entity.rest.VimRegisterInfo;
30 public class VimManagerUtil {
32 public static CloudRegion vimRegisterInfo2CloudRegion(VimRegisterInfo vimRegisterInfo) {
33 CloudRegion cloudRegion = new CloudRegion();
34 EsrSystemInfoList esrSystemInfo = new EsrSystemInfoList();
35 AuthInfo authInfo = new AuthInfo();
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 authInfo = vimAuthInfo2AuthInfo(vimRegisterInfo.getVimAuthInfo());
47 esrSystemInfo = ExtsysUtil.getEsrSystemInfoList(authInfo);
48 cloudRegion.setEsrSystemInfoList(esrSystemInfo);
52 private static AuthInfo vimAuthInfo2AuthInfo(VimAuthInfo vimAuthInfo) {
53 AuthInfo authInfo = new AuthInfo();
54 authInfo.setCloudDomain(vimAuthInfo.getCloudDomain());
55 authInfo.setUserName(vimAuthInfo.getUserName());
56 authInfo.setPassword(vimAuthInfo.getPassword());
57 authInfo.setServiceUrl(vimAuthInfo.getAuthUrl());
58 authInfo.setSslCassert(vimAuthInfo.getSslCacert());
59 authInfo.setSslInsecure(vimAuthInfo.getSslInsecure());
60 authInfo.setEsrSystemInfoId(ExtsysUtil.generateId());
61 authInfo.setSystemType(SystemType.VIM.toString());
62 authInfo.setSystemStatus(SystemStatus.normal.toString());
66 private static VimAuthInfo authInfo2VimAuthInfo(AuthInfo authInfo) {
67 VimAuthInfo vimAuthInfo = new VimAuthInfo();
68 vimAuthInfo.setAuthUrl(authInfo.getServiceUrl());
69 vimAuthInfo.setCloudDomain(authInfo.getCloudDomain());
70 vimAuthInfo.setPassword(authInfo.getPassword());
71 vimAuthInfo.setSslCacert(authInfo.getSslCassert());
72 vimAuthInfo.setSslInsecure(authInfo.getSslInsecure());
73 vimAuthInfo.setUserName(authInfo.getUserName());
77 public static VimRegisterInfo cloudRegion2VimRegisterInfo(CloudRegion cloudRegion) {
78 VimRegisterInfo vimRegisterInfo = new VimRegisterInfo();
79 VimAuthInfo vimAuthInfo = new VimAuthInfo();
80 vimAuthInfo = authInfo2VimAuthInfo(cloudRegion.getEsrSystemInfoList().getEsrSystemInfo().getEsrSystemInfo().get(0));
81 vimRegisterInfo.setVimAuthInfo(vimAuthInfo);
82 vimRegisterInfo.setCloudExtraInfo(cloudRegion.getCloudExtraInfo());
83 vimRegisterInfo.setCloudOwner(cloudRegion.getCloudOwner());
84 vimRegisterInfo.setCloudRegionId(cloudRegion.getCloudRegionId());
85 vimRegisterInfo.setCloudType(cloudRegion.getCloudType());
86 vimRegisterInfo.setCloudZone(cloudRegion.getCloudZone());
87 vimRegisterInfo.setComplexName(cloudRegion.getComplexName());
88 vimRegisterInfo.setOwnerDefinedType(cloudRegion.getOwnerDefinedType());
89 return vimRegisterInfo;