@NotEmpty
private String externalSystemAddr;
+ @NotEmpty
+ private String multiCloudAddr;
+
@Valid
private String serviceIp;
public void setMsbDiscoveryIp(String msbDiscoveryIp) {
this.msbDiscoveryIp = msbDiscoveryIp;
}
+
+ @JsonProperty
+ public String getMultiCloudAddr() {
+ return multiCloudAddr;
+ }
+
+ @JsonProperty
+ public void setMultiCloudAddr(String multiCloudAddr) {
+ this.multiCloudAddr = multiCloudAddr;
+ }
}
--- /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.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;
+ }
+}
--- /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.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;
+
+}
--- /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.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;
+ }
+}
--- /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.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);
+ }
+}
--- /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.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"));
+ }
+}
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;
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();
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