summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlizi00164331 <li.zi30@zte.com.cn>2017-09-21 19:26:13 +0800
committerlizi00164331 <li.zi30@zte.com.cn>2017-09-21 19:26:13 +0800
commit768eda8233bd6c2f4e512365f6bfd1ccd323bcbf (patch)
treea0611a79bd700eaff9fa6e9cde0da1b3f3c8020a
parent07c89153d16b14bda54f16ef9f37e54bfc0a68f8 (diff)
Update VIM after register finishied.
Change-Id: If71ff525a92ae25975beae94c303afc718f395c4 Issue-ID: AAI-361 Signed-off-by: lizi00164331 <li.zi30@zte.com.cn>
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/ExtsysAppConfiguration.java13
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/common/MsbConfig.java80
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/externalservice/cloud/IVimManage.java34
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/externalservice/cloud/Tenant.java35
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/externalservice/cloud/VimManagerProxy.java32
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/externalservice/cloud/VimUpdateProvider.java57
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/wrapper/VimManagerWrapper.java10
-rw-r--r--standalone/src/main/assembly/conf/extsys.yml1
8 files changed, 262 insertions, 0 deletions
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/ExtsysAppConfiguration.java b/esr-mgr/src/main/java/org/onap/aai/esr/ExtsysAppConfiguration.java
index 83bd831..39fc2a6 100644
--- a/esr-mgr/src/main/java/org/onap/aai/esr/ExtsysAppConfiguration.java
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/ExtsysAppConfiguration.java
@@ -50,6 +50,9 @@ public class ExtsysAppConfiguration extends Configuration {
@NotEmpty
private String externalSystemAddr;
+ @NotEmpty
+ private String multiCloudAddr;
+
@Valid
private String serviceIp;
@@ -146,4 +149,14 @@ public class ExtsysAppConfiguration extends Configuration {
public void setMsbDiscoveryIp(String msbDiscoveryIp) {
this.msbDiscoveryIp = msbDiscoveryIp;
}
+
+ @JsonProperty
+ public String getMultiCloudAddr() {
+ return multiCloudAddr;
+ }
+
+ @JsonProperty
+ public void setMultiCloudAddr(String multiCloudAddr) {
+ this.multiCloudAddr = multiCloudAddr;
+ }
}
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/common/MsbConfig.java b/esr-mgr/src/main/java/org/onap/aai/esr/common/MsbConfig.java
new file mode 100644
index 0000000..86ff1b0
--- /dev/null
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/common/MsbConfig.java
@@ -0,0 +1,80 @@
+/**
+ * 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.common;
+
+
+public class MsbConfig {
+
+ protected static String msbServerAddr;
+
+ protected static String cloudInfrastructureAddr;
+
+ protected static String externalSystemAddr;
+
+ protected static String multiCloudAddr;
+
+ protected static String msbDiscoveryIp;
+
+ protected static String msbDiscoveryPort;
+
+ public static void setCloudInfrastructureAddr(String address){
+ cloudInfrastructureAddr = address;
+ }
+
+ public static String getCloudInfrastructureAddr(){
+ return msbServerAddr + "/api/aai-cloudInfrastructure/v11";
+ }
+
+ public static String getExternalSystemAddr() {
+ return msbServerAddr + "/api/aai-externalSystem/v11";
+ }
+
+ public static void setExternalSystemAddr(String Addr) {
+ externalSystemAddr = Addr;
+ }
+
+ public static void setMultiCloudAddr(String address){
+ multiCloudAddr = address;
+ }
+
+ public static String getMultiCloudAddr(){
+ return msbServerAddr + "/api/multicloud/v0";
+ }
+
+ public static String getMsbDiscoveryIp() {
+ return msbDiscoveryIp;
+ }
+
+ public static void setMsbDiscoveryIp(String discoveryIp) {
+ msbDiscoveryIp = discoveryIp;
+ }
+
+ public static String getMsbDiscoveryPort() {
+ return msbDiscoveryPort;
+ }
+
+ public static void setMsbDiscoveryPort(String discoveryPort) {
+ msbDiscoveryPort = discoveryPort;
+ }
+
+ public static String getMsbServerAddr() {
+ return msbServerAddr;
+ }
+
+ public static void setMsbServerAddr(String msbServerAddr) {
+ MsbConfig.msbServerAddr = msbServerAddr;
+ }
+}
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/cloud/IVimManage.java b/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/cloud/IVimManage.java
new file mode 100644
index 0000000..33ecd91
--- /dev/null
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/cloud/IVimManage.java
@@ -0,0 +1,34 @@
+/**
+ * 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.externalservice.cloud;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+@Path("/")
+public interface IVimManage {
+ @POST
+ @Path("/cloud-region/{cloud_owner}_{cloud_region_id}/registry")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ public void updateVIM(@PathParam("cloud_owner") String cloud_owner,
+ @PathParam("cloud_region_id") String cloud_region_id, Tenant tenant) throws Exception;
+
+}
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/cloud/Tenant.java b/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/cloud/Tenant.java
new file mode 100644
index 0000000..947480f
--- /dev/null
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/cloud/Tenant.java
@@ -0,0 +1,35 @@
+/**
+ * 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.externalservice.cloud;
+
+import java.io.Serializable;
+
+import com.google.gson.annotations.SerializedName;
+
+public class Tenant implements Serializable {
+ public static final long serialVersionUID = 1L;
+
+ @SerializedName("defaultTenant")
+ private String defaultTenant;
+
+ public String getDefaultTenant() {
+ return defaultTenant;
+ }
+
+ public void setDefaultTenant(String defaultTenant) {
+ this.defaultTenant = defaultTenant;
+ }
+}
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/cloud/VimManagerProxy.java b/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/cloud/VimManagerProxy.java
new file mode 100644
index 0000000..3a485b2
--- /dev/null
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/cloud/VimManagerProxy.java
@@ -0,0 +1,32 @@
+/**
+ * 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.externalservice.cloud;
+
+import org.glassfish.jersey.client.ClientConfig;
+import org.onap.aai.esr.common.MsbConfig;
+
+import com.eclipsesource.jaxrs.consumer.ConsumerFactory;
+
+public class VimManagerProxy {
+
+ public static void updateVim(String cloudOwner, String cloudRegionId,
+ Tenant tenant) throws Exception {
+ ClientConfig config = new ClientConfig(new VimUpdateProvider());
+ IVimManage updateVimServiceproxy = ConsumerFactory
+ .createConsumer(MsbConfig.getCloudInfrastructureAddr(), config, IVimManage.class);
+ updateVimServiceproxy.updateVIM(cloudOwner, cloudRegionId, tenant);
+ }
+}
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/cloud/VimUpdateProvider.java b/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/cloud/VimUpdateProvider.java
new file mode 100644
index 0000000..9526ac7
--- /dev/null
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/cloud/VimUpdateProvider.java
@@ -0,0 +1,57 @@
+/**
+ * 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.externalservice.cloud;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.ext.MessageBodyWriter;
+
+import org.onap.aai.esr.externalservice.aai.VimRegisterProvider;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.gson.Gson;
+
+public class VimUpdateProvider implements MessageBodyWriter<Tenant>{
+ private static final Logger logger = LoggerFactory.getLogger(VimRegisterProvider.class);
+
+ @Override
+ public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations,
+ MediaType mediaType) {
+ return Tenant.class.isAssignableFrom(type);
+ }
+
+ @Override
+ public long getSize(Tenant t, Class<?> type, Type genericType,
+ Annotation[] annotations, MediaType mediaType) {
+ return -1;
+ }
+
+ @Override
+ public void writeTo(Tenant t, Class<?> type, Type genericType,
+ Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders,
+ OutputStream entityStream) throws IOException, WebApplicationException {
+ String json = new Gson().toJson(t, Tenant.class);
+ logger.info("the param to update VIM input is:" + json);
+ entityStream.write(json.getBytes("UTF-8"));
+ }
+}
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/wrapper/VimManagerWrapper.java b/esr-mgr/src/main/java/org/onap/aai/esr/wrapper/VimManagerWrapper.java
index 2a4174a..75eaaca 100644
--- a/esr-mgr/src/main/java/org/onap/aai/esr/wrapper/VimManagerWrapper.java
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/wrapper/VimManagerWrapper.java
@@ -25,6 +25,8 @@ import org.onap.aai.esr.entity.aai.EsrSystemInfo;
import org.onap.aai.esr.entity.rest.VimRegisterInfo;
import org.onap.aai.esr.entity.rest.VimRegisterResponse;
import org.onap.aai.esr.externalservice.aai.CloudRegionProxy;
+import org.onap.aai.esr.externalservice.cloud.Tenant;
+import org.onap.aai.esr.externalservice.cloud.VimManagerProxy;
import org.onap.aai.esr.util.ExtsysUtil;
import org.onap.aai.esr.util.VimManagerUtil;
import org.slf4j.Logger;
@@ -64,6 +66,14 @@ public class VimManagerWrapper {
CloudRegionProxy.registerVim(cloudOwner, cloudRegionId, cloudRegion);
result.setCloudOwner(cloudOwner);
result.setCloudRegionId(cloudRegionId);
+ Tenant tenant = new Tenant();
+ tenant.setDefaultTenant(cloudRegion.getEsrSystemInfoList().getEsrSystemInfo().get(0).getDefaultTenant());
+ try {
+ VimManagerProxy.updateVim(cloudOwner, cloudRegionId, tenant);
+ } catch (Exception e) {
+ e.printStackTrace();
+ LOG.error("Update VIM by Multi-cloud failed !" + e.getMessage());
+ }
return Response.ok(result).build();
} catch (Exception error) {
error.printStackTrace();
diff --git a/standalone/src/main/assembly/conf/extsys.yml b/standalone/src/main/assembly/conf/extsys.yml
index b6f66ae..abcddd8 100644
--- a/standalone/src/main/assembly/conf/extsys.yml
+++ b/standalone/src/main/assembly/conf/extsys.yml
@@ -24,6 +24,7 @@ msbDiscoveryPort: 10081
msbServerAddr: http://127.0.0.1:10081
cloudInfrastructureAddr: http://127.0.0.1/api/aai-cloudInfrastructure/v11
externalSystemAddr: http://127.0.0.1/api/aai-externalSystem/v11
+multiCloudAddr: http://10.74.148.80/api/multicloud/v0
registByHand: true
# use the simple server factory if you only want to run on a single port