--- /dev/null
+/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.aai.esr.entity.aai;
+
+import java.io.Serializable;
+
+import com.google.gson.annotations.SerializedName;
+
+public class EsrVnfm implements Serializable {
+
+ public static final long serialVersionUID = 1L;
+
+ @SerializedName("vnfm-id")
+ private String vnfmId;
+
+ @SerializedName("vim-id")
+ private String vimId;
+
+ @SerializedName("certificate-id")
+ private String certificateUrl;
+
+ @SerializedName("resouce-version")
+ private String resouceVersion;
+
+ public String getVnfmId() {
+ return vnfmId;
+ }
+
+ public void setVnfmId(String vnfmId) {
+ this.vnfmId = vnfmId;
+ }
+
+ public String getVimId() {
+ return vimId;
+ }
+
+ public void setVimId(String vimId) {
+ this.vimId = vimId;
+ }
+
+ public String getCertificateUrl() {
+ return certificateUrl;
+ }
+
+ public void setCertificateUrl(String certificateUrl) {
+ this.certificateUrl = certificateUrl;
+ }
+
+ public String getResouceVersion() {
+ return resouceVersion;
+ }
+
+ public void setResouceVersion(String resouceVersion) {
+ this.resouceVersion = resouceVersion;
+ }
+
+ public static long getSerialversionuid() {
+ return serialVersionUID;
+ }
+}
@SerializedName("vim-id")
private String vimId;
- @SerializedName("certificate-id")
+ @SerializedName("certificate-url")
private String certificateUrl;
@SerializedName("resouce-version")
--- /dev/null
+/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.aai.esr.entity.aai;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+
+import com.google.gson.annotations.SerializedName;
+
+public class EsrVnfmList implements Serializable {
+
+ public static final long serialVersionUID = 1L;
+
+ @SerializedName("esr-vnfm")
+ private ArrayList<EsrVnfm> esrVnfm;
+
+ public ArrayList<EsrVnfm> getEsrVnfm() {
+ return esrVnfm;
+ }
+
+ public void setEsrVnfm(ArrayList<EsrVnfm> esrVnfm) {
+ this.esrVnfm = esrVnfm;
+ }
+
+}
public static String queryVnfmDetail(String vnfmId) throws Exception {
return externalSystemproxy.queryVNFMDetail(transactionId, fromAppId, authorization, vnfmId);
}
+
+ public static String queryVnfmList() throws Exception {
+ return externalSystemproxy.queryVNFMList(transactionId, fromAppId, authorization);
+ }
}
import javax.ws.rs.core.Response;
-import org.onap.aai.esr.entity.aai.CloudRegionDetail;
import org.onap.aai.esr.entity.aai.EsrVnfmDetail;
+import org.onap.aai.esr.entity.aai.EsrVnfmList;
import org.onap.aai.esr.entity.rest.CommonRegisterResponse;
import org.onap.aai.esr.entity.rest.VnfmRegisterInfo;
-import org.onap.aai.esr.externalservice.aai.CloudRegionProxy;
import org.onap.aai.esr.externalservice.aai.ExternalSystemProxy;
-import org.onap.aai.esr.util.VimManagerUtil;
import org.onap.aai.esr.util.VnfmManagerUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public Response queryVnfmList() {
ArrayList<VnfmRegisterInfo> vnfmList = new ArrayList<VnfmRegisterInfo>();
- //TODO
- return Response.ok(vnfmList).build();
+ EsrVnfmList esrVnfm = new EsrVnfmList();
+ try {
+ String esrVnfmStr = ExternalSystemProxy.queryVnfmList();
+ esrVnfm = new Gson().fromJson(esrVnfmStr, EsrVnfmList.class);
+ vnfmList = getVnfmDetailList(esrVnfm);
+ return Response.ok(vnfmList).build();
+ } catch (Exception e) {
+ LOG.error("Query VNFM list failed !");
+ return Response.serverError().build();
+ }
+
}
public Response queryVnfmById(String vnfmId) {
+ VnfmRegisterInfo vnfm = new VnfmRegisterInfo();
+ vnfm = queryVnfmDetail(vnfmId);
+ if (vnfm != null) {
+ return Response.ok(vnfm).build();
+ } else {
+ return Response.serverError().build();
+ }
+ }
+
+ public Response delVnfm(String vnfmId) {
+ //TODO
+ return Response.noContent().build();
+ }
+
+ private VnfmRegisterInfo queryVnfmDetail(String vnfmId) {
VnfmRegisterInfo vnfm = new VnfmRegisterInfo();
EsrVnfmDetail esrVnfmDetail = new EsrVnfmDetail();
try {
LOG.info("Response from AAI by query VNFM: " + esrVnfmstr);
esrVnfmDetail = new Gson().fromJson(esrVnfmstr, EsrVnfmDetail.class);
vnfm = VnfmManagerUtil.esrVnfm2VnfmRegisterInfo(esrVnfmDetail);
- return Response.ok(vnfm).build();
+ return vnfm;
} catch (Exception e) {
- e.printStackTrace();
- return Response.serverError().build();
+ LOG.error("Query VNFM detail failed! VNFM ID: " + vnfmId, e.getMessage());
+ return null;
}
}
- public Response delVnfm(String vnfmId) {
- //TODO
- return Response.noContent().build();
+ private ArrayList<VnfmRegisterInfo> getVnfmDetailList(EsrVnfmList esrVnfm) {
+ ArrayList<VnfmRegisterInfo> vnfmInfoList = new ArrayList<VnfmRegisterInfo>();
+ VnfmRegisterInfo vnfmInfo = new VnfmRegisterInfo();
+ for (int i=0; i<esrVnfm.getEsrVnfm().size(); i++) {
+ String vnfmId = esrVnfm.getEsrVnfm().get(i).getVnfmId();
+ vnfmInfo = queryVnfmDetail(vnfmId);
+ if(vnfmInfo != null) {
+ vnfmInfoList.add(vnfmInfo);
+ }
+ }
+ return vnfmInfoList;
}
}