summaryrefslogtreecommitdiffstats
path: root/ResmanagementService/service/src/main/java
diff options
context:
space:
mode:
authorluxin <luxin7@huawei.com>2017-07-03 10:19:19 +0800
committerluxin <luxin7@huawei.com>2017-07-03 10:19:19 +0800
commit056dcab91efc64b5f9fc39825f9242e7fa0b9d05 (patch)
treed1af18cb6bfa6d3d61f0f77ff958d5a3ce7d6d06 /ResmanagementService/service/src/main/java
parentd0ad118ba98d809ddc8eece49cf1fe1dfc83fc74 (diff)
Upload nfvo resmanagement code
Change-Id: Ibe023d4b09e1105b84eb43153b4d4037cae691db Signed-off-by: luxin <luxin7@huawei.com>
Diffstat (limited to 'ResmanagementService/service/src/main/java')
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/ResourceUtil.java43
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/VimUtil.java141
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/constant/Constant.java93
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/constant/HttpConstant.java79
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/constant/ParamConstant.java370
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/constant/ResponseConstant.java60
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/constant/UrlConstant.java258
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/util/JsonUtil.java290
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/util/RestfulUtil.java371
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/util/StringUtil.java215
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/util/request/RequestUtil.java129
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/util/response/ResponseUtil.java133
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/util/response/RoaResponseUtil.java113
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/activator/ROAResmgrServicePostProcessor.java60
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/adapter/impl/ResmgrAdapter2MSBManager.java111
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/adapter/impl/ResmgrAdapterMgrService.java185
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/adapter/inf/IResmgrAdapter2MSBManager.java52
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/adapter/inf/IResmgrAdapterMgrService.java39
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/impl/HostImpl.java80
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/impl/LocationImpl.java186
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/impl/NetworkImpl.java101
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/impl/PortImpl.java103
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/impl/SitesImpl.java231
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/impl/VimImpl.java82
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/inf/Host.java66
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/inf/InterfaceResManagement.java40
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/inf/Location.java104
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/inf/Network.java69
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/inf/Port.java76
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/inf/ResManagement.java66
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/inf/Sites.java95
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/inf/Vim.java76
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/impl/HostBusinessImpl.java162
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/impl/LimitsBusinessImpl.java93
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/impl/LocationBusinessImpl.java242
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/impl/NetworkBusinessImpl.java153
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/impl/PortBusinessImpl.java161
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/impl/SitesBusinessImpl.java200
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/impl/VimBusinessImpl.java99
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/inf/HostBusiness.java131
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/inf/LimitsBusiness.java42
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/inf/LocationBusiness.java134
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/inf/NetworkBusiness.java133
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/inf/PortBusiness.java131
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/inf/SitesBusiness.java124
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/inf/VimBusiness.java72
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/AbstractDao.java57
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/HostDaoImpl.java83
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/LocationDaoImpl.java83
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/NetworkDaoImpl.java83
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/PortDaoImpl.java83
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/SitesDaoImpl.java77
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/VimDaoImpl.java55
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/VirtualLinkDaoImpl.java84
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/VmDaoImpl.java108
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/VnfDaoImpl.java84
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/VnfInfoDaoImpl.java96
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/VnfStatusDaoImpl.java96
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/HostDao.java114
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/LocationDao.java123
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/NetworkDao.java125
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/PortDao.java114
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/SitesDao.java105
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/VimDao.java68
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/VirtualLinkDao.java69
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/VmDao.java45
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/VnfDao.java69
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/VnfInfoDao.java43
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/VnfStatusDao.java43
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/HostEntity.java179
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/LocationEntity.java236
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/NetworkEntity.java271
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/PortEntity.java179
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/SitesEntity.java309
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/VimEntity.java106
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/VirtualLinkEntity.java285
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/VmEntity.java96
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/VnfEntity.java337
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/VnfInfoEntity.java83
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/VnfStatusEntity.java213
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/GrantResServiceImpl.java206
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/IResourceAddServiceImpl.java159
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/IResourceDelServiceImpl.java75
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/IResourceUpdateServiceImpl.java120
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/ResOperateServiceImpl.java257
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/VirtualLinkServiceImpl.java123
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/VmServiceImpl.java177
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/VnfInfoServiceImpl.java150
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/VnfServiceImpl.java141
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/VnfStatusServiceImpl.java117
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/inf/GrantResService.java44
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/inf/ResOperateService.java82
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/inf/VirtualLinkService.java64
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/inf/VmService.java44
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/inf/VnfInfoService.java42
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/inf/VnfService.java66
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/inf/VnfStatusService.java42
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/HostMapper.java114
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/LocationMapper.java123
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/NetworkMapper.java125
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/PortMapper.java114
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/SitesMapper.java111
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/VimMapper.java68
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/VirtualLinkMapper.java39
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/VmMapper.java41
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/VnfInfoMapper.java39
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/VnfMapper.java39
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/VnfStatusMapper.java39
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/GrantResourseRoa.java94
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/HostRoa.java183
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/LimitsRoa.java73
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/LocationRoa.java316
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/NetworkRoa.java189
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/PortRoa.java183
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/ResOperateRoa.java151
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/SitesRoa.java224
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/SwaggerRoa.java49
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/VirtualLinkRoa.java129
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/VmRoa.java127
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/VnfInfoRoa.java129
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/VnfRoa.java128
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/VnfStatusRoa.java129
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/exceptionmapper/ExceptionMessage.java64
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/exceptionmapper/GenericExceptionMapper.java41
-rw-r--r--ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/exceptionmapper/ServiceExceptionMapper.java45
125 files changed, 15210 insertions, 0 deletions
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/ResourceUtil.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/ResourceUtil.java
new file mode 100644
index 0000000..572de2b
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/ResourceUtil.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.common;
+
+/**
+ * <br/>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Aug 25, 2016
+ */
+public class ResourceUtil {
+
+ private ResourceUtil() {
+
+ }
+
+ /**
+ * It is used to get Message<br/>
+ *
+ * @param key
+ * @return
+ * @since NFVO 0.5
+ */
+ public static String getMessage(String key) {
+ return key;
+ }
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/VimUtil.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/VimUtil.java
new file mode 100644
index 0000000..5f2d417
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/VimUtil.java
@@ -0,0 +1,141 @@
+/*
+ * Copyright 2016-2017 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.common;
+
+import org.openo.baseservice.roa.util.restclient.RestfulParametes;
+import org.openo.nfvo.resmanagement.common.constant.ParamConstant;
+import org.openo.nfvo.resmanagement.common.constant.UrlConstant;
+import org.openo.nfvo.resmanagement.common.util.RestfulUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import net.sf.json.JSONArray;
+import net.sf.json.JSONObject;
+
+/**
+ * <br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Oct 30, 2016
+ */
+public class VimUtil {
+
+ private static final Logger LOG = LoggerFactory.getLogger(VimUtil.class);
+
+ private VimUtil() {
+
+ }
+
+ /**
+ * Get VIMs.
+ *
+ * @return
+ */
+ public static JSONArray getVims() {
+ String esrResponse =
+ RestfulUtil.getResponseContent(UrlConstant.ESR_GET_VIMS_URL, new RestfulParametes(), "get");
+ LOG.info("Get vims from ESR! EsrResponse:{}", esrResponse);
+ if(null == esrResponse) {
+ LOG.error("ESR return fail.");
+ return null;
+ } else {
+ return JSONArray.fromObject(esrResponse);
+ }
+
+ }
+
+ /**
+ * Get vimId by vimName.
+ *
+ * @return
+ */
+ public static String getVimIdByName(String name) {
+ JSONArray vims = getVims();
+ for(int i = 0; i < vims.size(); i++) {
+ JSONObject vim = vims.getJSONObject(i);
+ LOG.info("vimInfo: " + vim);
+ String vimName = vim.getString("name");
+ String vimId = vim.getString("vimId");
+ LOG.info("name:" + name + ", vimName:" + vimName + ", vimId:" + vimId);
+ if(name.trim().equalsIgnoreCase(vimName)) {
+ return vimId;
+ }
+ }
+ LOG.error("No vim with this vimName");
+ return "";
+
+ }
+
+ /**
+ * Get VIM.
+ *
+ * @param vimId
+ * @return
+ */
+ public static JSONObject getVimById(String vimId) {
+ if(vimId == null || "".equals(vimId.trim())) {
+ LOG.error("Get vim ERROR, VimId is null. ");
+ return null;
+ }
+ JSONObject esrResponse = RestfulUtil.getResponseObj(String.format(UrlConstant.ESR_GET_VIM_URL, vimId), "get");
+ LOG.info("Get vims from ESR! EsrResponse:{}", esrResponse);
+ if(null == esrResponse) {
+ LOG.error("ESR return fail.");
+ return null;
+ } else {
+ return esrResponse;
+ }
+ }
+
+ /**
+ * Get tenants.
+ *
+ * @param vimId
+ * @return
+ */
+ public static JSONArray getTenants(String vimId) {
+ String url = String.format(UrlConstant.GET_TENANT_URL, vimId);
+ JSONObject resultObj = RestfulUtil.getResponseObj(url, ParamConstant.PARAM_GET);
+ JSONArray tenants = resultObj.getJSONArray("tenants");
+ LOG.info("Get tenants from multivim! tenants:{}", tenants);
+ return tenants;
+ }
+
+ /**
+ * <br>
+ *
+ * @param tenant
+ * @param vimId
+ * @return
+ * @since NFVO 0.5
+ */
+ public static String getTenantIdByName(String tenant, String vimId) {
+ JSONArray tenants = VimUtil.getTenants(vimId);
+ String tenantId = "";
+ for(int i = 0; i < tenants.size(); i++) {
+ JSONObject obj = tenants.getJSONObject(i);
+ String name = obj.getString("name");
+ if(name.equalsIgnoreCase(tenant)) {
+ tenantId = obj.getString("id");
+ }
+ }
+ LOG.info("GetTenantIdByName tenantId:{}", tenantId);
+ return tenantId;
+ }
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/constant/Constant.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/constant/Constant.java
new file mode 100644
index 0000000..1e5941d
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/constant/Constant.java
@@ -0,0 +1,93 @@
+/*
+ * Copyright 2016-2017 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.common.constant;
+
+/**
+ * HTTP constants<br/>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Aug 25, 2016
+ */
+public class Constant {
+
+ public static final String RES_MANAGEMENT_DB = "resmanagementdb";
+
+ /**
+ * Database Delete/Modify/Add fail.
+ */
+ public static final int ERROR_CODE = -1;
+
+ /**
+ * Database Delete/Modify/Add success.
+ */
+ public static final int OK_CODE = 1;
+
+ /**
+ * Lack of resource.
+ */
+ public static final int RES_NOT_ENOUGH_CODE = -2;
+
+ /**
+ * Module name.
+ */
+ public static final String MODULE_NAME = "Resmanagement";
+
+ public static final String RESPONSE_CONTENT = "responseContent";
+
+ public static final String STATUS_CODE = "statusCode";
+
+ /**
+ * Format Time
+ */
+ public static final String DATE_FORMATE = "yyyy-MM-dd HH:mm:ss";
+
+ public static final String DATE_UTC_FORMATE = "yyyy-MM-dd'T'HH:mm:ss'Z'";
+
+ public static final String UTC_FORMATE = "UTC";
+
+ public static final String DATE_DAY_FORMATE = "yyyy-MM-dd 00:00:00";
+
+ /**
+ * IAM
+ */
+
+ public static final String HTTP_CONTENT_TYPE = "Content-Type";
+
+ public static final String HTTP_CONTENT_TYPE_VALUE = "application/json;charset=UTF-8";
+
+ public static final String X_TENANT_ID = "X-Tenant-Id";
+
+ public static final String IAM_TOKEN = "x-auth-token";
+
+ public static final String IAM_AUTH_TOKEN = "X-Auth-Token";
+
+ public static final String IAM_USER_ID = "X-User-Id";
+
+ public static final String IAM_USER_NAME = "X-User-Name";
+
+ public static final String IAM_DOMAIN_NAME = "X-Domain-Name";
+
+ public static final String HEADER_SUBJECT_TOKEN = "X-Subject-Token";
+
+ public static final int REPEAT_REG_TIME = 60 * 1000;
+
+ private Constant() {
+ // private constants
+ }
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/constant/HttpConstant.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/constant/HttpConstant.java
new file mode 100644
index 0000000..f480b70
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/constant/HttpConstant.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.common.constant;
+
+/**
+ *
+ * Http constant class.<br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Sep 10, 2016
+ */
+public class HttpConstant {
+
+ public static final int ERROR_CODE = -1;
+
+ public static final int OK_CODE = 1;
+
+ public static final int HTTP_OK = 200;
+
+ public static final int HTTP_CREATED = 201;
+
+ public static final int HTTP_ACCEPTED = 202;
+
+ public static final int HTTP_NOCONTENT = 204;
+
+ public static final int HTTP_UNAUTHORIZED = 401;
+
+ public static final int HTTP_BAD_REQUEST = 400;
+
+ public static final int HTTP_NOTFOUND_CODE = 404;
+
+ public static final int HTTP_CONFLICT_CODE = 409;
+
+ public static final int HTTP_INVALID_PARAMETERS = 415;
+
+ public static final int HTTP_INNERERROR_CODE = 500;
+
+ public static final int INTERNAL_EXCEPTION_CODE = 600;
+
+ public static final int TOKEN_HEAD_NULL_CODE = 601;
+
+ public static final int TOKEN_USER_NULL_CODE = 602;
+
+ public static final int SERVICE_URL_ERROR_CODE = 603;
+
+ public static final int ACCESS_OBJ_NULL_CODE = 604;
+
+ public static final int CONNECT_NOT_FOUND_CODE = 605;
+
+ public static final int VCENTER_PARA_ERROR_CODE = 606;
+
+ public static final int TYPE_PARA_ERROR_CODE = 607;
+
+ public static final int CONNECT_FAIL_CODE = 608;
+
+ public static final int DIS_CONNECT_FAIL_CODE = 609;
+
+ public static final int HANDSHAKE_FAIL_CODE = 610;
+
+ private HttpConstant() {
+ //private constructor
+ }
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/constant/ParamConstant.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/constant/ParamConstant.java
new file mode 100644
index 0000000..9ba0c4c
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/constant/ParamConstant.java
@@ -0,0 +1,370 @@
+/*
+ * Copyright 2016-2017 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.common.constant;
+
+/**
+ * <br/>
+ * <p>
+ * Contstant for System interactive.
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 2016-3-17
+ */
+public class ParamConstant {
+
+ /**
+ * param key: vimId.
+ */
+ public static final String PARAM_VIMID = "vimId";
+
+ /**
+ * param key: vimName
+ */
+ public static final String PARAM_VIMNAME = "vimName";
+
+ /**
+ * param key: tenantId.
+ */
+ public static final String PARAM_TENANTID = "tenantId";
+
+ public static final String TOTAL_CPU = "totalCPU";
+
+ public static final String USED_CPU = "usedCPU";
+
+ public static final String TOTAL_MEMORY = "totalMemory";
+
+ public static final String USED_MEMORY = "usedMemory";
+
+ public static final String TOTAL_DISK = "totalDisk";
+
+ public static final String USED_DISK = "usedDisk";
+
+ /**
+ * param key: data.
+ */
+ public static final String PARAM_DATA = "data";
+
+ /**
+ * param key: id.
+ */
+ public static final String PARAM_ID = "id";
+
+ /**
+ * param key: vimId
+ */
+ public static final String PARAM_IP = "ip";
+
+ /**
+ * param key: role.
+ */
+ public static final String PARAM_ROLE = "role";
+
+ /**
+ * param key: roleId.
+ */
+ public static final String PARAM_ROLEID = "roleId";
+
+ /**
+ * param key: total.
+ */
+ public static final String PARAM_TOTAL = "total";
+
+ /**
+ * param key: used.
+ */
+ public static final String PARAM_USED = "used";
+
+ /**
+ * param key: vcpus.
+ */
+ public static final String PARAM_VCPUS = "vcpus";
+
+ /**
+ * param key: disk.
+ */
+ public static final String PARAM_DISK = "disk";
+
+ /**
+ * param key: cpumhz.
+ */
+ public static final String PARAM_CPUMHZ = "cpumhz";
+
+ /**
+ * param key: countyr
+ */
+ public static final String PARAM_COUNTRY = "country";
+
+ /**
+ * param key: vendorId
+ */
+ public static final String PARAM_VENDORID = "vendorId";
+
+ /**
+ * param key: vendorName
+ */
+ public static final String PARAM_VENDORNAME = "vendorName";
+
+ /**
+ * param key: memory.
+ */
+ public static final String PARAM_MEMORY = "memory";
+
+ /**
+ * param key: name.
+ */
+ public static final String PARAM_NAME = "name";
+
+ /**
+ * param key: status.
+ */
+ public static final String PARAM_STATUS = "status";
+
+ /**
+ * param key: parent.
+ */
+ public static final String PARAM_PARENT = "parent";
+
+ /**
+ * param key: location.
+ */
+ public static final String PARAM_LOCATION = "location";
+
+ /**
+ * param key: siteName.
+ */
+ public static final String PARAM_SITENAME = "siteName";
+
+ /**
+ * param key: vendor.
+ */
+ public static final String PARAM_VENDOR = "vendor";
+
+ /**
+ * param key: vendors.
+ */
+ public static final String PARAM_VENDORS = "vendors";
+
+ /**
+ * param key: tenantSites.
+ */
+ public static final String PARAM_TENANTSITES = "tenantSites";
+
+ /**
+ * param key: siteId.
+ */
+ public static final String PARAM_SITEID = "siteId";
+
+ /**
+ * param key: resArbitration.
+ */
+ public static final String PARAM_RESARBITRATION = "resArbitration";
+
+ /**
+ * param key: userRole.
+ */
+ public static final String PARAM_USERROLE = "userRole";
+
+ /**
+ * param key: admin.
+ */
+ public static final String PARAM_ADMIN = "admin";
+
+ /**
+ * param key: tenant.
+ */
+ public static final String PARAM_TENANT = "tenant";
+
+ /**
+ * param key: type.
+ */
+ public static final String PARAM_TYPE = "type";
+
+ /**
+ * param key: action.
+ */
+ public static final String PARAM_ACTION = "action";
+
+ /**
+ * param key: offline.
+ */
+ public static final String PARAM_OFFLINE = "offline";
+
+ /**
+ * param key: online.
+ */
+ public static final String PARAM_ONLINE = "online";
+
+ /**
+ * param key: drexecute.
+ */
+ public static final String PARAM_DREXECUTE = "drexecute";
+
+ /**
+ * param key: drRollBack.
+ */
+ public static final String PARAM_DRROLLBACK = "drrollback";
+
+ /**
+ * param key: scaleOut.
+ */
+ public static final String PARAM_SCALEOUT = "scaleout";
+
+ /**
+ * param key: scaleIn.
+ */
+ public static final String PARAM_SCALEIN = "scalein";
+
+ /**
+ * param key: network.
+ */
+ public static final String PARAM_NETWORK = "networks";
+
+ /**
+ * param key: host.
+ */
+ public static final String PARAM_HOST = "hosts";
+
+ /**
+ * param key: network.
+ */
+ public static final String PARAM_PORT = "ports";
+
+ /**
+ * param key: providernetworks.
+ */
+ public static final String PARAM_PROVIDERNETWORKS = "providernetworks";
+
+ /**
+ * param key: vims.
+ */
+ public static final String PARAM_VIMS = "vims";
+
+ /**
+ * param key: vms.
+ */
+ public static final String PARAM_VMS = "vms";
+
+ /**
+ * param key: vapps.
+ */
+ public static final String PARAM_VAPPS = "vapps";
+
+ /**
+ * param key: vapp.
+ */
+ public static final String PARAM_VAPP = "vapp";
+
+ /**
+ * param key: sites.
+ */
+ public static final String PARAM_SITES = "sites";
+
+ /**
+ * param key: vduId.
+ */
+ public static final String PARAM_VDUID = "vduId";
+
+ /**
+ * param key: vappId.
+ */
+ public static final String PARAM_VAPPID = "vappId";
+
+ /**
+ * param key: hostId.
+ */
+ public static final String PARAM_HOSTID = "hostId";
+
+ /**
+ * param key: projectId.
+ */
+ public static final String PARAM_PROJECTID = "projectId";
+
+ /**
+ * param key: vnfmId.
+ */
+ public static final String PARAM_VNFMID = "vnfmId";
+
+ /**
+ * param key: params.
+ */
+ public static final String PARAM_PARAMS = "params";
+
+ /**
+ * param key: url.
+ */
+ public static final String PARAM_URL = "url";
+
+ /**
+ * param key: post.
+ */
+ public static final String PARAM_POST = "post";
+
+ /**
+ * param key: put.
+ */
+ public static final String PARAM_PUT = "put";
+
+ /**
+ * param key: del.
+ */
+ public static final String PARAM_DEL = "del";
+
+ /**
+ * param key: get.
+ */
+ public static final String PARAM_GET = "get";
+
+ /**
+ * param key: retCode.
+ */
+ public static final String PARAM_RETCODE = "retCode";
+
+ /**
+ * param key: ADD.
+ */
+ public static final String PARAM_ADD = "add";
+
+ /**
+ * param key: active.
+ */
+ public static final String PARAM_ACTIVE = "active";
+
+ /**
+ * param key: deleted.
+ */
+ public static final String PARAM_DELETED = "deleted";
+
+ /**
+ * param key: deleting.
+ */
+ public static final String PARAM_DELETING = "deleting";
+
+ /**
+ * param key: response
+ */
+ public static final String PARAM_RESPONSE = "response";
+
+ /**
+ * param key: info
+ */
+ public static final String PARAM_INFO = "info";
+
+ private ParamConstant() {
+ // private constructor
+ }
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/constant/ResponseConstant.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/constant/ResponseConstant.java
new file mode 100644
index 0000000..a4fe9e0
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/constant/ResponseConstant.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2016-2017 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.common.constant;
+
+import org.openo.nfvo.resmanagement.common.ResourceUtil;
+
+/**
+ * Response constants.<br/>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Aug 25, 2016
+ */
+public class ResponseConstant {
+
+ public static final String ADD_SUCESS_MSG = ResourceUtil.getMessage("org.openo.nfvo.resmanage.common.add.success");
+
+ public static final String ADD_FAIL_MSG = ResourceUtil.getMessage("org.openo.nfvo.resmanage.common.add.error");
+
+ public static final String DEL_SUCESS_MSG = ResourceUtil.getMessage("org.openo.nfvo.resmanage.common.del.success");
+
+ public static final String DEL_FAIL_MSG = ResourceUtil.getMessage("org.openo.nfvo.resmanage.common.del.error");
+
+ public static final String MOD_SUCESS_MSG =
+ ResourceUtil.getMessage("org.openo.nfvo.resmanage.common.update.success");
+
+ public static final String MOD_FAIL_MSG = ResourceUtil.getMessage("org.openo.nfvo.resmanage.common.update.error");
+
+ public static final String QUERY_SUCESS_MSG =
+ ResourceUtil.getMessage("org.openo.nfvo.resmanage.common.query.success");
+
+ public static final String QUERY_FAIL_MSG = ResourceUtil.getMessage("org.openo.nfvo.resmanage.common.query.error");
+
+ public static final String DELSODORES_FAIL_MSG = "delete sodores error";
+
+ public static final String DELVNFMINFO_FAIL_MSG = "delete vnfm error";
+
+ public static final String RES_VERIFY_SUCESS_MSG = "nsdata verify sucessfully";
+
+ public static final String RES_VERIFY_FAIL_MSG = "res verify failed";
+
+ private ResponseConstant() {
+ // private constructor
+ }
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/constant/UrlConstant.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/constant/UrlConstant.java
new file mode 100644
index 0000000..b9a93a1
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/constant/UrlConstant.java
@@ -0,0 +1,258 @@
+/*
+ * Copyright 2016-2017 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.common.constant;
+
+/**
+ * <br/>
+ * <p>
+ * Constant for REST URL.
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 2016-3-17
+ */
+public class UrlConstant {
+
+ /**
+ * networks target.
+ */
+ public static final String LOCATION_TARGET = "location";
+
+ /**
+ * MSB register url.
+ */
+ public static final String REST_MSB_REGISTER = "/openoapi/microservices/v1/services";
+
+ public static final String ESR_GET_VIM_URL = "/openoapi/extsys/v1/vims/%s";
+
+ public static final String ESR_GET_VIMS_URL = "/openoapi/extsys/v1/vims";
+
+ /**
+ * send resource info to monitor url
+ */
+ public static final String SEND_MSG_MONITOR = "/openoapi/umc/v1/resinfo";
+
+ /**
+ * networks url.
+ */
+ public static final String LOCATION_URL = "/v1/locations";
+
+ /**
+ * port url.
+ */
+ public static final String PORT_URL = "/v1/ports";
+
+ /**
+ * host url.
+ */
+ public static final String HOST_URL = "/v1/hosts";
+
+ /**
+ * vl url.
+ */
+ public static final String VL_URL = "/v1/vl";
+
+ /**
+ * vnf url.
+ */
+ public static final String VNF_URL = "/v1/vnf";
+
+ /**
+ * vnfinfo url.
+ */
+ public static final String VNFINFO_URL = "/v1/vnfinfo";
+
+ /**
+ * vnfstatus url.
+ */
+ public static final String VNFSTATUS_URL = "/v1/vnfstatus";
+
+ /**
+ * grant resource url.
+ */
+ public static final String GRANTRES_URL = "/v1/resource/grant";
+
+ /**
+ * vm url.
+ */
+ public static final String VM_URL = "/v1/vm";
+
+ /**
+ * sites target.
+ */
+ public static final String SITES_TARGET = "sites";
+
+ /**
+ * sites url.
+ */
+ public static final String SITES_URL = "/v1/datacenters";
+
+ /**
+ * networks target.
+ */
+ public static final String NETWORKS_TARGET = "networks";
+
+ /**
+ * networks url.
+ */
+ public static final String NETWORKS_URL = "/v1/networks";
+
+ /**
+ * updateres.
+ */
+ public static final String MODRES_URL = "/updateres";
+
+ /**
+ * resoperate target.
+ */
+ public static final String RESOPERATE_TARGET = "resoperate";
+
+ /**
+ * APPLICATION_TYPE.
+ */
+ public static final String APPLICATION_TYPE = "application/json";
+
+ /**
+ * ADDRES.
+ */
+ public static final String ADDRES_URL = "/resmgr/vims";
+
+ /**
+ * updatebytenant.
+ */
+ public static final String UPDATE_BY_TENANT = "updatebytenant";
+
+ /**
+ * updatebyvapp.
+ */
+ public static final String UPDATE_BY_VAPP = "updatebyvapp";
+
+ /**
+ * getNetworkURL.
+ */
+ public static final String GET_NETWORK_URL = "/openoapi/multivim/v1/%s/%s/networks";
+
+ /**
+ * getTenantURL.
+ */
+ public static final String GET_TENANT_URL = "/openoapi/multivim/v1/%s/tenants";
+
+ /**
+ * getHostURL.
+ */
+ public static final String GET_HOST_URL = "/openoapi/multivim/v1/%s/%s/hosts";
+
+ /**
+ * getHostDetailURL.
+ */
+ public static final String GET_HOSTDETAIL_URL = "/openoapi/multivim/v1/%s/%s/hosts/%s";
+
+ /**
+ * getNetworkURL.
+ */
+ public static final String GET_PORT_URL = "/openoapi/multivim/v1/%s/%s/ports";
+
+ /**
+ * getLimitsURL.
+ */
+ public static final String GET_LIMITS_URL = "/openoapi/multivim/v1/%s/%s/limits";
+
+ /**
+ * template notify M url.
+ */
+ public static final String TEMPLATE_NOTIFY_M_URL = "";
+
+ /**
+ * tenantsite allot url.
+ */
+ public static final String TENANTSITE_ALLOT_URL = "/v1/resmanage/tenantsite/allot";
+
+ /**
+ * tenantsite allot target.
+ */
+ public static final String TENANTSITE_ALLOT_TARGET = "tenantsite/allot";
+
+ /**
+ * tenant url.
+ */
+ public static final String TENANT_URL = "/v1/resmanage/tenant";
+
+ /**
+ * tenant target.
+ */
+ public static final String TENANT_TARGET = "tenant";
+
+ /**
+ * rollback url.
+ */
+ public static final String ROLLBACK_URL = "/v1/resmanage/rollback";
+
+ /**
+ * rollback target.
+ */
+ public static final String ROLLBACK_TARGET = "rollback";
+
+ /**
+ * vms target.
+ */
+ public static final String VIM_TARGET = "vim";
+
+ /**
+ * vms url.
+ */
+ public static final String VIM_URL = "/v1/resmanage/vim";
+
+ /**
+ * https
+ */
+ public static final String GET_HTTPS = "https://";
+
+ /**
+ * get token
+ */
+ public static final String GET_IAM_TOKEN = "/v3/auth/tokens";
+
+ /**
+ * rest.
+ */
+ public static final String REST = "/rest";
+
+ /**
+ * donsdata url.
+ */
+ public static final String INSTALL_URL = "install";
+
+ /**
+ * donsdata url.
+ */
+ public static final String UNINSTALL_URL = "uninstall";
+
+ /**
+ * respool url.
+ */
+ public static final String RESOPERATE_URL = "/v1/resoperate";
+
+ /**
+ * limits url.
+ */
+ public static final String LIMITS_URL = "/v1/limits";
+
+ private UrlConstant() {
+ // private constructor
+ }
+
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/util/JsonUtil.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/util/JsonUtil.java
new file mode 100644
index 0000000..5440a7a
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/util/JsonUtil.java
@@ -0,0 +1,290 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.common.util;
+
+import org.openo.nfvo.resmanagement.common.constant.ParamConstant;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import net.sf.json.JSONArray;
+import net.sf.json.JSONException;
+import net.sf.json.JSONObject;
+
+/**
+ *
+ * Json Utility Class.<br/>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Sep 10, 2016
+ */
+public final class JsonUtil {
+
+ private static final Logger LOG = LoggerFactory.getLogger(StringUtil.class);
+
+ private static final int TYPE_STRING = 0;
+
+ private static final int TYPE_INT = 1;
+
+ private static final int TYPE_JSONA = 2;
+
+ private static final int TYPE_JSONO = 3;
+
+ private static final int TYPE_LONG = 4;
+
+ private JsonUtil() {
+ }
+
+ /**
+ *
+ * Get Json Field String.<br>
+ *
+ * @param jsonObj
+ * @param fieldName
+ * @return
+ * @since NFVO 0.5
+ */
+ public static String getJsonFieldStr(JSONObject jsonObj, String fieldName) {
+ return (String)getJsonFieldObject(jsonObj, fieldName, TYPE_STRING);
+ }
+
+ /**
+ *
+ * Get Json Field Integer.<br>
+ *
+ * @param jsonObj
+ * @param fieldName
+ * @return
+ * @since NFVO 0.5
+ */
+ public static Integer getJsonFieldInt(JSONObject jsonObj, String fieldName) {
+ return (Integer)getJsonFieldObject(jsonObj, fieldName, TYPE_INT);
+ }
+
+ /**
+ *
+ * Get Json Field array.<br>
+ *
+ * @param jsonObj
+ * @param fieldName
+ * @return
+ * @since NFVO 0.5
+ */
+ public static JSONArray getJsonFieldArr(JSONObject jsonObj, String fieldName) {
+ return (JSONArray)getJsonFieldObject(jsonObj, fieldName, TYPE_JSONA);
+ }
+
+ /**
+ *
+ * Get Json Field Json.<br>
+ *
+ * @param jsonObj
+ * @param fieldName
+ * @return
+ * @since NFVO 0.5
+ */
+ public static JSONObject getJsonFieldJson(JSONObject jsonObj, String fieldName) {
+ return (JSONObject)getJsonFieldObject(jsonObj, fieldName, TYPE_JSONO);
+ }
+
+ /**
+ *
+ * Get Json Field Long.<br>
+ *
+ * @param jsonObj
+ * @param fieldName
+ * @return
+ * @since NFVO 0.5
+ */
+ public static Long getJsonFieldLong(JSONObject jsonObj, String fieldName) {
+ return (Long)getJsonFieldObject(jsonObj, fieldName, TYPE_LONG);
+ }
+
+ /**
+ *
+ * Get Json Field Object.<br>
+ *
+ * @param jsonObj
+ * @param fieldName
+ * @param classType
+ * @return
+ * @since NFVO 0.5
+ */
+ private static Object getJsonFieldObject(JSONObject jsonObj, String fieldName, int classType) {
+ try {
+ if(null != jsonObj && jsonObj.has(fieldName)) {
+ Object result = new Object();
+ switch(classType) {
+ case TYPE_STRING:
+ result = "null".equals(jsonObj.getString(fieldName)) ? "" : jsonObj.getString(fieldName);
+ break;
+ case TYPE_INT:
+ result = jsonObj.getInt(fieldName);
+ break;
+ case TYPE_JSONA:
+ result = jsonObj.getJSONArray(fieldName);
+ break;
+ case TYPE_JSONO:
+ result = jsonObj.getJSONObject(fieldName);
+ break;
+ case TYPE_LONG:
+ result = jsonObj.getLong(fieldName);
+ break;
+ default:
+ result = null;
+ break;
+ }
+ return result;
+ }
+ } catch(JSONException e) {
+ LOG.error("function=getJsonFieldLong, exception: {} ", e);
+ return null;
+ }
+ return null;
+ }
+
+ /**
+ *
+ * Check whether the Json Object is empty.<br>
+ *
+ * @param jsonObject
+ * @return
+ * @since NFVO 0.5
+ */
+ public static boolean isNullJson(JSONObject jsonObject) {
+ if(null == jsonObject || jsonObject.isEmpty()) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ *
+ * Get String value by Json.<br>
+ *
+ * @param json
+ * @param key
+ * @return
+ * @since NFVO 0.5
+ */
+ public static String getStrValueByjson(JSONObject json, String key) {
+ JSONArray names = json.names();
+ String result = null;
+ for(int i = 0; i < names.size(); i++) {
+ String nodeName = names.getString(i);
+ if(json.optJSONObject(nodeName) != null) {
+ result = getStrValueByjson(json.getJSONObject(nodeName), key);
+ }
+ if(json.optJSONArray(nodeName) != null) {
+ result = getStrValueByJArray(json.getJSONArray(nodeName), key);
+ }
+ if(nodeName.equals(key)) {
+ result = json.getString(nodeName);
+ break;
+ }
+ }
+ return result;
+ }
+
+ private static String getStrValueByJArray(JSONArray json, String key) {
+ String result = null;
+ for(int i = 0; i < json.size(); i++) {
+ if(json.optJSONObject(i) != null) {
+ result = getStrValueByjson(json.getJSONObject(i), key);
+ }
+ if(json.optJSONArray(i) != null) {
+ result = getStrValueByJArray(json.getJSONArray(i), key);
+ }
+ }
+ return result;
+ }
+
+ /**
+ *
+ * Get Json Value by Json object.<br>
+ *
+ * @param json
+ * @param key
+ * @return
+ * @since NFVO 0.5
+ */
+ public static JSONObject getJsonValueByjson(JSONObject json, String key) {
+ JSONObject resultJson = new JSONObject();
+ String result = getStrValueByjson(json, key);
+ if(null == result) {
+ return null;
+ }
+ resultJson.element(key, result);
+ return resultJson;
+
+ }
+
+ /**
+ *
+ * Get String Value by Json object.<br>
+ *
+ * @param json
+ * @param parentKey
+ * @param key
+ * @return
+ * @since NFVO 0.5
+ */
+ public static String getStrValueByJson(JSONObject json, String parentKey, String key) {
+ if(parentKey.isEmpty()) {
+ return getStrValueByjson(json, key);
+ }
+ JSONObject parentJson = getJsonValueByjson(json, parentKey);
+ if(isNullJson(parentJson)) {
+ return null;
+ }
+ return getStrValueByjson(parentJson, key);
+
+ }
+
+ /**
+ *
+ * Get response Data.<br>
+ *
+ * @param obj
+ * @return
+ * @since NFVO 0.5
+ */
+ public static JSONObject getResponseData(JSONObject obj) {
+ JSONObject result = new JSONObject();
+
+ Integer retCode = getJsonFieldInt(obj, ParamConstant.PARAM_RETCODE);
+ if(null == retCode || retCode == -1) {
+ return null;
+ }
+
+ if(obj.optJSONObject(ParamConstant.PARAM_DATA) != null) {
+ result = obj.getJSONObject(ParamConstant.PARAM_DATA);
+ } else if(obj.optJSONArray(ParamConstant.PARAM_DATA) != null) {
+ result = obj.getJSONArray(ParamConstant.PARAM_DATA).getJSONObject(0);
+ }
+ if(result.isEmpty()) {
+ return null;
+ }
+
+ if(result.containsKey(ParamConstant.PARAM_RETCODE)) {
+ result = getResponseData(result);
+ }
+ return result;
+ }
+
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/util/RestfulUtil.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/util/RestfulUtil.java
new file mode 100644
index 0000000..e644e27
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/util/RestfulUtil.java
@@ -0,0 +1,371 @@
+/*
+ * Copyright 2016-2017 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.common.util;
+
+import java.lang.invoke.MethodHandles;
+import java.lang.invoke.MethodType;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.lang3.StringUtils;
+import org.openo.baseservice.remoteservice.exception.ServiceException;
+import org.openo.baseservice.roa.util.restclient.Restful;
+import org.openo.baseservice.roa.util.restclient.RestfulAsyncCallback;
+import org.openo.baseservice.roa.util.restclient.RestfulFactory;
+import org.openo.baseservice.roa.util.restclient.RestfulOptions;
+import org.openo.baseservice.roa.util.restclient.RestfulParametes;
+import org.openo.baseservice.roa.util.restclient.RestfulResponse;
+import org.openo.nfvo.resmanagement.common.ResourceUtil;
+import org.openo.nfvo.resmanagement.common.constant.Constant;
+import org.openo.nfvo.resmanagement.common.constant.ParamConstant;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import net.sf.json.JSONArray;
+import net.sf.json.JSONException;
+import net.sf.json.JSONObject;
+
+/**
+ * Restful Utility Class.<br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Sep 10, 2016
+ */
+public class RestfulUtil {
+
+ public static final String TYPE_GET = "get";
+
+ public static final String TYPE_PUT = "put";
+
+ public static final String TYPE_POST = "post";
+
+ public static final String TYPE_DEL = "delete";
+
+ public static final String CONTENT_TYPE = "Content-type";
+
+ public static final String APPLICATION = "application/json";
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(RestfulUtil.class);
+
+ private static final Restful REST_CLIENT = RestfulFactory.getRestInstance(RestfulFactory.PROTO_HTTP);
+
+ private RestfulUtil() {
+ }
+
+ /**
+ * Get response object.<br>
+ *
+ * @param url
+ * @param type
+ * @return
+ * @since NFVO 0.5
+ */
+ public static JSONObject getResponseObj(String url, String type) {
+ return getResponseObj(url, new RestfulParametes(), type);
+ }
+
+ /**
+ * Get response object.<br>
+ *
+ * @param url
+ * @param parametes
+ * @param type
+ * @return
+ * @since NFVO 0.5
+ */
+ public static JSONObject getResponseObj(String url, RestfulParametes parametes, String type) {
+ try {
+ String content = RestfulUtil.getResponseContent(url, parametes, null, type);
+ LOGGER.error("function=getResponseObj, content : {}", content);
+ if(StringUtils.isEmpty(content)) {
+ return null;
+ }
+ return JSONObject.fromObject(content);
+ } catch(JSONException e) {
+ LOGGER.error("function=getResponseObj, exception : {}", e);
+ return null;
+ }
+ }
+
+ /**
+ * Get response content.<br>
+ *
+ * @param url
+ * @param restParametes
+ * @param type
+ * @return
+ * @since NFVO 0.5
+ */
+ public static String getResponseContent(String url, RestfulParametes restParametes, String type) {
+ return getResponseContent(url, restParametes, null, type);
+ }
+
+ /**
+ * Get response map.<br>
+ *
+ * @param url
+ * @param restParametes
+ * @param opt
+ * @param type
+ * @return
+ * @since NFVO 0.5
+ */
+ public static Map<String, Object> getResponseMap(String url, RestfulParametes restParametes, RestfulOptions opt,
+ String type) {
+ RestfulResponse response = restfulResponse(url, restParametes, opt, type);
+ return getResponseMap(response);
+ }
+
+ /**
+ * Get response content map.<br>
+ *
+ * @param url
+ * @param type
+ * @return
+ * @since NFVO 0.5
+ */
+ public static Map<String, Object> getResponseContentMap(String url, String type) {
+ RestfulResponse response = restfulResponse(url, new RestfulParametes(), null, type);
+ return getResponseMap(response);
+ }
+
+ private static Map<String, Object> getResponseMap(RestfulResponse response) {
+ Map<String, Object> resMap = new HashMap<>(10);
+ if(null != response) {
+ resMap.put(Constant.RESPONSE_CONTENT, response.getResponseContent());
+ resMap.put(Constant.STATUS_CODE, response.getStatus());
+ }
+ return resMap;
+ }
+
+ /**
+ * Get response content.<br>
+ *
+ * @param url
+ * @param restParametes
+ * @param opt
+ * @param type
+ * @return
+ * @since NFVO 0.5
+ */
+ public static String getResponseContent(String url, RestfulParametes restParametes, RestfulOptions opt,
+ String type) {
+ String responseContent = null;
+ RestfulResponse rsp = restfulResponse(url, restParametes, opt, type);
+ if(rsp != null) {
+ int httpStatus = rsp.getStatus();
+ LOGGER.warn("function=getResponseContent, get response httpStatusCode : {} ", httpStatus);
+ if(httpStatus < HttpServletResponse.SC_BAD_REQUEST && httpStatus > 0) {
+ responseContent = rsp.getResponseContent();
+ LOGGER.warn("function=getResponseContent, get response data success!responseContent={}",
+ responseContent);
+ }
+ }
+ return responseContent;
+ }
+
+ /**
+ * Get restful response.<br>
+ *
+ * @param url
+ * @param restParametes
+ * @param type
+ * @return
+ * @since NFVO 0.5
+ */
+ public static RestfulResponse getRestfulResponse(String url, RestfulParametes restParametes, String type) {
+ return restfulResponse(url, restParametes, null, type);
+ }
+
+ private static RestfulResponse restfulResponse(String url, RestfulParametes restParametes, RestfulOptions opt,
+ String type) {
+ RestfulResponse rsp = new RestfulResponse();
+ try {
+
+ if(REST_CLIENT != null) {
+ if(TYPE_GET.equals(type)) {
+ rsp = REST_CLIENT.get(url, restParametes, opt);
+ } else if(TYPE_POST.equals(type)) {
+ rsp = REST_CLIENT.post(url, restParametes, opt);
+ } else if(TYPE_PUT.equals(type)) {
+ rsp = REST_CLIENT.put(url, restParametes, opt);
+ } else if(TYPE_DEL.equals(type)) {
+ rsp = REST_CLIENT.delete(url, restParametes, opt);
+ }
+ }
+ } catch(ServiceException e) {
+ LOGGER.error("function=restfulResponse, get restful response catch exception {} ", e);
+ }
+ LOGGER.warn("function=restfulResponse, response status is {} ", rsp.getStatus());
+ return rsp;
+ }
+
+ /**
+ * encapsulate the java reflect exception.<br>
+ *
+ * @param methodName, Restful's method.
+ * @param objects, method param array.
+ * @return
+ * @since NFVO 0.5
+ */
+ public static RestfulResponse getRestRes(String methodName, Object... objects) {
+ try {
+ if(objects == null || REST_CLIENT == null) {
+ return null;
+ }
+
+ Class<?>[] classes = new Class[objects.length];
+ for(int i = 0; i < objects.length; i++) {
+ classes[i] = objects[i].getClass();
+ }
+ if(methodName.startsWith("async")) {
+ classes[classes.length - 1] = RestfulAsyncCallback.class;
+ }
+
+ Class<?> rtType = methodName.startsWith("async") ? void.class : RestfulResponse.class;
+ MethodType mt = MethodType.methodType(rtType, classes);
+ Object result = MethodHandles.lookup().findVirtual(REST_CLIENT.getClass(), methodName, mt)
+ .bindTo(REST_CLIENT).invokeWithArguments(objects);
+ if(result != null) {
+ return (RestfulResponse)result;
+ }
+ LOGGER.warn("function=getRestRes, msg: invoke Restful async {} method which return type is Void.",
+ methodName);
+ return null;
+ } catch(ReflectiveOperationException e) {
+ LOGGER.error("function=getRestRes, msg=error occurs, e={}.", e);
+ } catch(Throwable e) {// NOSONAR
+ LOGGER.error("function=getRestRes, msg=Throwable, e={}.", e);
+ try {
+ throw (ServiceException)new ServiceException().initCause(e.getCause());
+ } catch(ServiceException se) {
+ LOGGER.error("function=getRestRes, msg=ServiceException occurs, e={}.", se);
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Get response.<br>
+ *
+ * @param restParametes
+ * @param url
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ public static JSONArray getResponseRes(RestfulParametes restParametes, String url) throws ServiceException {
+ String result = getResponseContent(url, restParametes, RestfulUtil.TYPE_GET);
+ if(null == result || result.isEmpty()) {
+ LOGGER.error("result from url:" + url + " result:" + result);
+ throw new ServiceException(
+ ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.group.resoperate.add.res.no.result"));
+ }
+
+ JSONArray rsArray = null;
+ try {
+ JSONObject rsJson = JSONObject.fromObject(result);
+ rsArray = rsJson.getJSONArray(ParamConstant.PARAM_DATA);
+ } catch(JSONException e) {
+ LOGGER.error("getResources error:" + e);
+ throw new ServiceException(
+ ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.group.resoperate.add.res.no.result"));
+ }
+ return rsArray;
+ }
+
+ /**
+ * Get response.<br>
+ *
+ * @param restParametes
+ * @param url
+ * @param iResName
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ public static JSONArray getResponseRes(RestfulParametes restParametes, String url, String iResName)
+ throws ServiceException {
+ String result = getResponseContent(url, restParametes, RestfulUtil.TYPE_GET);
+ if(null == result || result.isEmpty()) {
+ LOGGER.error("result from url:" + url + " result:" + result);
+ throw new ServiceException(
+ ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.group.resoperate.add.res.no.result"));
+ }
+
+ JSONArray rsArray = null;
+ try {
+ JSONObject rsJson = JSONObject.fromObject(result);
+ rsArray = rsJson.getJSONArray(iResName);
+ String vimId = rsJson.getString(ParamConstant.PARAM_VIMID);
+ String vimName = rsJson.getString(ParamConstant.PARAM_VIMNAME);
+ for(int i = 0; i < rsArray.size(); i++) {
+ JSONObject jsonObj = rsArray.getJSONObject(i);
+ jsonObj.put(ParamConstant.PARAM_VIMID, vimId);
+ jsonObj.put(ParamConstant.PARAM_VIMNAME, vimName);
+ }
+ } catch(JSONException e) {
+ LOGGER.error("getResources error:" + e);
+ throw new ServiceException(
+ ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.group.resoperate.add.res.no.result"));
+ }
+ return rsArray;
+ }
+
+ /**
+ * <br>
+ *
+ * @param paramsMap
+ * @param params
+ * @return
+ * @since NFVO 0.5
+ */
+ public static RestfulResponse getRemoteResponse(Map<String, String> paramsMap, String params) {
+ String url = paramsMap.get("url");
+ String methodType = paramsMap.get("methodType");
+
+ RestfulResponse rsp = null;
+ Restful rest = RestfulFactory.getRestInstance(RestfulFactory.PROTO_HTTP);
+ try {
+
+ RestfulParametes restfulParametes = new RestfulParametes();
+ Map<String, String> headerMap = new HashMap<>(3);
+ headerMap.put(CONTENT_TYPE, APPLICATION);
+ restfulParametes.setHeaderMap(headerMap);
+ restfulParametes.setRawData(params);
+
+ if(rest != null) {
+ if(TYPE_GET.equalsIgnoreCase(methodType)) {
+ rsp = rest.get(url, restfulParametes);
+ } else if(TYPE_POST.equalsIgnoreCase(methodType)) {
+ rsp = rest.post(url, restfulParametes);
+ } else if(TYPE_PUT.equalsIgnoreCase(methodType)) {
+ rsp = rest.put(url, restfulParametes);
+ } else if(TYPE_DEL.equalsIgnoreCase(methodType)) {
+ rsp = rest.delete(url, restfulParametes);
+ }
+ }
+ } catch(ServiceException e) {
+ LOGGER.error("function=getRemoteResponse, get restful response catch exception {}", e);
+ }
+ return rsp;
+ }
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/util/StringUtil.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/util/StringUtil.java
new file mode 100644
index 0000000..fd8f09f
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/util/StringUtil.java
@@ -0,0 +1,215 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.common.util;
+
+import java.math.BigDecimal;
+import java.text.DecimalFormat;
+
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ *
+ * String Utility Class.<br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Sep 10, 2016
+ */
+public final class StringUtil {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(StringUtil.class);
+
+ private StringUtil() {
+ }
+
+ /**
+ *
+ * Check whether thestring is valid.<br>
+ *
+ * @param str
+ * @return
+ * @since NFVO 0.5
+ */
+ public static boolean isValidString(String str) {
+ if(null == str || str.isEmpty()) {
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ *
+ * Check whether the value is larger than zero.<br>
+ *
+ * @param strs
+ * @return
+ * @since NFVO 0.5
+ */
+ public static boolean isAnyLargeThanZero(String... strs) {
+ for(String str : strs) {
+ if(!StringUtils.isEmpty(str) && Float.parseFloat(str) > 0) {
+ LOGGER.info("isAnyLargeThanZero : {} is > 0", str);
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ *
+ * Check whether the value is Integer.<br>
+ *
+ * @param strs
+ * @return
+ * @since NFVO 0.5
+ */
+ public static boolean isInteger(String... strs) {
+ try {
+ for(String str : strs) {
+ if(!StringUtils.isEmpty(str)) {
+ int value = Integer.parseInt(str);
+ if(value < 0) {
+ return false;
+ }
+ }
+ }
+ } catch(NumberFormatException e) {
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ *
+ * Check whether the input is Numeric.<br>
+ *
+ * @param strs
+ * @return
+ * @since NFVO 0.5
+ */
+ public static boolean isNumeric(String... strs) {
+ try {
+ for(String str : strs) {
+ if(!StringUtils.isEmpty(str)) {
+ float value = Float.parseFloat(str);
+ if(value < 0) {
+ return false;
+ }
+ }
+ }
+ } catch(NumberFormatException e) {
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ *
+ * Compare zero by float.<br>
+ *
+ * @param tatol
+ * @param used
+ * @param drTotal
+ * @return
+ * @since NFVO 0.5
+ */
+ public static boolean compareZeroByFloat(String tatol, String used, String drTotal) {
+ Float ftotal = (float)0;
+ Float fused = (float)0;
+ Float fdrTotal = (float)0;
+ if(!StringUtils.isEmpty(tatol)) {
+ ftotal = new Float(tatol);
+ }
+ if(!StringUtils.isEmpty(used)) {
+ fused = new Float(used);
+ }
+ if(!StringUtils.isEmpty(drTotal)) {
+ fdrTotal = new Float(drTotal);
+ }
+ if(ftotal < fused + fdrTotal) {
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ *
+ * Compare zero by integer.<br>
+ *
+ * @param tatol
+ * @param used
+ * @param drTotal
+ * @return
+ * @since NFVO 0.5
+ */
+ public static boolean compareZeroByInteger(String tatol, String used, String drTotal) {
+ Integer ftotal = (int)0;
+ Integer fused = (int)0;
+ Integer fdrTotal = (int)0;
+ if(!StringUtils.isEmpty(tatol)) {
+ ftotal = Integer.valueOf(tatol);
+ }
+ if(!StringUtils.isEmpty(used)) {
+ fused = Integer.valueOf(used);
+ }
+ if(!StringUtils.isEmpty(drTotal)) {
+ fdrTotal = Integer.valueOf(drTotal);
+ }
+ if(ftotal < fused + fdrTotal) {
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ *
+ * Number format.<br>
+ *
+ * @param data
+ * @return
+ * @since NFVO 0.5
+ */
+ public static String numFormat(String data) {
+ if(null != data && !("".equals(data))) {
+ BigDecimal var = new BigDecimal(data);
+ DecimalFormat formatWithoutFraction = new DecimalFormat("############");
+ DecimalFormat formatWithFraction = new DecimalFormat("############.############");
+ if(new BigDecimal(var.intValue()).compareTo(var) == 0) {
+ return formatWithoutFraction.format(var);
+ }
+ return formatWithFraction.format(var);
+ }
+ return null;
+ }
+
+ /**
+ *
+ * <br>
+ *
+ * @param inputStr
+ * @return
+ * @since NFVO 0.5
+ */
+ public static boolean checkXss(String inputStr) {
+ return inputStr.matches("[A-Za-z0-9_.']+");
+ }
+
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/util/request/RequestUtil.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/util/request/RequestUtil.java
new file mode 100644
index 0000000..5eae4e3
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/util/request/RequestUtil.java
@@ -0,0 +1,129 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.common.util.request;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.commons.io.IOUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import net.sf.json.JSONException;
+import net.sf.json.JSONObject;
+
+/**
+ * <br/>
+ * <p>
+ * Utility used for request
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 2016-3-17
+ */
+public final class RequestUtil {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(RequestUtil.class);
+
+ /**
+ * Constructor<br/>
+ * <p>
+ * </p>
+ *
+ * @since NFVO 0.5
+ */
+ private RequestUtil() {
+ }
+
+ /**
+ * Get context string from http context
+ *
+ * @param context
+ * http context
+ * @return the needed string in http context
+ */
+ public static String getStringRequestBody(HttpServletRequest context) {
+ try {
+ InputStream input = context.getInputStream();
+ return IOUtils.toString(input);
+ } catch(IOException e) {
+ LOGGER.error("function=getStringRequestBody, get httpservletrequest body exception: {}", e);
+ return null;
+ }
+ }
+
+ /**
+ * Get json parameter from http context
+ *
+ * @param context
+ * http context
+ * @return JSONObject
+ */
+ public static JSONObject getJsonRequestBody(HttpServletRequest context) {
+ try {
+ String bodyStr = getStringRequestBody(context);
+ return JSONObject.fromObject(bodyStr);
+ } catch(JSONException e) {
+ LOGGER.error("function=getJsonRequestBody, maybe request param is not a jsonobject exception: {}", e);
+ return null;
+ }
+ }
+
+ /**
+ * Get the body of all request in json format<br/>
+ *
+ * @param context
+ * The http context
+ * @return JSONObject The body of all request in json format
+ * @since NFVO 0.5
+ */
+ public static JSONObject getAllJsonRequestBody(HttpServletRequest context) {
+ JSONObject requestBody = getJsonRequestBody(context);
+ if(null == requestBody) {
+ LOGGER.error("get httpservletrequest body exception");
+ requestBody = new JSONObject();
+ }
+ LOGGER.warn("function=getAllJsonRequestBody; msg=get request data is:[{}]", requestBody.toString());
+ requestBody.put("header", getContextHeader(context));
+ return requestBody;
+ }
+
+ /**
+ * Get the context header<br/>
+ *
+ * @param context
+ * The http context
+ * @return Map context header
+ * @since NFVO 0.5
+ */
+ @SuppressWarnings("unchecked")
+ private static Map<String, String> getContextHeader(HttpServletRequest context) {
+ Map<String, String> header = new HashMap<String, String>();
+ Enumeration<String> headerNames = context.getHeaderNames();
+ while(headerNames.hasMoreElements()) {
+ String headerName = headerNames.nextElement();
+ String value = context.getHeader(headerName);
+ header.put(headerName, value);
+ }
+ return header;
+ }
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/util/response/ResponseUtil.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/util/response/ResponseUtil.java
new file mode 100644
index 0000000..d6b1415
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/util/response/ResponseUtil.java
@@ -0,0 +1,133 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.common.util.response;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import javax.servlet.http.HttpServletRequest;
+
+import net.sf.json.JSONObject;
+
+/**
+ *
+ * Response utility class.<br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Sep 10, 2016
+ */
+public final class ResponseUtil {
+
+ private ResponseUtil() {
+ }
+
+ /**
+ * Roa request common return function, default return code 200 <br/>
+ *
+ * @param retCode
+ * The request return code
+ * @param msg
+ * The request message
+ * @return JSONObject The response for http request
+ * @since NFVO 0.5
+ */
+ public static JSONObject genHttpResponse(int retCode, String msg) {
+ return genHttpResponse(null, createCodeMap(-1, retCode), msg, null);
+ }
+
+ /**
+ * Roa request common return function, default return code 200<br/>
+ *
+ * @param retCode
+ * The request return code
+ * @param msg
+ * The request message
+ * @param map
+ * Other request info of this request
+ * @return JSONObject The response for http request
+ * @since NFVO 0.5
+ */
+ public static JSONObject genHttpResponse(int retCode, String msg, Map<String, Object> map) {
+ return genHttpResponse(null, createCodeMap(-1, retCode), msg, map);
+ }
+
+ /**
+ * Roa request common return method <br/>
+ *
+ * @param context
+ * The http request context
+ * @param httpStatusCode
+ * The http response code
+ * @param retCode
+ * The http request return code
+ * @param msg
+ * The message of request
+ * @return JSONObject The response for http request
+ * @since NFVO 0.5
+ */
+ public static JSONObject genHttpResponse(HttpServletRequest context, int httpStatusCode, int retCode, String msg) {
+ return genHttpResponse(context, createCodeMap(httpStatusCode, retCode), msg, null);
+ }
+
+ /**
+ *
+ * Roa request common return method.<br>
+ *
+ * @param context, The http request context
+ * @param codeMap
+ * @param msg, The message of request
+ * @param map, Other message of request
+ * @return
+ * @since NFVO 0.5
+ */
+ public static JSONObject genHttpResponse(HttpServletRequest context, Map<String, Integer> codeMap, String msg,
+ Map<String, Object> map) {
+ JSONObject object = new JSONObject();
+
+ object.put("msg", msg);
+ if(null != map) {
+ Iterator<Entry<String, Object>> ite = map.entrySet().iterator();
+ if(ite.hasNext()) {
+ Map.Entry<String, Object> entry = ite.next();
+ object.put(entry.getKey(), entry.getValue().toString());
+ }
+ }
+ return object;
+ }
+
+ /**
+ * Create code map to maintenance the relationship between return code and
+ * http status code <br/>
+ *
+ * @param httpStatusCode
+ * The http response code
+ * @param retCode
+ * The http request return code
+ * @return Map
+ * @since NFVO 0.5
+ */
+ private static Map<String, Integer> createCodeMap(int httpStatusCode, int retCode) {
+ Map<String, Integer> codeMap = new HashMap<>(5);
+ codeMap.put("httpStatusCode", httpStatusCode);
+ codeMap.put("retCode", retCode);
+ return codeMap;
+ }
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/util/response/RoaResponseUtil.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/util/response/RoaResponseUtil.java
new file mode 100644
index 0000000..dbb034d
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/common/util/response/RoaResponseUtil.java
@@ -0,0 +1,113 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.common.util.response;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.openo.nfvo.resmanagement.common.constant.HttpConstant;
+import org.openo.nfvo.resmanagement.common.constant.ParamConstant;
+import org.openo.nfvo.resmanagement.common.constant.ResponseConstant;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import net.sf.json.JSONObject;
+
+/**
+ * <br/>
+ * <p>
+ * Utility for generate Roa get/add/update/delete method status
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 2016-3-17
+ */
+public final class RoaResponseUtil {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(RoaResponseUtil.class);
+
+ private RoaResponseUtil() {
+
+ }
+
+ /**
+ * Generate get method response<br/>
+ *
+ * @param list
+ * The basic response for get method
+ * @return JSONObject The response for http request
+ * @since NFVO 0.5
+ */
+ public static <T> JSONObject get(List<T> list) {
+ Map<String, Object> map = new HashMap<String, Object>(10);
+ map.put(ParamConstant.PARAM_DATA, list);
+ LOGGER.info("function=get; msg=get map:{}", map.toString());
+ return ResponseUtil.genHttpResponse(HttpConstant.OK_CODE, ResponseConstant.QUERY_SUCESS_MSG, map);
+ }
+
+ /**
+ * Generate different response by different parameter for add method <br/>
+ *
+ * @param result
+ * The result
+ * @return JSONObject
+ * @since NFVO 0.5
+ */
+ public static JSONObject add(int result) {
+ LOGGER.info("function=add; msg=add result{}", result);
+ if(result <= 0) {
+ return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, ResponseConstant.ADD_FAIL_MSG);
+ } else {
+ return ResponseUtil.genHttpResponse(HttpConstant.OK_CODE, ResponseConstant.ADD_SUCESS_MSG);
+ }
+ }
+
+ /**
+ * Generate different response by different parameter for update method <br/>
+ *
+ * @param result
+ * The result
+ * @return JSONObject The response for http request
+ * @since NFVO 0.5
+ */
+ public static JSONObject update(int result) {
+ LOGGER.info("function=update; msg=update result{}", result);
+ if(result <= 0) {
+ return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, ResponseConstant.MOD_FAIL_MSG);
+ } else {
+ return ResponseUtil.genHttpResponse(HttpConstant.OK_CODE, ResponseConstant.MOD_SUCESS_MSG);
+ }
+ }
+
+ /**
+ * Generate different response by different parameter for delete method <br/>
+ *
+ * @param result
+ * The result
+ * @return delete JSONObject of the response for http request
+ * @since NFVO 0.5
+ */
+ public static JSONObject delete(int result) {
+ LOGGER.info("function=delete; msg=delete result{}", result);
+ if(result <= 0) {
+ return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, ResponseConstant.DEL_FAIL_MSG);
+ } else {
+ return ResponseUtil.genHttpResponse(HttpConstant.OK_CODE, ResponseConstant.DEL_SUCESS_MSG);
+ }
+ }
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/activator/ROAResmgrServicePostProcessor.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/activator/ROAResmgrServicePostProcessor.java
new file mode 100644
index 0000000..ad66303
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/activator/ROAResmgrServicePostProcessor.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.activator;
+
+import org.openo.nfvo.resmanagement.service.adapter.inf.IResmgrAdapterMgrService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.config.DestructionAwareBeanPostProcessor;
+
+/**
+ * <br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Sep 22, 2016
+ */
+public class ROAResmgrServicePostProcessor implements DestructionAwareBeanPostProcessor {
+
+ private static final Logger LOG = LoggerFactory.getLogger(ROAResmgrServicePostProcessor.class);
+
+ @Override
+ public Object postProcessAfterInitialization(Object bean, String name) throws BeansException {
+ if(bean instanceof IResmgrAdapterMgrService) {
+ LOG.warn("Register to Microservice BUS!");
+ IResmgrAdapterMgrService resmgrAdapterSvc = (IResmgrAdapterMgrService)bean;
+ resmgrAdapterSvc.register();
+ }
+
+ return bean;
+ }
+
+ @Override
+ public Object postProcessBeforeInitialization(Object bean, String name) throws BeansException {
+ // TODO Auto-generated method stub
+ return bean;
+ }
+
+ @Override
+ public void postProcessBeforeDestruction(Object bean, String name) throws BeansException {
+ // TODO Auto-generated method stub
+
+ }
+
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/adapter/impl/ResmgrAdapter2MSBManager.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/adapter/impl/ResmgrAdapter2MSBManager.java
new file mode 100644
index 0000000..9e523e3
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/adapter/impl/ResmgrAdapter2MSBManager.java
@@ -0,0 +1,111 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.adapter.impl;
+
+import java.util.Map;
+
+import org.openo.baseservice.roa.util.restclient.RestfulResponse;
+import org.openo.nfvo.resmanagement.common.constant.Constant;
+import org.openo.nfvo.resmanagement.common.constant.HttpConstant;
+import org.openo.nfvo.resmanagement.common.util.RestfulUtil;
+import org.openo.nfvo.resmanagement.service.adapter.inf.IResmgrAdapter2MSBManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import net.sf.json.JSONObject;
+
+/**
+ * <br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Sep 22, 2016
+ */
+public class ResmgrAdapter2MSBManager implements IResmgrAdapter2MSBManager {
+
+ private static final Logger LOG = LoggerFactory.getLogger(ResmgrAdapter2MSBManager.class);
+
+ @Override
+ public JSONObject registerResmgr(Map<String, String> paramsMap, JSONObject driverInfo) {
+ JSONObject resultObj = new JSONObject();
+
+ RestfulResponse rsp = RestfulUtil.getRemoteResponse(paramsMap, driverInfo.toString());
+ if(null == rsp) {
+ LOG.error("function=registerResmgr, RestfulResponse is null");
+ resultObj.put("reason", "RestfulResponse is null.");
+ resultObj.put("retCode", Constant.ERROR_CODE);
+ return resultObj;
+ }
+ LOG.warn("function=registerResmgr, status={}, content={}.", rsp.getStatus(), rsp.getResponseContent());
+ String resultCreate = rsp.getResponseContent();
+
+ if(rsp.getStatus() == HttpConstant.HTTP_CREATED) {
+ LOG.warn("function=registerResmgr, msg= status={}, result={}.", rsp.getStatus(), resultCreate);
+ resultObj = JSONObject.fromObject(resultCreate);
+ resultObj.put("retCode", HttpConstant.HTTP_CREATED);
+ return resultObj;
+ } else if(rsp.getStatus() == HttpConstant.HTTP_INVALID_PARAMETERS) {
+ LOG.error("function=registerResmgr, msg=MSB return fail,invalid parameters,status={}, result={}.",
+ rsp.getStatus(), resultCreate);
+ resultObj.put("reason", "MSB return fail,invalid parameters.");
+ } else if(rsp.getStatus() == HttpConstant.HTTP_INNERERROR_CODE) {
+ LOG.error("function=registerResmgr, msg=MSB return fail,internal system error,status={}, result={}.",
+ rsp.getStatus(), resultCreate);
+ resultObj.put("reason", "MSB return fail,internal system error.");
+ }
+ resultObj.put("retCode", Constant.ERROR_CODE);
+ return resultObj;
+ }
+
+ @Override
+ public JSONObject unregisterResmgr(Map<String, String> paramsMap) {
+ JSONObject resultObj = new JSONObject();
+
+ RestfulResponse rsp = RestfulUtil.getRemoteResponse(paramsMap, "");
+ if(null == rsp) {
+ LOG.error("function=unregisterResmgr, RestfulResponse is null");
+ resultObj.put("reason", "RestfulResponse is null.");
+ resultObj.put("retCode", Constant.ERROR_CODE);
+ return resultObj;
+ }
+ String resultCreate = rsp.getResponseContent();
+
+ if(rsp.getStatus() == HttpConstant.HTTP_NOCONTENT) {
+ LOG.warn("function=unregisterResmgr, msg= status={}, result={}.", rsp.getStatus(), resultCreate);
+ resultObj = JSONObject.fromObject(resultCreate);
+ resultObj.put("retCode", HttpConstant.HTTP_NOCONTENT);
+ return resultObj;
+ } else if(rsp.getStatus() == HttpConstant.HTTP_NOTFOUND_CODE) {
+ LOG.error(
+ "function=unregisterResmgr, msg=MSB return fail,can't find the service instance.status={}, result={}.",
+ rsp.getStatus(), resultCreate);
+ resultObj.put("reason", "MSB return fail,can't find the service instance.");
+ } else if(rsp.getStatus() == HttpConstant.HTTP_INVALID_PARAMETERS) {
+ LOG.error("function=unregisterResmgr, msg=MSB return fail,invalid parameters,status={}, result={}.",
+ rsp.getStatus(), resultCreate);
+ resultObj.put("reason", "MSB return fail,invalid parameters.");
+ } else if(rsp.getStatus() == HttpConstant.HTTP_INNERERROR_CODE) {
+ LOG.error("function=unregisterResmgr, msg=MSB return fail,internal system error,status={}, result={}.",
+ rsp.getStatus(), resultCreate);
+ resultObj.put("reason", "MSB return fail,internal system error.");
+ }
+ resultObj.put("retCode", Constant.ERROR_CODE);
+ return resultObj;
+ }
+
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/adapter/impl/ResmgrAdapterMgrService.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/adapter/impl/ResmgrAdapterMgrService.java
new file mode 100644
index 0000000..ea9a53d
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/adapter/impl/ResmgrAdapterMgrService.java
@@ -0,0 +1,185 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.adapter.impl;
+
+import java.io.BufferedInputStream;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.Executors;
+
+import org.openo.baseservice.util.impl.SystemEnvVariablesFactory;
+import org.openo.nfvo.resmanagement.common.constant.Constant;
+import org.openo.nfvo.resmanagement.common.constant.HttpConstant;
+import org.openo.nfvo.resmanagement.common.constant.ParamConstant;
+import org.openo.nfvo.resmanagement.common.constant.UrlConstant;
+import org.openo.nfvo.resmanagement.service.adapter.inf.IResmgrAdapter2MSBManager;
+import org.openo.nfvo.resmanagement.service.adapter.inf.IResmgrAdapterMgrService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+
+import net.sf.json.JSONObject;
+
+/**
+ * <br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Sep 22, 2016
+ */
+@Service
+public class ResmgrAdapterMgrService implements IResmgrAdapterMgrService {
+
+ private static final Logger LOG = LoggerFactory.getLogger(ResmgrAdapterMgrService.class);
+
+ public static final String RESMGRADAPTERINFO = "resmgradapterinfo.json";
+
+ @Override
+ public void register() {
+ // set BUS URL and mothedtype
+ Map<String, String> paramsMap = new HashMap<>();
+ paramsMap.put("url", UrlConstant.REST_MSB_REGISTER);
+ paramsMap.put("methodType", ParamConstant.PARAM_POST);
+
+ // get resmgr info and raise registration
+ try {
+ String resmgrInfo = readVimAdapterInfoFromJson();
+ if(!"".equals(resmgrInfo)) {
+ JSONObject adapterObject = JSONObject.fromObject(resmgrInfo);
+ RegisterResmgrThread resmgrThread = new RegisterResmgrThread(paramsMap, adapterObject);
+ Executors.newSingleThreadExecutor().submit(resmgrThread);
+ } else {
+ LOG.error("Resmgr info is null,please check!");
+ }
+
+ } catch(IOException e) {
+ LOG.error("Failed to read Resmgr info! " + e.getMessage(), e);
+ }
+
+ }
+
+ /**
+ * Retrieve VIM driver information.
+ *
+ * @return
+ * @throws IOException
+ */
+ public static String readVimAdapterInfoFromJson() throws IOException {
+ InputStream ins = null;
+ BufferedInputStream bins = null;
+ String fileContent = "";
+
+ String fileName = SystemEnvVariablesFactory.getInstance().getAppRoot() + System.getProperty("file.separator")
+ + "etc" + System.getProperty("file.separator") + "adapterInfo" + System.getProperty("file.separator")
+ + RESMGRADAPTERINFO;
+
+ try {
+ ins = new FileInputStream(fileName);
+ bins = new BufferedInputStream(ins);
+
+ byte[] contentByte = new byte[ins.available()];
+ int num = bins.read(contentByte);
+
+ if(num > 0) {
+ fileContent = new String(contentByte);
+ }
+ } catch(FileNotFoundException e) {
+ LOG.error(fileName + "is not found!", e);
+ } finally {
+ if(ins != null) {
+ ins.close();
+ }
+ if(bins != null) {
+ bins.close();
+ }
+ }
+
+ return fileContent;
+ }
+
+ private static class RegisterResmgrThread implements Runnable {
+
+ // Thread lock Object
+ private final Object lockObject = new Object();
+
+ private IResmgrAdapter2MSBManager adapter2MSBMgr = new ResmgrAdapter2MSBManager();
+
+ // url and mothedtype
+ private Map<String, String> paramsMap;
+
+ // driver body
+ private JSONObject adapterInfo;
+
+ public RegisterResmgrThread(Map<String, String> paramsMap, JSONObject adapterInfo) {
+ this.paramsMap = paramsMap;
+ this.adapterInfo = adapterInfo;
+ }
+
+ @Override
+ public void run() {
+ LOG.info("start register resmgr", RegisterResmgrThread.class);
+
+ if(paramsMap == null || adapterInfo == null) {
+ LOG.error("parameter is null,please check!", RegisterResmgrThread.class);
+ return;
+ }
+
+ // catch Runtime Exception
+ try {
+ sendRequest(paramsMap, adapterInfo);
+ } catch(RuntimeException e) {
+ LOG.error(e.getMessage(), e);
+ }
+
+ }
+
+ private void sendRequest(Map<String, String> paramsMap, JSONObject driverInfo) {
+ JSONObject resultObj = adapter2MSBMgr.registerResmgr(paramsMap, driverInfo);
+
+ if(Integer.valueOf(resultObj.get("retCode").toString()) == HttpConstant.HTTP_CREATED) {
+ LOG.info("Resmgr has now Successfully Registered to the Microservice BUS!");
+ } else {
+ LOG.error("Resmgr failed to Register to the Microservice BUS! Reason:"
+ + resultObj.get("reason").toString() + " retCode:" + resultObj.get("retCode").toString());
+
+ // if registration fails,wait one minute and try again
+ try {
+ synchronized(lockObject) {
+ lockObject.wait(Constant.REPEAT_REG_TIME);
+ }
+ } catch(InterruptedException e) {
+ LOG.error(e.getMessage(), e);
+ }
+
+ sendRequest(this.paramsMap, this.adapterInfo);
+ }
+
+ }
+
+ }
+
+ @Override
+ public void unregister() {
+ // unregister
+ }
+
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/adapter/inf/IResmgrAdapter2MSBManager.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/adapter/inf/IResmgrAdapter2MSBManager.java
new file mode 100644
index 0000000..df00261
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/adapter/inf/IResmgrAdapter2MSBManager.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.adapter.inf;
+
+import java.util.Map;
+
+import net.sf.json.JSONObject;
+
+/**
+ * <br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Sep 22, 2016
+ */
+public interface IResmgrAdapter2MSBManager {
+
+ /**
+ * <br>
+ *
+ * @param paramsMap
+ * @param driverInfo
+ * @return
+ * @since NFVO 0.5
+ */
+ JSONObject registerResmgr(Map<String, String> paramsMap, JSONObject driverInfo);
+
+ /**
+ * <br>
+ *
+ * @param paramsMap
+ * @return
+ * @since NFVO 0.5
+ */
+ JSONObject unregisterResmgr(Map<String, String> paramsMap);
+
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/adapter/inf/IResmgrAdapterMgrService.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/adapter/inf/IResmgrAdapterMgrService.java
new file mode 100644
index 0000000..05d4739
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/adapter/inf/IResmgrAdapterMgrService.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.adapter.inf;
+
+/**
+ * <br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Sep 22, 2016
+ */
+public interface IResmgrAdapterMgrService {
+
+ /**
+ * Resmgr register interface.
+ */
+ void register();
+
+ /**
+ * Resmgr unregister interface.
+ */
+ void unregister();
+
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/impl/HostImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/impl/HostImpl.java
new file mode 100644
index 0000000..131d7c7
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/impl/HostImpl.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.base.openstack.impl;
+
+import java.util.List;
+import java.util.Map;
+
+import org.openo.baseservice.remoteservice.exception.ServiceException;
+import org.openo.nfvo.resmanagement.service.base.openstack.inf.Host;
+import org.openo.nfvo.resmanagement.service.business.inf.HostBusiness;
+import org.openo.nfvo.resmanagement.service.entity.HostEntity;
+
+import net.sf.json.JSONObject;
+
+/**
+ *
+ * Host implementation class.<br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Sep 10, 2016
+ */
+public class HostImpl implements Host {
+
+ private HostBusiness hostBusiness;
+
+ @Override
+ public int add(JSONObject jsonObject) throws ServiceException {
+ return hostBusiness.addHost(HostEntity.toEntity(jsonObject));
+ }
+
+ @Override
+ public int update(JSONObject jsonObject) throws ServiceException {
+ return hostBusiness.updateHostSelective(HostEntity.toEntity(jsonObject));
+ }
+
+ @Override
+ public int update(HostEntity portEntity) throws ServiceException {
+ return hostBusiness.updateHostSelective(portEntity);
+ }
+
+ @Override
+ public int delete(String id) throws ServiceException {
+ return hostBusiness.deleteHost(id);
+ }
+
+ @Override
+ public int updateStatusByVimId(JSONObject jsonObject) throws ServiceException {
+ return hostBusiness.updateHostByVimId(HostEntity.toEntity(jsonObject));
+ }
+
+ @Override
+ public int deleteResByVimId(String vimId) throws ServiceException {
+ return hostBusiness.deleteHostByVimId(vimId);
+ }
+
+ @Override
+ public List<HostEntity> getList(Map<String, Object> condition) throws ServiceException {
+ return hostBusiness.getHosts(condition);
+ }
+
+ public void setHostBusiness(HostBusiness hostBusiness) {
+ this.hostBusiness = hostBusiness;
+ }
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/impl/LocationImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/impl/LocationImpl.java
new file mode 100644
index 0000000..346ac84
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/impl/LocationImpl.java
@@ -0,0 +1,186 @@
+/*
+ * Copyright 2016-2017 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.base.openstack.impl;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.openo.baseservice.remoteservice.exception.ServiceException;
+import org.openo.nfvo.resmanagement.common.VimUtil;
+import org.openo.nfvo.resmanagement.common.constant.ParamConstant;
+import org.openo.nfvo.resmanagement.common.util.JsonUtil;
+import org.openo.nfvo.resmanagement.service.base.openstack.inf.Location;
+import org.openo.nfvo.resmanagement.service.base.openstack.inf.Sites;
+import org.openo.nfvo.resmanagement.service.business.inf.LocationBusiness;
+import org.openo.nfvo.resmanagement.service.entity.LocationEntity;
+import org.openo.nfvo.resmanagement.service.entity.SitesEntity;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import net.sf.json.JSONArray;
+import net.sf.json.JSONObject;
+
+/**
+ * Location Implementation Class.<br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Sep 10, 2016
+ */
+public class LocationImpl implements Location {
+
+ private LocationBusiness locationBusiness;
+
+ private Sites sites;
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(LocationImpl.class);
+
+ @Override
+ public int add(JSONObject jsonObject) throws ServiceException {
+ return locationBusiness.addLocation(LocationEntity.toEntity(jsonObject));
+ }
+
+ @Override
+ public int update(JSONObject jsonObject) throws ServiceException {
+ return locationBusiness.updateLocationSelective(LocationEntity.toEntity(jsonObject));
+ }
+
+ @Override
+ public int delete(String location) throws ServiceException {
+ return locationBusiness.deleteLocation(location);
+ }
+
+ @Override
+ public Map<String, Object> get(String id) throws ServiceException {
+ Map<String, Object> map = new HashMap<>();
+ map.put(ParamConstant.PARAM_ID, id);
+ List<LocationEntity> sodores = locationBusiness.getLocations(map);
+ map.clear();
+ map.put(ParamConstant.PARAM_DATA, sodores);
+ return map;
+ }
+
+ @Override
+ public List<LocationEntity> get(Map<String, Object> condition) throws ServiceException {
+ return locationBusiness.getLocations(condition);
+ }
+
+ @Override
+ public List<String> getCountry() throws ServiceException {
+ return locationBusiness.getCountry();
+ }
+
+ @Override
+ public List<String> getCloudservice() throws ServiceException {
+ LOGGER.info("get cloud service from external system");
+ JSONArray vims = VimUtil.getVims();
+ LOGGER.info("vims: " + vims.toString());
+ List<String> cloudService = new ArrayList<>();
+ for(int i = 0; i < vims.size(); i++) {
+ String vimName = vims.getJSONObject(i).getString("name");
+ cloudService.add(vimName);
+ }
+ return cloudService;
+ }
+
+ @Override
+ public List<String> getLocationByCountry(Map<String, Object> condition) throws ServiceException {
+ return locationBusiness.getLocationByCountry(condition);
+ }
+
+ @Override
+ public LocationEntity getLocation(Map<String, Object> condition) throws ServiceException {
+ List<LocationEntity> locationlist = locationBusiness.getLocations(condition);
+ if(null == locationlist || locationlist.isEmpty()) {
+ return null;
+ }
+ return locationlist.get(0);
+ }
+
+ @Override
+ public List<JSONObject> getLocationInfo(List<LocationEntity> locationInfo) throws ServiceException {
+ ArrayList<JSONObject> newSites = new ArrayList<>();
+ Map<String, Object> condition = new HashMap<>();
+ for(int i = 0; i < locationInfo.size(); i++) {
+ LocationEntity locationEntity = locationInfo.get(i);
+ String latitude = locationEntity.getLatitude();
+ String longitude = locationEntity.getLongitude();
+ String locatSite = locationEntity.getLocation();
+ condition.put(ParamConstant.PARAM_LOCATION, locatSite);
+ LOGGER.info("LocationRoa::getLocation condition:{}", condition);
+ List<SitesEntity> sitesEntity = sites.getList(condition);
+ LOGGER.info("LocationRoa::getLocation sitesEntity:{}", sitesEntity);
+ if(null != sitesEntity && !sitesEntity.isEmpty()) {
+ for(SitesEntity entity : sitesEntity) {
+ JSONObject site = JSONObject.fromObject(entity.toString());
+ JSONObject resTotalJo = site.getJSONObject("total");
+ JSONObject resUsedlJo = site.getJSONObject("used");
+ JSONObject ressiteJo = computingSite(resTotalJo, resUsedlJo);
+ site.element("latitude", latitude);
+ site.element("longitude", longitude);
+ site.element("siteDetail", ressiteJo);
+ LOGGER.info("LocationRoa::getLocation latitude:{}, longitude:{}", latitude, longitude);
+ LOGGER.info("LocationRoa::getLocation site:{}", site);
+ newSites.add(site);
+ }
+ }
+ }
+ return newSites;
+ }
+
+ /**
+ * Computing site.<br>
+ *
+ * @param total
+ * @param used
+ * @return
+ * @since NFVO 0.5
+ */
+ public JSONObject computingSite(JSONObject total, JSONObject used) {
+ String vcpus = JsonUtil.getJsonFieldStr(total, ParamConstant.PARAM_VCPUS);
+ String memorys = JsonUtil.getJsonFieldStr(total, ParamConstant.PARAM_MEMORY);
+ String disks = JsonUtil.getJsonFieldStr(total, ParamConstant.PARAM_DISK);
+ String vcpusused = JsonUtil.getJsonFieldStr(used, ParamConstant.PARAM_VCPUS);
+ String memoryused = JsonUtil.getJsonFieldStr(used, ParamConstant.PARAM_MEMORY);
+ String diskused = JsonUtil.getJsonFieldStr(used, ParamConstant.PARAM_DISK);
+ float cpu = Float.parseFloat(vcpusused) / Float.parseFloat(vcpus);
+ float memory = Float.parseFloat(memoryused) / Integer.parseInt(memorys);
+ float disk = Float.parseFloat(diskused) / Float.parseFloat(disks);
+ JSONObject resTotalJo = new JSONObject();
+ resTotalJo.put(ParamConstant.PARAM_VCPUS, String.valueOf(Math.round(cpu * 100)) + "%");
+ resTotalJo.put(ParamConstant.PARAM_MEMORY, String.valueOf(Math.round(memory * 100)) + "%");
+ resTotalJo.put(ParamConstant.PARAM_DISK, String.valueOf(Math.round(disk * 100)) + "%");
+
+ return resTotalJo;
+ }
+
+ public LocationBusiness getLocationBusiness() {
+ return locationBusiness;
+ }
+
+ public void setLocationBusiness(LocationBusiness locationBusiness) {
+ this.locationBusiness = locationBusiness;
+ }
+
+ public void setSites(Sites sites) {
+ this.sites = sites;
+ }
+
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/impl/NetworkImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/impl/NetworkImpl.java
new file mode 100644
index 0000000..b9ec757
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/impl/NetworkImpl.java
@@ -0,0 +1,101 @@
+/*
+ * Copyright 2016-2017 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.base.openstack.impl;
+
+import java.util.List;
+import java.util.Map;
+
+import org.openo.baseservice.remoteservice.exception.ServiceException;
+import org.openo.nfvo.resmanagement.common.util.JsonUtil;
+import org.openo.nfvo.resmanagement.service.base.openstack.inf.Network;
+import org.openo.nfvo.resmanagement.service.business.inf.NetworkBusiness;
+import org.openo.nfvo.resmanagement.service.entity.NetworkEntity;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import net.sf.json.JSONObject;
+
+/**
+ * Network implementation class.<br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Sep 10, 2016
+ */
+public class NetworkImpl implements Network {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(NetworkImpl.class);
+
+ private NetworkBusiness networkBusiness;
+
+ @Override
+ public int add(JSONObject jsonObject) throws ServiceException {
+ LOGGER.warn("function=addPort; jsonObject={}", jsonObject);
+ JSONObject networkObj = dataParse(jsonObject);
+ return networkBusiness.addNetwork(NetworkEntity.toEntity(networkObj));
+ }
+
+ private JSONObject dataParse(JSONObject jsonObject) {
+ JSONObject portObj = new JSONObject();
+ portObj.put("id", JsonUtil.getJsonFieldStr(jsonObject, "id"));
+ portObj.put("name", JsonUtil.getJsonFieldStr(jsonObject, "name"));
+ portObj.put("status", JsonUtil.getJsonFieldStr(jsonObject, "status"));
+ portObj.put("tenantId", JsonUtil.getJsonFieldStr(jsonObject, "tenant_id"));
+ portObj.put("vimId", JsonUtil.getJsonFieldStr(jsonObject, "vimId"));
+ portObj.put("vimName", JsonUtil.getJsonFieldStr(jsonObject, "vimName"));
+ portObj.put("physicalNetwork", JsonUtil.getJsonFieldStr(jsonObject, "physicalNetwork"));
+ portObj.put("networkType", JsonUtil.getJsonFieldStr(jsonObject, "networkType"));
+ portObj.put("segmentationId", JsonUtil.getJsonFieldStr(jsonObject, "segmentationId"));
+ return portObj;
+ }
+
+ @Override
+ public int add(NetworkEntity entity) throws ServiceException {
+ return networkBusiness.addNetwork(entity);
+ }
+
+ @Override
+ public int update(JSONObject jsonObject) throws ServiceException {
+ return networkBusiness.updateNetworkSelective(NetworkEntity.toEntity(jsonObject));
+ }
+
+ @Override
+ public int delete(String id) throws ServiceException {
+ return networkBusiness.deleteNetwork(id);
+ }
+
+ @Override
+ public int updateStatusByVimId(JSONObject jsonObject) throws ServiceException {
+ return networkBusiness.updateNetworkByVimId(NetworkEntity.toEntity(jsonObject));
+ }
+
+ @Override
+ public List<NetworkEntity> getList(Map<String, Object> condition) throws ServiceException {
+ return networkBusiness.getNetworks(condition);
+ }
+
+ @Override
+ public int deleteResByVimId(String vimId) throws ServiceException {
+ return networkBusiness.deleteNetworkByVimId(vimId);
+ }
+
+ public void setNetworkBusiness(NetworkBusiness networkBusiness) {
+ this.networkBusiness = networkBusiness;
+ }
+
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/impl/PortImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/impl/PortImpl.java
new file mode 100644
index 0000000..3dee172
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/impl/PortImpl.java
@@ -0,0 +1,103 @@
+/*
+ * Copyright 2016-2017 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.base.openstack.impl;
+
+import java.util.List;
+import java.util.Map;
+
+import org.openo.baseservice.remoteservice.exception.ServiceException;
+import org.openo.nfvo.resmanagement.common.util.JsonUtil;
+import org.openo.nfvo.resmanagement.service.base.openstack.inf.Port;
+import org.openo.nfvo.resmanagement.service.business.inf.PortBusiness;
+import org.openo.nfvo.resmanagement.service.entity.PortEntity;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import net.sf.json.JSONObject;
+
+/**
+ * Port implementation class.<br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Sep 10, 2016
+ */
+public class PortImpl implements Port {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(PortImpl.class);
+
+ private PortBusiness portBusiness;
+
+ @Override
+ public int add(JSONObject jsonObject) throws ServiceException {
+ LOGGER.warn("function=addPort; jsonObject={}", jsonObject);
+ JSONObject portObj = dataParse(jsonObject);
+ return portBusiness.addPort(PortEntity.toEntity(portObj));
+ }
+
+ private JSONObject dataParse(JSONObject jsonObject) {
+ JSONObject portObj = new JSONObject();
+ portObj.put("id", JsonUtil.getJsonFieldStr(jsonObject, "id"));
+ portObj.put("name", JsonUtil.getJsonFieldStr(jsonObject, "name"));
+ portObj.put("networkId", JsonUtil.getJsonFieldStr(jsonObject, "networkId"));
+ portObj.put("status", JsonUtil.getJsonFieldStr(jsonObject, "status"));
+ portObj.put("tenantId", JsonUtil.getJsonFieldStr(jsonObject, "tenant_id"));
+ portObj.put("vimId", JsonUtil.getJsonFieldStr(jsonObject, "vimId"));
+ portObj.put("vimName", JsonUtil.getJsonFieldStr(jsonObject, "vimName"));
+ return portObj;
+ }
+
+ @Override
+ public int add(PortEntity portEntity) throws ServiceException {
+ return portBusiness.addPort(portEntity);
+ }
+
+ @Override
+ public int update(JSONObject jsonObject) throws ServiceException {
+ return portBusiness.updatePortSelective(PortEntity.toEntity(jsonObject));
+ }
+
+ @Override
+ public int update(PortEntity portEntity) throws ServiceException {
+ return portBusiness.updatePortSelective(portEntity);
+ }
+
+ @Override
+ public int delete(String id) throws ServiceException {
+ return portBusiness.deletePort(id);
+ }
+
+ @Override
+ public int updateStatusByVimId(JSONObject jsonObject) throws ServiceException {
+ return portBusiness.updatePortByVimId(PortEntity.toEntity(jsonObject));
+ }
+
+ @Override
+ public int deleteResByVimId(String vimId) throws ServiceException {
+ return portBusiness.deletePortByVimId(vimId);
+ }
+
+ @Override
+ public List<PortEntity> getList(Map<String, Object> condition) throws ServiceException {
+ return portBusiness.getPorts(condition);
+ }
+
+ public void setPortBusiness(PortBusiness portBusiness) {
+ this.portBusiness = portBusiness;
+ }
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/impl/SitesImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/impl/SitesImpl.java
new file mode 100644
index 0000000..6b9345e
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/impl/SitesImpl.java
@@ -0,0 +1,231 @@
+/*
+ * Copyright 2016-2017 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.base.openstack.impl;
+
+import java.math.BigDecimal;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+import org.apache.commons.lang3.StringUtils;
+import org.openo.baseservice.remoteservice.exception.ServiceException;
+import org.openo.nfvo.resmanagement.common.VimUtil;
+import org.openo.nfvo.resmanagement.common.constant.ParamConstant;
+import org.openo.nfvo.resmanagement.common.util.JsonUtil;
+import org.openo.nfvo.resmanagement.service.base.openstack.inf.Sites;
+import org.openo.nfvo.resmanagement.service.business.inf.LimitsBusiness;
+import org.openo.nfvo.resmanagement.service.business.inf.SitesBusiness;
+import org.openo.nfvo.resmanagement.service.entity.SitesEntity;
+import org.openo.nfvo.resmanagement.service.group.inf.ResOperateService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import net.sf.json.JSONObject;
+
+/**
+ * DC info interface.<br/>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Aug 24, 2016
+ */
+public class SitesImpl implements Sites {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(SitesImpl.class);
+
+ private SitesBusiness sitesBusiness;
+
+ private LimitsBusiness limitsBusiness;
+
+ private ResOperateService resOperateService;
+
+ @Override
+ public int add(JSONObject jsonObject) throws ServiceException {
+ LOGGER.info("Add datacenter jsonObject: {}", jsonObject);
+ SitesEntity sitesEntity = SitesEntity.toEntity(jsonObject);
+ sitesEntity.setStatus(ParamConstant.PARAM_ACTIVE);
+ String vimName = jsonObject.getString(ParamConstant.PARAM_VIMNAME);
+ String vimId = VimUtil.getVimIdByName(vimName);
+ sitesEntity.setVimId(vimId);
+ JSONObject resource = limitsBusiness.getLimits(vimId);
+ sitesEntity.setVimName(resource.getString(ParamConstant.PARAM_VIMNAME));
+ sitesEntity.setTotalCPU(resource.getString(ParamConstant.TOTAL_CPU));
+ sitesEntity.setUsedCPU(resource.getString(ParamConstant.USED_CPU));
+ sitesEntity.setTotalMemory(resource.getString(ParamConstant.TOTAL_MEMORY));
+ sitesEntity.setUsedMemory(resource.getString(ParamConstant.USED_MEMORY));
+ sitesEntity.setTotalDisk(resource.getString(ParamConstant.TOTAL_DISK));
+ sitesEntity.setUsedDisk(resource.getString(ParamConstant.USED_DISK));
+ if(StringUtils.isEmpty(sitesEntity.getId())) {
+ sitesEntity.setId(UUID.randomUUID().toString());
+ jsonObject.put(ParamConstant.PARAM_ID, sitesEntity.getId());
+ }
+ LOGGER.info("Add datacenter sitesEntity: {}", sitesEntity.toString());
+ return sitesBusiness.addSite(sitesEntity);
+ }
+
+ /**
+ * <br>
+ *
+ * @param json
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ @Override
+ public void sendToMonitor(JSONObject jsonObject) throws ServiceException {
+ LOGGER.info("SitesImpl sendToMonitor jsonObject: {}", jsonObject);
+ String vimName = jsonObject.getString(ParamConstant.PARAM_VIMNAME);
+ String vimId = VimUtil.getVimIdByName(vimName);
+ JSONObject vimInfo = VimUtil.getVimById(vimId);
+ LOGGER.info("SitesImpl sendToMonitor vimInfo: {}", vimInfo);
+ String tenant = vimInfo.getString("tenant");
+ String tenantId = VimUtil.getTenantIdByName(tenant, vimId);
+ JSONObject json = new JSONObject();
+ json.put("header", null);
+ LOGGER.info("tenantId:{}, vimId:{}", tenantId, vimId);
+ resOperateService.addIRes(tenantId, vimId, json);
+ resOperateService.sendMsgMonitor("create", vimId);
+ }
+
+ @Override
+ public int update(SitesEntity sitesEntity) throws ServiceException {
+ return sitesBusiness.updateSiteSelective(sitesEntity);
+ }
+
+ @Override
+ public int update(JSONObject jsonObject) throws ServiceException {
+ LOGGER.info("grantResource jsonObject: {}", jsonObject);
+ JSONObject sitesObj = dataParse(jsonObject);
+ return sitesBusiness.updateSiteSelective(SitesEntity.toEntity(sitesObj));
+ }
+
+ private JSONObject dataParse(JSONObject jsonObject) throws ServiceException {
+ String vimId = jsonObject.getString(ParamConstant.PARAM_VIMID);
+ Map<String, Object> condition = new HashMap<>();
+ condition.put("vimId", vimId);
+ SitesEntity sitesEntity = get(condition);
+ if(null == sitesEntity) {
+ LOGGER.error("Get sites null, vimId={}", vimId);
+ return null;
+ }
+ return computeSiteUsed(jsonObject, sitesEntity);
+ }
+
+ private JSONObject computeSiteUsed(JSONObject jsonObject, SitesEntity sitesEntity) throws ServiceException {
+ String action = JsonUtil.getJsonFieldStr(jsonObject, "action");
+ String usedCpu = JsonUtil.getJsonFieldStr(jsonObject, ParamConstant.USED_CPU);
+ String usedMemory = JsonUtil.getJsonFieldStr(jsonObject, ParamConstant.USED_MEMORY);
+ String usedDisk = JsonUtil.getJsonFieldStr(jsonObject, ParamConstant.USED_DISK);
+ String oldCpu = sitesEntity.getUsedCPU();
+ String oldMemory = sitesEntity.getUsedMemory();
+ String oldDisk = sitesEntity.getUsedDisk();
+ String newCpu = accumOrFreeRes(usedCpu, oldCpu, action, sitesEntity.getTotalCPU(), "cpu");
+ String newMemory = accumOrFreeRes(usedMemory, oldMemory, action, sitesEntity.getTotalMemory(), "memory");
+ String newDisk = accumOrFreeRes(usedDisk, oldDisk, action, sitesEntity.getTotalDisk(), "disk");
+
+ JSONObject resUsed = new JSONObject();
+ resUsed.put(ParamConstant.USED_CPU, newCpu);
+ resUsed.put(ParamConstant.USED_MEMORY, newMemory);
+ resUsed.put(ParamConstant.USED_DISK, newDisk);
+ resUsed.put("id", sitesEntity.getId());
+ resUsed.put("name", sitesEntity.getName());
+ resUsed.put("status", sitesEntity.getStatus());
+ resUsed.put("location", sitesEntity.getLocation());
+ resUsed.put("country", sitesEntity.getCountry());
+ resUsed.put(ParamConstant.PARAM_VIMID, sitesEntity.getVimId());
+ resUsed.put(ParamConstant.PARAM_VIMNAME, sitesEntity.getVimName());
+ resUsed.put(ParamConstant.TOTAL_CPU, sitesEntity.getTotalCPU());
+ resUsed.put(ParamConstant.TOTAL_MEMORY, sitesEntity.getTotalMemory());
+ resUsed.put(ParamConstant.TOTAL_DISK, sitesEntity.getTotalDisk());
+ return resUsed;
+ }
+
+ private String accumOrFreeRes(String resUsed, String resOld, String action, String total, String type)
+ throws ServiceException {
+ BigDecimal iResUsed = new BigDecimal(resUsed);
+ BigDecimal iResOld = new BigDecimal(resOld);
+ BigDecimal itotal = new BigDecimal(total);
+ if("online".equals(action)) {
+ if(iResOld.add(iResUsed).compareTo(itotal) > 0) {
+ throw new ServiceException("Grant resource fail! The " + type + " resource not enough.");
+ }
+ return String.valueOf(iResOld.add(iResUsed));
+ } else {
+ if(iResOld.subtract(iResUsed).compareTo(BigDecimal.ZERO) < 0) {
+ throw new ServiceException("Grant resource fail! The " + type + " resource used below zero.");
+ }
+ return String.valueOf(iResOld.subtract(iResUsed));
+ }
+ }
+
+ @Override
+ public int updateResource(JSONObject jsonObject) throws ServiceException {
+ return sitesBusiness.updateSiteResource(SitesEntity.toEntity(jsonObject));
+ }
+
+ @Override
+ public int delete(String id) throws ServiceException {
+ Map<String, Object> map = new HashMap<String, Object>(10);
+ map.put(ParamConstant.PARAM_ID, id);
+ List<SitesEntity> datacenters = getList(map);
+ SitesEntity site = datacenters.get(0);
+ LOGGER.info("site: {}", site);
+ String vimId = site.getVimId();
+ LOGGER.info("vimId: {}", vimId);
+ resOperateService.sendMsgMonitor("delete", vimId);
+ resOperateService.deleteIRes(vimId);
+ return sitesBusiness.deleteSite(id);
+ }
+
+ @Override
+ public int updateStatusByVimId(JSONObject jsonObject) throws ServiceException {
+ return sitesBusiness.updateSiteByVimId(SitesEntity.toEntity(jsonObject));
+ }
+
+ @Override
+ public List<SitesEntity> getList(Map<String, Object> condition) throws ServiceException {
+ return sitesBusiness.getSites(condition);
+ }
+
+ @Override
+ public SitesEntity get(Map<String, Object> condition) throws ServiceException {
+ List<SitesEntity> siteList = sitesBusiness.getSites(condition);
+ if(null == siteList || siteList.isEmpty()) {
+ return null;
+ }
+ return siteList.get(0);
+ }
+
+ @Override
+ public int deleteResByVimId(String vimId) throws ServiceException {
+ return 0;
+ }
+
+ public void setSitesBusiness(SitesBusiness sitesBusiness) {
+ this.sitesBusiness = sitesBusiness;
+ }
+
+ public void setLimitsBusiness(LimitsBusiness limitsBusiness) {
+ this.limitsBusiness = limitsBusiness;
+ }
+
+ public void setResOperateService(ResOperateService resOperateService) {
+ this.resOperateService = resOperateService;
+ }
+
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/impl/VimImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/impl/VimImpl.java
new file mode 100644
index 0000000..d1405a2
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/impl/VimImpl.java
@@ -0,0 +1,82 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.base.openstack.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.openo.baseservice.remoteservice.exception.ServiceException;
+import org.openo.nfvo.resmanagement.service.base.openstack.inf.Vim;
+import org.openo.nfvo.resmanagement.service.business.inf.VimBusiness;
+import org.openo.nfvo.resmanagement.service.entity.VimEntity;
+
+import net.sf.json.JSONObject;
+
+/**
+ * Vim info interface.<br/>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Aug 24, 2016
+ */
+public class VimImpl implements Vim {
+
+ private VimBusiness vimBusiness;
+
+ @Override
+ public int add(String id) throws ServiceException {
+ return vimBusiness.addVim(id);
+ }
+
+ @Override
+ public int add(JSONObject jsonObject) throws ServiceException {
+ return add(jsonObject.getString("id"));
+ }
+
+ @Override
+ public int update(JSONObject jsonObject) throws ServiceException {
+ return 0;
+ }
+
+ @Override
+ public int delete(String id) throws ServiceException {
+ return vimBusiness.deleteVim(id);
+ }
+
+ @Override
+ public VimEntity getVim(String id) throws ServiceException {
+ return vimBusiness.getVim(id);
+ }
+
+ @Override
+ public List<VimEntity> getList() throws ServiceException {
+ return vimBusiness.getVims();
+ }
+
+ @Override
+ public List<JSONObject> getVimInfo(Map<String, Object> condition) throws ServiceException {
+ // get vim from vimadapter
+ return new ArrayList<JSONObject>();
+ }
+
+ public void setVimBusiness(VimBusiness vimBusiness) {
+ this.vimBusiness = vimBusiness;
+ }
+
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/inf/Host.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/inf/Host.java
new file mode 100644
index 0000000..44adb19
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/inf/Host.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.base.openstack.inf;
+
+import java.util.List;
+import java.util.Map;
+
+import org.openo.baseservice.remoteservice.exception.ServiceException;
+import org.openo.nfvo.resmanagement.service.entity.HostEntity;
+
+import net.sf.json.JSONObject;
+
+/**
+ * <br/>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Aug 25, 2016
+ */
+public interface Host extends InterfaceResManagement {
+
+ /**
+ * <br/>
+ *
+ * @param jsonObject
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ int updateStatusByVimId(JSONObject jsonObject) throws ServiceException;
+
+ /**
+ * <br/>
+ *
+ * @param condition
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ List<HostEntity> getList(Map<String, Object> condition) throws ServiceException;
+
+ /**
+ * <br/>
+ *
+ * @param resPoolEntity
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ int update(HostEntity resPoolEntity) throws ServiceException;
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/inf/InterfaceResManagement.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/inf/InterfaceResManagement.java
new file mode 100644
index 0000000..a89e48e
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/inf/InterfaceResManagement.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.base.openstack.inf;
+
+import org.openo.baseservice.remoteservice.exception.ServiceException;
+
+/**
+ * <br/>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Aug 25, 2016
+ */
+public interface InterfaceResManagement extends ResManagement {
+
+ /**
+ * <br/>
+ *
+ * @param vimId
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ int deleteResByVimId(String vimId) throws ServiceException;
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/inf/Location.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/inf/Location.java
new file mode 100644
index 0000000..7ee574c
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/inf/Location.java
@@ -0,0 +1,104 @@
+/*
+ * Copyright 2016-2017 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.base.openstack.inf;
+
+import java.util.List;
+import java.util.Map;
+
+import org.openo.baseservice.remoteservice.exception.ServiceException;
+import org.openo.nfvo.resmanagement.service.entity.LocationEntity;
+
+import net.sf.json.JSONObject;
+
+/**
+ * Location details class.<br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Sep 10, 2016
+ */
+public interface Location extends ResManagement {
+
+ /**
+ * <br>
+ *
+ * @param id
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ Map<String, Object> get(String id) throws ServiceException;
+
+ /**
+ * Get list of locations.<br>
+ *
+ * @param condition
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ List<LocationEntity> get(Map<String, Object> condition) throws ServiceException;
+
+ /**
+ * Get location details.<br>
+ *
+ * @param condition
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ LocationEntity getLocation(Map<String, Object> condition) throws ServiceException;
+
+ /**
+ * Get location info.<br>
+ *
+ * @param locationInfo
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ List<JSONObject> getLocationInfo(List<LocationEntity> locationInfo) throws ServiceException;
+
+ /**
+ * Get Country.<br>
+ *
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ List<String> getCountry() throws ServiceException;
+
+ /**
+ * Get location by country.<br>
+ *
+ * @param condition
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ List<String> getLocationByCountry(Map<String, Object> condition) throws ServiceException;
+
+ /**
+ * Get cloud services.<br>
+ *
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ List<String> getCloudservice() throws ServiceException;
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/inf/Network.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/inf/Network.java
new file mode 100644
index 0000000..bd00e1a
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/inf/Network.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.base.openstack.inf;
+
+import java.util.List;
+import java.util.Map;
+
+import org.openo.baseservice.remoteservice.exception.ServiceException;
+import org.openo.nfvo.resmanagement.service.entity.NetworkEntity;
+
+import net.sf.json.JSONObject;
+
+/**
+ *
+ * Network class.<br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Sep 10, 2016
+ */
+public interface Network extends InterfaceResManagement {
+
+ /**
+ *
+ * Update status by VIM Id.<br>
+ *
+ * @param jsonObject
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ int updateStatusByVimId(JSONObject jsonObject) throws ServiceException;
+
+ /**
+ *
+ * Get list of networks.<br>
+ *
+ * @param condition
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ List<NetworkEntity> getList(Map<String, Object> condition) throws ServiceException;
+
+ /**
+ * <br>
+ *
+ * @param entity
+ * @return
+ * @since NFVO 0.5
+ */
+ int add(NetworkEntity entity) throws ServiceException;
+
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/inf/Port.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/inf/Port.java
new file mode 100644
index 0000000..3ef79b3
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/inf/Port.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.base.openstack.inf;
+
+import java.util.List;
+import java.util.Map;
+
+import org.openo.baseservice.remoteservice.exception.ServiceException;
+import org.openo.nfvo.resmanagement.service.entity.PortEntity;
+
+import net.sf.json.JSONObject;
+
+/**
+ * <br/>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Aug 25, 2016
+ */
+public interface Port extends InterfaceResManagement {
+
+ /**
+ * <br/>
+ *
+ * @param jsonObject
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ int updateStatusByVimId(JSONObject jsonObject) throws ServiceException;
+
+ /**
+ * <br/>
+ *
+ * @param condition
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ List<PortEntity> getList(Map<String, Object> condition) throws ServiceException;
+
+ /**
+ * <br/>
+ *
+ * @param resPoolEntity
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ int update(PortEntity resPoolEntity) throws ServiceException;
+
+ /**
+ * <br>
+ *
+ * @param portEntity
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ int add(PortEntity portEntity) throws ServiceException;
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/inf/ResManagement.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/inf/ResManagement.java
new file mode 100644
index 0000000..8acbf77
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/inf/ResManagement.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.base.openstack.inf;
+
+import org.openo.baseservice.remoteservice.exception.ServiceException;
+
+import net.sf.json.JSONObject;
+
+/**
+ * <br/>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Aug 25, 2016
+ */
+public interface ResManagement {
+
+ /**
+ * <br/>
+ *
+ * @param jsonObject
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ int add(JSONObject jsonObject) throws ServiceException;
+
+ /**
+ * <br/>
+ *
+ * @param jsonObject
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ int update(JSONObject jsonObject) throws ServiceException;
+
+ /*
+ * key : parameter key value : parameter value
+ */
+ /**
+ * <br/>
+ *
+ * @param id
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ int delete(String id) throws ServiceException;
+
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/inf/Sites.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/inf/Sites.java
new file mode 100644
index 0000000..ab2e104
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/inf/Sites.java
@@ -0,0 +1,95 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.base.openstack.inf;
+
+import java.util.List;
+import java.util.Map;
+
+import org.openo.baseservice.remoteservice.exception.ServiceException;
+import org.openo.nfvo.resmanagement.service.entity.SitesEntity;
+
+import net.sf.json.JSONObject;
+
+/**
+ * <br/>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Aug 25, 2016
+ */
+public interface Sites extends InterfaceResManagement {
+
+ /**
+ * <br/>
+ *
+ * @param jsonObject
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ int updateStatusByVimId(JSONObject jsonObject) throws ServiceException;
+
+ /**
+ * <br/>
+ *
+ * @param condition
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ List<SitesEntity> getList(Map<String, Object> condition) throws ServiceException;
+
+ /**
+ * <br/>
+ *
+ * @param condition
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ SitesEntity get(Map<String, Object> condition) throws ServiceException;
+
+ /**
+ * <br/>
+ *
+ * @param jsonObject
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ int updateResource(JSONObject jsonObject) throws ServiceException;
+
+ /**
+ * <br/>
+ *
+ * @param sitesEntity
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ int update(SitesEntity sitesEntity) throws ServiceException;
+
+ /**
+ * <br>
+ *
+ * @param json
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ void sendToMonitor(JSONObject json) throws ServiceException;
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/inf/Vim.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/inf/Vim.java
new file mode 100644
index 0000000..f923e0f
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/base/openstack/inf/Vim.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.base.openstack.inf;
+
+import java.util.List;
+import java.util.Map;
+
+import org.openo.baseservice.remoteservice.exception.ServiceException;
+import org.openo.nfvo.resmanagement.service.entity.VimEntity;
+
+import net.sf.json.JSONObject;
+
+/**
+ * Virtualised Infrastructure Manager.<br/>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Aug 25, 2016
+ */
+public interface Vim extends ResManagement {
+
+ /**
+ * <br/>
+ *
+ * @param id
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ VimEntity getVim(String id) throws ServiceException;
+
+ /**
+ * <br/>
+ *
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ List<VimEntity> getList() throws ServiceException;
+
+ /**
+ *
+ * Get VIM information.<br>
+ *
+ * @param condition
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ List<JSONObject> getVimInfo(Map<String, Object> condition) throws ServiceException;
+
+ /**
+ * <br/>
+ *
+ * @param vimId
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ int add(String vimId) throws ServiceException;
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/impl/HostBusinessImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/impl/HostBusinessImpl.java
new file mode 100644
index 0000000..6da2657
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/impl/HostBusinessImpl.java
@@ -0,0 +1,162 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.business.impl;
+
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+import org.apache.commons.lang3.StringUtils;
+import org.openo.baseservice.remoteservice.exception.ServiceException;
+import org.openo.nfvo.resmanagement.common.ResourceUtil;
+import org.openo.nfvo.resmanagement.service.business.inf.HostBusiness;
+import org.openo.nfvo.resmanagement.service.dao.inf.HostDao;
+import org.openo.nfvo.resmanagement.service.entity.HostEntity;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ *
+ * Host business implementation class.<br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Sep 10, 2016
+ */
+public class HostBusinessImpl implements HostBusiness {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(HostBusinessImpl.class);
+
+ private HostDao hostDao;
+
+ @Override
+ public HostEntity getHost(String id) {
+ if(StringUtils.isEmpty(id)) {
+ LOGGER.error("function=getHost; msg=get error, because id is empty.");
+ return null;
+ }
+ return hostDao.getHost(id);
+ }
+
+ @Override
+ public List<HostEntity> getHosts(Map<String, Object> condition) {
+ return hostDao.getHosts(condition);
+ }
+
+ @Override
+ public int deleteHost(String id) throws ServiceException {
+ if(StringUtils.isEmpty(id)) {
+ LOGGER.error("function=deleteHost; msg=delete error, because id is empty.");
+ throw new ServiceException(ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.host.delete.id.null"));
+ }
+ HostEntity rp = hostDao.getHost(id);
+ if(null == rp) {
+ return hostDao.deleteHost(id);
+ }
+
+ return hostDao.deleteHost(id);
+ }
+
+ @Override
+ public int addHost(HostEntity hostEntity) throws ServiceException {
+ if(null == hostEntity) {
+ LOGGER.error("function=addHost; msg=add error, because hostEntity is null.");
+ throw new ServiceException(
+ ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.host.add.entity.null"));
+ }
+
+ if(!checkId(hostEntity.getId())) {
+ LOGGER.error("function=addHost; msg=add error, because id is already exist.");
+ throw new ServiceException(ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.host.add.id.check"));
+ }
+ if(StringUtils.isEmpty(hostEntity.getId())) {
+ hostEntity.setId(UUID.randomUUID().toString());
+ }
+ return hostDao.addHost(hostEntity);
+ }
+
+ @Override
+ public int addHostSelective(HostEntity hostEntity) throws ServiceException {
+ if(null == hostEntity) {
+ LOGGER.error("function=addHostSelective; msg=add error, because hostEntity is null.");
+ throw new ServiceException(
+ ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.host.add.entity.null"));
+ }
+ if(!checkId(hostEntity.getId())) {
+ LOGGER.error("function=addHostSelective; msg=add error, because id is allready exist.");
+ throw new ServiceException(ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.host.add.id.check"));
+ }
+
+ if(StringUtils.isEmpty(hostEntity.getId())) {
+ hostEntity.setId(UUID.randomUUID().toString());
+ }
+ return hostDao.addHostSelective(hostEntity);
+ }
+
+ private boolean checkId(String id) {
+ HostEntity respool = hostDao.getHost(id);
+ if(null == respool) {
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public int updateHostSelective(HostEntity hostEntity) throws ServiceException {
+ if(!checkId(hostEntity.getId())) {
+ return hostDao.updateHostSelective(hostEntity);
+ } else {
+ return addHostSelective(hostEntity);
+ }
+ }
+
+ @Override
+ public int updateHost(HostEntity hostEntity) throws ServiceException {
+ if(null == hostEntity) {
+ LOGGER.error("function=updateHost; msg=update error, because hostEntity is null.");
+ throw new ServiceException("update error, because hostEntity is null.");
+ }
+
+ return hostDao.updateHost(hostEntity);
+ }
+
+ @Override
+ public int updateHostByVimId(HostEntity hostEntity) throws ServiceException {
+ if(null == hostEntity) {
+ LOGGER.error("function=updateHostByVimId; msg=update error, because hostEntity is null.");
+ throw new ServiceException(
+ ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.host.update.entity.null"));
+ }
+ return hostDao.updateHostByVimId(hostEntity);
+ }
+
+ @Override
+ public int deleteHostByVimId(String vimId) throws ServiceException {
+ if(StringUtils.isEmpty(vimId)) {
+ LOGGER.error("function=deleteHostByVimId; msg=delete error, because VimId is empty.");
+ throw new ServiceException(
+ ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.host.delete.vimid.check"));
+ }
+ return hostDao.deleteHostByVimId(vimId);
+ }
+
+ public void setHostDao(HostDao hostDao) {
+ this.hostDao = hostDao;
+ }
+
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/impl/LimitsBusinessImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/impl/LimitsBusinessImpl.java
new file mode 100644
index 0000000..eeb2de0
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/impl/LimitsBusinessImpl.java
@@ -0,0 +1,93 @@
+/*
+ * Copyright 2016-2017 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.business.impl;
+
+import org.openo.baseservice.remoteservice.exception.ServiceException;
+import org.openo.nfvo.resmanagement.common.VimUtil;
+import org.openo.nfvo.resmanagement.common.constant.ParamConstant;
+import org.openo.nfvo.resmanagement.common.constant.UrlConstant;
+import org.openo.nfvo.resmanagement.common.util.RestfulUtil;
+import org.openo.nfvo.resmanagement.service.business.inf.LimitsBusiness;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import net.sf.json.JSONObject;
+
+/**
+ * <br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Sep 10, 2016
+ */
+public class LimitsBusinessImpl implements LimitsBusiness {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(LimitsBusinessImpl.class);
+
+ /**
+ * <br>
+ *
+ * @param vimId
+ * @param tenantId
+ * @return
+ * @since NFVO 0.5
+ */
+ private JSONObject getResponse(String vimId, String tenantId) {
+ LOGGER.info("function=getResponse; vimId={}, tenantId={}", vimId, tenantId);
+ String url = String.format(UrlConstant.GET_LIMITS_URL, vimId, tenantId);
+ JSONObject result = RestfulUtil.getResponseObj(url, ParamConstant.PARAM_GET);
+ LOGGER.warn("function=getResponse; result={}", result);
+ if(null == result) {
+ JSONObject obj = new JSONObject();
+ obj.put("msg", "getLimits fail!");
+ return obj;
+ }
+ return result;
+ }
+
+ @Override
+ public JSONObject getLimits(String vimId) throws ServiceException {
+ JSONObject vimInfo = VimUtil.getVimById(vimId);
+ LOGGER.info("GetLimits vimInfo: {}", vimInfo);
+ String vimName = vimInfo.getString("name");
+ String tenant = vimInfo.getString("tenant");
+ String tenantId = VimUtil.getTenantIdByName(tenant, vimId);
+
+ JSONObject limits = getResponse(vimId, tenantId);
+
+ String totalCPU = String.valueOf(limits.get("maxTotalCores"));
+ String totalMemory = String.valueOf(limits.get("maxTotalRAMSize"));
+ String totalDisk = String.valueOf(limits.get("maxTotalVolumeGigabytes"));
+ String usedCPU = String.valueOf(limits.get("totalCoresUsed"));
+ String usedMemory = String.valueOf(limits.get("totalRAMUsed"));
+ String usedDisk = String.valueOf(limits.get("totalGigabytesUsed"));
+
+ JSONObject result = new JSONObject();
+ result.put("vimId", vimId);
+ result.put("vimName", vimName);
+ result.put("totalCPU", totalCPU);
+ result.put("totalMemory", totalMemory);
+ result.put("totalDisk", totalDisk);
+ result.put("usedCPU", usedCPU);
+ result.put("usedMemory", usedMemory);
+ result.put("usedDisk", usedDisk);
+ LOGGER.info("getLimits result:{}", result);
+ return result;
+ }
+
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/impl/LocationBusinessImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/impl/LocationBusinessImpl.java
new file mode 100644
index 0000000..76ee2a0
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/impl/LocationBusinessImpl.java
@@ -0,0 +1,242 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.business.impl;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+import org.apache.commons.lang3.StringUtils;
+import org.openo.baseservice.remoteservice.exception.ServiceException;
+import org.openo.nfvo.resmanagement.common.ResourceUtil;
+import org.openo.nfvo.resmanagement.common.constant.ParamConstant;
+import org.openo.nfvo.resmanagement.common.util.StringUtil;
+import org.openo.nfvo.resmanagement.service.business.inf.LocationBusiness;
+import org.openo.nfvo.resmanagement.service.dao.inf.LocationDao;
+import org.openo.nfvo.resmanagement.service.entity.LocationEntity;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ *
+ * Location Business implementation class.<br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Sep 10, 2016
+ */
+public class LocationBusinessImpl implements LocationBusiness {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(LocationBusinessImpl.class);
+
+ private LocationDao locationDao;
+
+ /**
+ *
+ * Check location.<br>
+ *
+ * @param locationEntity
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ public boolean checkLocation(LocationEntity locationEntity) throws ServiceException {
+ String location = locationEntity.getLocation();
+ Map<String, Object> map = new HashMap<>();
+ map.put(ParamConstant.PARAM_LOCATION, location);
+ List<LocationEntity> locationList = getLocations(map);
+ if(locationList == null || locationList.isEmpty()) {
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ *
+ * Check Latitude.;<br>
+ *
+ * @param locationEntity
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ public boolean checkLatitude(LocationEntity locationEntity) throws ServiceException {
+ String latitu = locationEntity.getLatitude();
+ String longitu = locationEntity.getLongitude();
+ if("-0".equals(locationEntity.getLatitude())) {
+ locationEntity.setLatitude("0");
+ }
+ if("-0".equals(locationEntity.getLongitude())) {
+ locationEntity.setLongitude("0");
+ }
+ float latitude = Float.parseFloat(latitu);
+ float longitude = Float.parseFloat(longitu);
+ if((latitude >= -90 && latitude <= 90) && (longitude >= -180 && longitude <= 180)) {
+ return true;
+ }
+ return false;
+ }
+
+ private boolean checkModified(LocationEntity locationEntity) {
+ String newCountry = locationEntity.getCountry();
+ String newLocation = locationEntity.getLocation();
+ String id = locationEntity.getId();
+ LocationEntity selectLocation = locationDao.getLocation(id);
+ if(null == selectLocation) {
+ return false;
+ }
+ String oldCountry = selectLocation.getCountry();
+ String oldLocation = selectLocation.getLocation();
+ if(newCountry.equals(oldCountry) && newLocation.equals(oldLocation)) {
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public LocationEntity getLocation(String id) throws ServiceException {
+ if(StringUtils.isEmpty(id)) {
+ LOGGER.error("function=getLocation; msg=get error, because id is empty.");
+ return null;
+ }
+ return locationDao.getLocation(id);
+ }
+
+ @Override
+ public List<String> getCountry() throws ServiceException {
+ return locationDao.getCountry();
+ }
+
+ @Override
+ public List<String> getLocationByCountry(Map<String, Object> condition) throws ServiceException {
+ return locationDao.getLocationByCountry(condition);
+ }
+
+ @Override
+ public List<LocationEntity> getLocations(Map<String, Object> condition) throws ServiceException {
+ return locationDao.getLocations(condition);
+ }
+
+ @Override
+ public int deleteLocation(String location) throws ServiceException {
+ if(StringUtils.isEmpty(location)) {
+ LOGGER.error("function=deleteLocation; msg=delete error, because location is empty.");
+ throw new ServiceException(
+ ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.location.delete.base.entity.check"));
+ }
+ return locationDao.deleteLocation(location);
+ }
+
+ @Override
+ public int addLocation(LocationEntity locationEntity) throws ServiceException {
+ if(null == locationEntity) {
+ LOGGER.error("function=addLocation; msg=add error, because locationEntity is null.");
+ throw new ServiceException(
+ ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.location.add.entity.null"));
+ }
+ if(!StringUtil.checkXss(locationEntity.getCountry()) || !StringUtil.checkXss(locationEntity.getLocation())
+ || !StringUtil.checkXss(locationEntity.getLatitude())
+ || !StringUtil.checkXss(locationEntity.getLongitude())) {
+ LOGGER.error("function=addLocation; msg=add Location error, because XSS injection.");
+ throw new ServiceException(
+ ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.location.add.xss.check"));
+ }
+ if(checkLocation(locationEntity)) {
+ LOGGER.error("function=addLocation; msg=add Location error, because location exist.");
+ throw new ServiceException(
+ ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.location.add.entity.check"));
+ }
+ if(!checkLatitude(locationEntity)) {
+ LOGGER.error("function=addLocation; msg=add Location error, because latitude or longitude illegal.");
+ throw new ServiceException(
+ ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.location.add.latitude.check"));
+ }
+ if(null == locationEntity.getId() || locationEntity.getId().isEmpty()) {
+ locationEntity.setId(UUID.randomUUID().toString());
+ }
+ LOGGER.error("function=addLocation; msg=add DO success, : " + locationEntity);
+ return locationDao.addLocation(locationEntity);
+
+ }
+
+ @Override
+ public int addLocationSelective(LocationEntity locationEntity) throws ServiceException {
+ if(null == locationEntity) {
+ LOGGER.error("function=addLocationSelective; msg=add error, because locationEntity is null.");
+ throw new ServiceException(
+ ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.location.add.entity.null"));
+ }
+ if(!StringUtil.checkXss(locationEntity.getCountry()) || !StringUtil.checkXss(locationEntity.getLocation())
+ || !StringUtil.checkXss(locationEntity.getLatitude())
+ || !StringUtil.checkXss(locationEntity.getLongitude())) {
+ LOGGER.error("function=addLocation; msg=add Location error, because XSS injection.");
+ throw new ServiceException(
+ ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.location.add.xss.check"));
+ }
+ if(null == locationEntity.getId() || locationEntity.getId().isEmpty()) {
+ locationEntity.setId(UUID.randomUUID().toString());
+ }
+ return locationDao.addLocationSelective(locationEntity);
+ }
+
+ @Override
+ public int updateLocationSelective(LocationEntity locationEntity) throws ServiceException {
+ if(null == locationEntity) {
+ LOGGER.error("function=updateLocationSelective; msg=update error, because locationEntity is null.");
+ throw new ServiceException(
+ ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.location.update.entity.check"));
+ }
+ if(!checkLatitude(locationEntity)) {
+ LOGGER.error("function=updateLocationSelective; msg=update Location error, "
+ + "because latitude or longitude illegal.");
+ throw new ServiceException(
+ ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.location.update.latitude.check"));
+ }
+ if(!checkModified(locationEntity)) {
+ LOGGER.error("function=updateLocationSelective; msg=update Location error, "
+ + "because country or location be modified.");
+ throw new ServiceException(
+ ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.location.update.modified.check"));
+ }
+ return locationDao.updateLocationSelective(locationEntity);
+ }
+
+ @Override
+ public int updateLocation(LocationEntity locationEntity) throws ServiceException {
+ if(null == locationEntity) {
+ LOGGER.error("function=updateLocation; msg=update error, because locationEntity is null.");
+ throw new ServiceException(
+ ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.location.update.entity.null"));
+ }
+ if(!checkLatitude(locationEntity)) {
+ LOGGER.error("function=updateLocation; msg=update Location error, because latitude or longitude illegal.");
+ throw new ServiceException(
+ ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.location.update.latitude.check"));
+ }
+ return locationDao.updateLocation(locationEntity);
+ }
+
+ public LocationDao getLocationDao() {
+ return locationDao;
+ }
+
+ public void setLocationDao(LocationDao locationDao) {
+ this.locationDao = locationDao;
+ }
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/impl/NetworkBusinessImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/impl/NetworkBusinessImpl.java
new file mode 100644
index 0000000..811c3e4
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/impl/NetworkBusinessImpl.java
@@ -0,0 +1,153 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.business.impl;
+
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+import org.apache.commons.lang3.StringUtils;
+import org.openo.baseservice.remoteservice.exception.ServiceException;
+import org.openo.nfvo.resmanagement.common.ResourceUtil;
+import org.openo.nfvo.resmanagement.service.business.inf.NetworkBusiness;
+import org.openo.nfvo.resmanagement.service.dao.inf.NetworkDao;
+import org.openo.nfvo.resmanagement.service.entity.NetworkEntity;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Network business implementation class.<br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Sep 10, 2016
+ */
+public class NetworkBusinessImpl implements NetworkBusiness {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(NetworkBusinessImpl.class);
+
+ private NetworkDao networkDao;
+
+ @Override
+ public NetworkEntity getNetwork(String id) {
+ if(StringUtils.isEmpty(id)) {
+ LOGGER.error("function=getNetwork; msg=get error, because id is empty.");
+ return null;
+ }
+ return networkDao.getNetwork(id);
+ }
+
+ @Override
+ public List<NetworkEntity> getNetworks(Map<String, Object> condition) {
+ return networkDao.getNetworks(condition);
+ }
+
+ @Override
+ public int deleteNetwork(String id) throws ServiceException {
+ if(StringUtils.isEmpty(id)) {
+ LOGGER.error("function=deleteNetwork; msg=delete error, because id is empty.");
+ throw new ServiceException(
+ ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.network.delete.id.null"));
+ }
+ return networkDao.deleteNetwork(id);
+ }
+
+ @Override
+ public int addNetwork(NetworkEntity networkEntity) throws ServiceException {
+ if(null == networkEntity) {
+ LOGGER.error("function=addNetwork; msg=add error, because networkEntity is null.");
+ throw new ServiceException(
+ ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.network.add.entity.null"));
+ }
+ if(!checkId(networkEntity.getId())) {
+ return networkDao.updateNetworkSelective(networkEntity);
+ }
+ if(StringUtils.isEmpty(networkEntity.getId())) {
+ networkEntity.setId(UUID.randomUUID().toString());
+ }
+ return networkDao.addNetwork(networkEntity);
+ }
+
+ @Override
+ public int addNetworkSelective(NetworkEntity networkEntity) throws ServiceException {
+ if(null == networkEntity) {
+ LOGGER.error("function=addNetworkSelective; msg=add error, because networkEntity is null.");
+ throw new ServiceException(
+ ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.network.add.entity.null"));
+ }
+ if(!checkId(networkEntity.getId())) {
+ return networkDao.updateNetworkSelective(networkEntity);
+ }
+ if(StringUtils.isEmpty(networkEntity.getId())) {
+ networkEntity.setId(UUID.randomUUID().toString());
+ }
+ return networkDao.addNetworkSelective(networkEntity);
+ }
+
+ private boolean checkId(String id) {
+ NetworkEntity network = networkDao.getNetwork(id);
+ if(null == network) {
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public int updateNetworkSelective(NetworkEntity networkEntity) throws ServiceException {
+ if(null == networkEntity) {
+ LOGGER.error("function=updateNetworkSelective; msg=update error, because networkEntity is null.");
+ throw new ServiceException(
+ ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.network.update.entity.null"));
+ }
+ return networkDao.updateNetworkSelective(networkEntity);
+ }
+
+ @Override
+ public int updateNetwork(NetworkEntity networkEntity) throws ServiceException {
+ if(null == networkEntity) {
+ LOGGER.error("function=updateNetwork; msg=update error, because networkEntity is null.");
+ throw new ServiceException(
+ ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.network.update.entity.null"));
+ }
+ return networkDao.updateNetwork(networkEntity);
+ }
+
+ @Override
+ public int updateNetworkByVimId(NetworkEntity networkEntity) throws ServiceException {
+ if(null == networkEntity) {
+ LOGGER.error("function=updateNetworkByVimId; msg=update error, because networkEntity is null.");
+ throw new ServiceException(
+ ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.network.update.entity.null"));
+ }
+ return networkDao.updateNetworkByVimId(networkEntity);
+ }
+
+ @Override
+ public int deleteNetworkByVimId(String vimId) throws ServiceException {
+ if(StringUtils.isEmpty(vimId)) {
+ LOGGER.error("function=deleteNetworkByVimId; msg=delete error, because VimId is empty.");
+ throw new ServiceException(ResourceUtil.getMessage(""));
+ }
+ return networkDao.deleteNetworkByVimId(vimId);
+ }
+
+ public void setNetworkDao(NetworkDao networkDao) {
+ this.networkDao = networkDao;
+ }
+
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/impl/PortBusinessImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/impl/PortBusinessImpl.java
new file mode 100644
index 0000000..ce715d9
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/impl/PortBusinessImpl.java
@@ -0,0 +1,161 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.business.impl;
+
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+import org.apache.commons.lang3.StringUtils;
+import org.openo.baseservice.remoteservice.exception.ServiceException;
+import org.openo.nfvo.resmanagement.common.ResourceUtil;
+import org.openo.nfvo.resmanagement.service.business.inf.PortBusiness;
+import org.openo.nfvo.resmanagement.service.dao.inf.PortDao;
+import org.openo.nfvo.resmanagement.service.entity.PortEntity;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Port business implementation class.<br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Sep 10, 2016
+ */
+public class PortBusinessImpl implements PortBusiness {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(PortBusinessImpl.class);
+
+ private PortDao portDao;
+
+ @Override
+ public PortEntity getPort(String id) {
+ if(StringUtils.isEmpty(id)) {
+ LOGGER.error("function=getPort; msg=get error, because id is empty.");
+ return null;
+ }
+ return portDao.getPort(id);
+ }
+
+ @Override
+ public List<PortEntity> getPorts(Map<String, Object> condition) {
+ return portDao.getPorts(condition);
+ }
+
+ @Override
+ public int deletePort(String id) throws ServiceException {
+ if(StringUtils.isEmpty(id)) {
+ LOGGER.error("function=deletePort; msg=delete error, because id is empty.");
+ throw new ServiceException(ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.port.delete.id.null"));
+ }
+ PortEntity rp = portDao.getPort(id);
+ if(null == rp) {
+ return portDao.deletePort(id);
+ }
+
+ return portDao.deletePort(id);
+ }
+
+ @Override
+ public int addPort(PortEntity portEntity) throws ServiceException {
+ if(null == portEntity) {
+ LOGGER.error("function=addPort; msg=add error, because portEntity is null.");
+ throw new ServiceException(
+ ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.port.add.entity.null"));
+ }
+
+ if(!checkId(portEntity.getId())) {
+ return portDao.updatePortSelective(portEntity);
+ }
+ if(StringUtils.isEmpty(portEntity.getId())) {
+ portEntity.setId(UUID.randomUUID().toString());
+ }
+ return portDao.addPort(portEntity);
+ }
+
+ @Override
+ public int addPortSelective(PortEntity portEntity) throws ServiceException {
+ if(null == portEntity) {
+ LOGGER.error("function=addPortSelective; msg=add error, because portEntity is null.");
+ throw new ServiceException(
+ ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.port.add.entity.null"));
+ }
+ if(!checkId(portEntity.getId())) {
+ return portDao.updatePortSelective(portEntity);
+ }
+
+ if(StringUtils.isEmpty(portEntity.getId())) {
+ portEntity.setId(UUID.randomUUID().toString());
+ }
+ return portDao.addPortSelective(portEntity);
+ }
+
+ private boolean checkId(String id) {
+ PortEntity respool = portDao.getPort(id);
+ if(null == respool) {
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public int updatePortSelective(PortEntity portEntity) throws ServiceException {
+ if(null == portEntity) {
+ LOGGER.error("function=updatePortSelective; msg=update error, because portEntity is null.");
+ throw new ServiceException(
+ ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.port.update.entity.null"));
+ }
+
+ return portDao.updatePortSelective(portEntity);
+ }
+
+ @Override
+ public int updatePort(PortEntity portEntity) throws ServiceException {
+ if(null == portEntity) {
+ LOGGER.error("function=updatePort; msg=update error, because portEntity is null.");
+ throw new ServiceException("update error, because portEntity is null.");
+ }
+
+ return portDao.updatePort(portEntity);
+ }
+
+ @Override
+ public int updatePortByVimId(PortEntity portEntity) throws ServiceException {
+ if(null == portEntity) {
+ LOGGER.error("function=updatePortByVimId; msg=update error, because portEntity is null.");
+ throw new ServiceException(
+ ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.port.update.entity.null"));
+ }
+ return portDao.updatePortByVimId(portEntity);
+ }
+
+ @Override
+ public int deletePortByVimId(String vimId) throws ServiceException {
+ if(StringUtils.isEmpty(vimId)) {
+ LOGGER.error("function=deletePortByVimId; msg=delete error, because VimId is empty.");
+ throw new ServiceException(
+ ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.port.delete.vimid.check"));
+ }
+ return portDao.deletePortByVimId(vimId);
+ }
+
+ public void setPortDao(PortDao portDao) {
+ this.portDao = portDao;
+ }
+
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/impl/SitesBusinessImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/impl/SitesBusinessImpl.java
new file mode 100644
index 0000000..6ffb3fc
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/impl/SitesBusinessImpl.java
@@ -0,0 +1,200 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.business.impl;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+import org.apache.commons.lang3.StringUtils;
+import org.openo.baseservice.remoteservice.exception.ServiceException;
+import org.openo.nfvo.resmanagement.common.ResourceUtil;
+import org.openo.nfvo.resmanagement.common.constant.ParamConstant;
+import org.openo.nfvo.resmanagement.service.business.inf.SitesBusiness;
+import org.openo.nfvo.resmanagement.service.dao.inf.SitesDao;
+import org.openo.nfvo.resmanagement.service.entity.SitesEntity;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Sites info interface.<br/>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Aug 24, 2016
+ */
+public class SitesBusinessImpl implements SitesBusiness {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(SitesBusinessImpl.class);
+
+ private SitesDao sitesDao;
+
+ private static final String TYPE_ADD = "add";
+
+ private static final String TYPE_UPDATE = "update";
+
+ private static final String TYPE_DELETE = "delete";
+
+ @Override
+ public SitesEntity getSite(String id) throws ServiceException {
+ if(StringUtils.isEmpty(id)) {
+ LOGGER.error("function=getSite; msg=get error, because id is empty.");
+ throw new ServiceException(
+ ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.site.add.id.null"));
+ }
+ return sitesDao.getSite(id);
+ }
+
+ @Override
+ public List<SitesEntity> getSites(Map<String, Object> condition) {
+ return sitesDao.getSites(condition);
+ }
+
+ @Override
+ public int deleteSite(String id) throws ServiceException {
+ if(StringUtils.isEmpty(id)) {
+ LOGGER.error("function=deleteSite; msg=delete error, because id is empty.");
+ throw new ServiceException(
+ ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.site.delete.id.null"));
+ }
+
+ return sitesDao.deleteSite(id);
+ }
+
+ @Override
+ public int addSite(SitesEntity sitesEntity) throws ServiceException {
+ LOGGER.info("addSite sitesEntity");
+ if(null == sitesEntity) {
+ LOGGER.error("function=addSite; msg=add error, because sitesEntity is null.");
+ throw new ServiceException(
+ ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.site.add.entity.null"));
+ }
+ // if(!StringUtil.checkXss(sitesEntity.getName()) ||
+ // !StringUtil.checkXss(sitesEntity.getCountry())
+ // || !StringUtil.checkXss(sitesEntity.getLocation())) {
+ // LOGGER.error("function=addLocation; msg=add site error, because XSS injection.");
+ // throw new ServiceException(
+ // ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.location.add.xss.check"));
+ // }
+ LOGGER.info("sitesEntity: " + sitesEntity.toString());
+ this.checkSite(sitesEntity, TYPE_ADD);
+ SitesEntity.dataFramat(sitesEntity);
+ LOGGER.info("Add datacenter data into DB.");
+ return sitesDao.addSite(sitesEntity);
+ }
+
+ private void checkSite(SitesEntity sitesEntity, String type) throws ServiceException {
+ if(TYPE_ADD.equals(type)) {
+ checkId(sitesEntity.getId());
+ checkSiteName(sitesEntity.getName());
+ if(!SitesEntity.checkResource(sitesEntity)) {
+ LOGGER.error("function=checkRespool; msg=site{} resource error", sitesEntity.toString());
+ throw new ServiceException(
+ ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.site.add.resource.check"));
+ }
+ }
+ }
+
+ private void checkSiteName(String siteName) throws ServiceException {
+ Map<String, Object> siteMap = new HashMap<>(10);
+ siteMap.put(ParamConstant.PARAM_NAME, siteName);
+ List<SitesEntity> siteList = sitesDao.getSites(siteMap);
+ if(null != siteList && !siteList.isEmpty()) {
+ LOGGER.error("function=checkSiteName; msg=site: {} has already exist.", siteName);
+ throw new ServiceException(
+ ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.site.add.name.check"));
+ }
+ }
+
+ private void checkId(String id) throws ServiceException {
+ SitesEntity site = sitesDao.getSite(id);
+ if(null != site) {
+ LOGGER.error("function=checkId; msg=add error, because id is already exist.");
+ throw new ServiceException(
+ ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.site.add.id.check"));
+ }
+ }
+
+ @Override
+ public int addSiteSelective(SitesEntity sitesEntity) throws ServiceException {
+ if(null == sitesEntity) {
+ LOGGER.error("function=addSiteSelective; msg=add error, because sitesEntity is null.");
+ throw new ServiceException(
+ ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.site.add.entity.null"));
+ }
+ this.checkSite(sitesEntity, TYPE_ADD);
+
+ if(StringUtils.isEmpty(sitesEntity.getId())) {
+ sitesEntity.setId(UUID.randomUUID().toString());
+ }
+ SitesEntity.dataFramat(sitesEntity);
+ return sitesDao.addSiteSelective(sitesEntity);
+ }
+
+ @Override
+ public int updateSiteSelective(SitesEntity sitesEntity) throws ServiceException {
+ if(null == sitesEntity) {
+ LOGGER.error("function=updateSiteSelective; msg=update error, because sitesEntity is null.");
+ throw new ServiceException(
+ ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.site.update.entity.null"));
+ }
+
+ this.checkSite(sitesEntity, TYPE_UPDATE);
+ SitesEntity.dataFramat(sitesEntity);
+ return sitesDao.updateSiteSelective(sitesEntity);
+ }
+
+ @Override
+ public int updateSite(SitesEntity sitesEntity) throws ServiceException {
+ if(null == sitesEntity) {
+ LOGGER.error("function=updateSite; msg=update error, because sitesEntity is null.");
+ throw new ServiceException(
+ ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.site.update.entity.null"));
+ }
+ this.checkSite(sitesEntity, TYPE_UPDATE);
+ SitesEntity.dataFramat(sitesEntity);
+ return sitesDao.updateSite(sitesEntity);
+ }
+
+ @Override
+ public int updateSiteByVimId(SitesEntity sitesEntity) throws ServiceException {
+ if(null == sitesEntity) {
+ LOGGER.error("function=updateSiteByVimId; msg=update error, because sitesEntity is null.");
+ throw new ServiceException(
+ ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.site.update.entity.null"));
+ }
+ SitesEntity.dataFramat(sitesEntity);
+ return sitesDao.updateSiteByVimId(sitesEntity);
+ }
+
+ @Override
+ public int updateSiteResource(SitesEntity sitesEntity) throws ServiceException {
+ if(null == sitesEntity) {
+ LOGGER.error("function=updateSiteResource; msg=update error, because sitesEntity is null.");
+ throw new ServiceException(
+ ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.site.update.entity.null"));
+ }
+ SitesEntity.dataFramat(sitesEntity);
+ return sitesDao.updateSiteSelective(sitesEntity);
+ }
+
+ public void setSitesDao(SitesDao sitesDao) {
+ this.sitesDao = sitesDao;
+ }
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/impl/VimBusinessImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/impl/VimBusinessImpl.java
new file mode 100644
index 0000000..6cbcfc4
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/impl/VimBusinessImpl.java
@@ -0,0 +1,99 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.business.impl;
+
+import java.util.List;
+
+import org.apache.commons.lang3.StringUtils;
+import org.openo.baseservice.remoteservice.exception.ServiceException;
+import org.openo.nfvo.resmanagement.common.ResourceUtil;
+import org.openo.nfvo.resmanagement.common.util.StringUtil;
+import org.openo.nfvo.resmanagement.service.business.inf.VimBusiness;
+import org.openo.nfvo.resmanagement.service.dao.inf.VimDao;
+import org.openo.nfvo.resmanagement.service.entity.VimEntity;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Vim info interface.<br/>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Aug 24, 2016
+ */
+public class VimBusinessImpl implements VimBusiness {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(VimBusinessImpl.class);
+
+ private VimDao vimDao;
+
+ @Override
+ public VimEntity getVim(String id) {
+ if(StringUtils.isEmpty(id)) {
+ LOGGER.error("function=getVim; msg=get error, because id is empty.");
+ return null;
+ }
+ return vimDao.getVim(id);
+ }
+
+ @Override
+ public List<VimEntity> getVims() {
+ return vimDao.getVims();
+ }
+
+ @Override
+ public int deleteVim(String id) throws ServiceException {
+ if(StringUtils.isEmpty(id)) {
+ LOGGER.error("function=deleteVim; msg=deleteVim error, because id is empty.");
+ throw new ServiceException(
+ ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.vim.del.id.check"));
+ }
+ return vimDao.deleteVim(id);
+ }
+
+ @Override
+ public int addVim(String id) throws ServiceException {
+ if(!StringUtil.isValidString(id)) {
+ LOGGER.error("function=addVim; msg=add error, because id is null.");
+ throw new ServiceException(
+ ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.vim.add.id.null"));
+ }
+ if(!checkId(id)) {
+ LOGGER.error("function=addVim; msg=add error, because id is already exist.");
+ throw new ServiceException(
+ ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.vim.add.id.check"));
+ }
+
+ VimEntity vimEntity = new VimEntity();
+ vimEntity.setId(id);
+ return vimDao.addVim(vimEntity);
+ }
+
+ private boolean checkId(String id) {
+ VimEntity vim = vimDao.getVim(id);
+ if(null == vim) {
+ return true;
+ }
+ return false;
+ }
+
+ public void setVimDao(VimDao vimDao) {
+ this.vimDao = vimDao;
+ }
+
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/inf/HostBusiness.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/inf/HostBusiness.java
new file mode 100644
index 0000000..803c96e
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/inf/HostBusiness.java
@@ -0,0 +1,131 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.business.inf;
+
+import java.util.List;
+import java.util.Map;
+
+import org.openo.baseservice.remoteservice.exception.ServiceException;
+import org.openo.nfvo.resmanagement.service.entity.HostEntity;
+
+/**
+ * Host Buisiness Class.<br/>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Aug 31, 2016
+ */
+public interface HostBusiness {
+
+ /**
+ *
+ * Get host.<br>
+ *
+ * @param id
+ * @return
+ * @since NFVO 0.5
+ */
+ HostEntity getHost(String id);
+
+ /**
+ *
+ * Get details of hosts.<br>
+ *
+ * @param condition
+ * @return
+ * @since NFVO 0.5
+ */
+ List<HostEntity> getHosts(Map<String, Object> condition);
+
+ /**
+ *
+ * Delete host.<br>
+ *
+ * @param id
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ int deleteHost(String id) throws ServiceException;
+
+ /**
+ *
+ * Delete host by VIM Id.<br>
+ *
+ * @param vimId
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ int deleteHostByVimId(String vimId) throws ServiceException;
+
+ /**
+ *
+ * Add host.<br>
+ *
+ * @param hostEntity
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ int addHost(HostEntity hostEntity) throws ServiceException;
+
+ /**
+ *
+ * Add selective host.<br>
+ *
+ * @param hostEntity
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ int addHostSelective(HostEntity hostEntity) throws ServiceException;
+
+ /**
+ *
+ * Update selective host.<br>
+ *
+ * @param hostEntity
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ int updateHostSelective(HostEntity hostEntity) throws ServiceException;
+
+ /**
+ *
+ * Update host.<br>
+ *
+ * @param hostEntity
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ int updateHost(HostEntity hostEntity) throws ServiceException;
+
+ /**
+ *
+ * Update host by VIM Id.<br>
+ *
+ * @param hostEntity
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ int updateHostByVimId(HostEntity hostEntity) throws ServiceException;
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/inf/LimitsBusiness.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/inf/LimitsBusiness.java
new file mode 100644
index 0000000..b78b6a8
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/inf/LimitsBusiness.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2016-2017 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.business.inf;
+
+import org.openo.baseservice.remoteservice.exception.ServiceException;
+
+import net.sf.json.JSONObject;
+
+/**
+ * <br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Sep 10, 2016
+ */
+public interface LimitsBusiness {
+
+ /**
+ * <br>
+ *
+ * @param paramJson
+ * @return
+ * @since NFVO 0.5
+ */
+ JSONObject getLimits(String vimId) throws ServiceException;
+
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/inf/LocationBusiness.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/inf/LocationBusiness.java
new file mode 100644
index 0000000..fd5cef2
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/inf/LocationBusiness.java
@@ -0,0 +1,134 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.business.inf;
+
+import java.util.List;
+import java.util.Map;
+
+import org.openo.baseservice.remoteservice.exception.ServiceException;
+import org.openo.nfvo.resmanagement.service.entity.LocationEntity;
+
+/**
+ *
+ * Location Business Class.<br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Sep 10, 2016
+ */
+public interface LocationBusiness {
+
+ /**
+ *
+ * Get Location.<br>
+ *
+ * @param location
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ LocationEntity getLocation(String location) throws ServiceException;
+
+ /**
+ *
+ * Get Locations.<br>
+ *
+ * @param condition
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ List<LocationEntity> getLocations(Map<String, Object> condition) throws ServiceException;
+
+ /**
+ *
+ * Delete Location.<br>
+ *
+ * @param location
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ int deleteLocation(String location) throws ServiceException;
+
+ /**
+ *
+ * Add Location.<br>
+ *
+ * @param locationEntity
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ int addLocation(LocationEntity locationEntity) throws ServiceException;
+
+ /**
+ *
+ * Add Selective Location.<br>
+ *
+ * @param locationEntity
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ int addLocationSelective(LocationEntity locationEntity) throws ServiceException;
+
+ /**
+ *
+ * Update Selective Location.<br>
+ *
+ * @param locationEntity
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ int updateLocationSelective(LocationEntity locationEntity) throws ServiceException;
+
+ /**
+ *
+ * Update Location.<br>
+ *
+ * @param locationEntity
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ int updateLocation(LocationEntity locationEntity) throws ServiceException;
+
+ /**
+ *
+ * Get Country.<br>
+ *
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ List<String> getCountry() throws ServiceException;
+
+ /**
+ *
+ * Get Location By Country.<br>
+ *
+ * @param condition
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ List<String> getLocationByCountry(Map<String, Object> condition) throws ServiceException;
+
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/inf/NetworkBusiness.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/inf/NetworkBusiness.java
new file mode 100644
index 0000000..be0c9dc
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/inf/NetworkBusiness.java
@@ -0,0 +1,133 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.business.inf;
+
+import java.util.List;
+import java.util.Map;
+
+import org.openo.baseservice.remoteservice.exception.ServiceException;
+import org.openo.nfvo.resmanagement.service.entity.NetworkEntity;
+
+/**
+ *
+ * Network Business class.<br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Sep 10, 2016
+ */
+public interface NetworkBusiness {
+
+ /**
+ *
+ * Get network details.<br>
+ *
+ * @param id
+ * @return
+ * @since NFVO 0.5
+ */
+ NetworkEntity getNetwork(String id);
+
+ /**
+ *
+ * Get details of available networks.<br>
+ *
+ * @param condition
+ * @return
+ * @since NFVO 0.5
+ */
+ List<NetworkEntity> getNetworks(Map<String, Object> condition);
+
+ /**
+ *
+ * Delete Network.<br>
+ *
+ * @param id
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ int deleteNetwork(String id) throws ServiceException;
+
+ /**
+ *
+ * Delete network by Virtual Infrastructure Manager ID.<br>
+ *
+ * @param vimId
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ int deleteNetworkByVimId(String vimId) throws ServiceException;
+
+ /**
+ *
+ * Add Network.<br>
+ *
+ * @param networkEntity
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ int addNetwork(NetworkEntity networkEntity) throws ServiceException;
+
+ /**
+ *
+ * Add Selective Network.<br>
+ *
+ * @param networkEntity
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ int addNetworkSelective(NetworkEntity networkEntity) throws ServiceException;
+
+ /**
+ *
+ * Update Selective Network.<br>
+ *
+ * @param networkEntity
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ int updateNetworkSelective(NetworkEntity networkEntity) throws ServiceException;
+
+ /**
+ *
+ * Update Network.<br>
+ *
+ * @param networkEntity
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ int updateNetwork(NetworkEntity networkEntity) throws ServiceException;
+
+ /**
+ *
+ * Update network by Virtual Infrastructure Manager ID.<br>
+ *
+ * @param networkEntity
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ int updateNetworkByVimId(NetworkEntity networkEntity) throws ServiceException;
+
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/inf/PortBusiness.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/inf/PortBusiness.java
new file mode 100644
index 0000000..b81a3e1
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/inf/PortBusiness.java
@@ -0,0 +1,131 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.business.inf;
+
+import java.util.List;
+import java.util.Map;
+
+import org.openo.baseservice.remoteservice.exception.ServiceException;
+import org.openo.nfvo.resmanagement.service.entity.PortEntity;
+
+/**
+ * Port Buisiness Class.<br/>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Aug 31, 2016
+ */
+public interface PortBusiness {
+
+ /**
+ *
+ * Get Port.<br>
+ *
+ * @param id
+ * @return
+ * @since NFVO 0.5
+ */
+ PortEntity getPort(String id);
+
+ /**
+ *
+ * Get details of ports.<br>
+ *
+ * @param condition
+ * @return
+ * @since NFVO 0.5
+ */
+ List<PortEntity> getPorts(Map<String, Object> condition);
+
+ /**
+ *
+ * Delete Port.<br>
+ *
+ * @param id
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ int deletePort(String id) throws ServiceException;
+
+ /**
+ *
+ * Delete port by VIM ID.<br>
+ *
+ * @param vimId
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ int deletePortByVimId(String vimId) throws ServiceException;
+
+ /**
+ *
+ * Add port.<br>
+ *
+ * @param portEntity
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ int addPort(PortEntity portEntity) throws ServiceException;
+
+ /**
+ *
+ * Add selective port.<br>
+ *
+ * @param portEntity
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ int addPortSelective(PortEntity portEntity) throws ServiceException;
+
+ /**
+ *
+ * Update selective port.<br>
+ *
+ * @param portEntity
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ int updatePortSelective(PortEntity portEntity) throws ServiceException;
+
+ /**
+ *
+ * Update port.<br>
+ *
+ * @param portEntity
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ int updatePort(PortEntity portEntity) throws ServiceException;
+
+ /**
+ *
+ * Update port by VIM Id.<br>
+ *
+ * @param portEntity
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ int updatePortByVimId(PortEntity portEntity) throws ServiceException;
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/inf/SitesBusiness.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/inf/SitesBusiness.java
new file mode 100644
index 0000000..8d11a39
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/inf/SitesBusiness.java
@@ -0,0 +1,124 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.business.inf;
+
+import java.util.List;
+import java.util.Map;
+
+import org.openo.baseservice.remoteservice.exception.ServiceException;
+import org.openo.nfvo.resmanagement.service.entity.SitesEntity;
+
+/**
+ * DC info interface.<br/>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Aug 24, 2016
+ */
+public interface SitesBusiness {
+
+ /**
+ * It is used to get Site info.<br/>
+ *
+ * @param id
+ * @return The get result
+ * @throws ServiceException When get failed.
+ * @since NFVO 0.5
+ */
+ SitesEntity getSite(String id) throws ServiceException;
+
+ /**
+ * It is used to get Sites info.<br/>
+ *
+ * @param condition
+ * @return The get result
+ * @since NFVO 0.5
+ */
+ List<SitesEntity> getSites(Map<String, Object> condition);
+
+ /**
+ * It is used to delete Site info.<br/>
+ *
+ * @param id
+ * @return The delete result
+ * @throws ServiceException When delete failed.
+ * @since NFVO 0.5
+ */
+ int deleteSite(String id) throws ServiceException;
+
+ /**
+ * It is used to add Site info.<br/>
+ *
+ * @param sitesEntity
+ * @return The add result
+ * @throws ServiceException When add failed.
+ * @since NFVO 0.5
+ */
+ int addSite(SitesEntity sitesEntity) throws ServiceException;
+
+ /**
+ * It is used to add Site info.<br/>
+ *
+ * @param sitesEntity
+ * @return The add result
+ * @throws ServiceException When add failed.
+ * @since NFVO 0.5
+ */
+ int addSiteSelective(SitesEntity sitesEntity) throws ServiceException;
+
+ /**
+ * It is used to update Site info.<br/>
+ *
+ * @param sitesEntity
+ * @return The update result
+ * @throws ServiceException When update failed.
+ * @since NFVO 0.5
+ */
+ int updateSiteSelective(SitesEntity sitesEntity) throws ServiceException;
+
+ /**
+ * It is used to create update Site info.<br/>
+ *
+ * @param sitesEntity
+ * @return The update result
+ * @throws ServiceException When update failed.
+ * @since NFVO 0.5
+ */
+ int updateSite(SitesEntity sitesEntity) throws ServiceException;
+
+ /**
+ * It is used to update Site info.<br/>
+ *
+ * @param sitesEntity
+ * @return The update result
+ * @throws ServiceException When update failed.
+ * @since NFVO 0.5
+ */
+ int updateSiteByVimId(SitesEntity sitesEntity) throws ServiceException;
+
+ /**
+ * It is used to update Site info.<br/>
+ *
+ * @param sitesEntity
+ * @return The update result
+ * @throws ServiceException When update failed.
+ * @since NFVO 0.5
+ */
+ int updateSiteResource(SitesEntity sitesEntity) throws ServiceException;
+
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/inf/VimBusiness.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/inf/VimBusiness.java
new file mode 100644
index 0000000..8806e7a
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/business/inf/VimBusiness.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.business.inf;
+
+import java.util.List;
+
+import org.openo.baseservice.remoteservice.exception.ServiceException;
+import org.openo.nfvo.resmanagement.service.entity.VimEntity;
+
+/**
+ * Vim info interface.<br/>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Aug 24, 2016
+ */
+public interface VimBusiness {
+
+ /**
+ * It is used to get Vim info.<br/>
+ *
+ * @param id
+ * @return The get result
+ * @since NFVO 0.5
+ */
+ VimEntity getVim(String id);
+
+ /**
+ * It is used to get Vim info.<br/>
+ *
+ * @param id
+ * @return The get result
+ * @since NFVO 0.5
+ */
+ List<VimEntity> getVims();
+
+ /**
+ * It is used to delete Vim info.<br/>
+ *
+ * @param id
+ * @return the delete result
+ * @throws ServiceException When delete failed.
+ * @since NFVO 0.5
+ */
+ int deleteVim(String id) throws ServiceException;
+
+ /**
+ * It is used to add Vim info.<br/>
+ *
+ * @param id
+ * @return the add result
+ * @throws ServiceException When add failed.
+ * @since NFVO 0.5
+ */
+ int addVim(String id) throws ServiceException;
+
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/AbstractDao.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/AbstractDao.java
new file mode 100644
index 0000000..e3a76ca
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/AbstractDao.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.dao.impl;
+
+import org.apache.ibatis.session.SqlSession;
+
+/**
+ * <br/>
+ * <p>
+ * Database abstract class to get the MapperManager
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 2016-3-17
+ */
+public class AbstractDao {
+
+ private SqlSession session;
+
+ protected AbstractDao() {
+ //added this private costructor to fix static errors.
+ }
+
+ public SqlSession getSession() {
+ return session;
+ }
+
+ public void setSession(SqlSession session) {
+ this.session = session;
+ }
+
+ /**
+ * get Mybatis Mapper<br/>
+ *
+ * @param type
+ * The type of Class
+ * @return Mapper
+ * @since NFVO 0.5
+ */
+ public <T> T getMapperManager(Class<T> type) {
+ return (T)getSession().getMapper(type);
+ }
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/HostDaoImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/HostDaoImpl.java
new file mode 100644
index 0000000..1c5c03c
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/HostDaoImpl.java
@@ -0,0 +1,83 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.dao.impl;
+
+import java.util.List;
+import java.util.Map;
+
+import org.openo.nfvo.resmanagement.service.dao.impl.AbstractDao;
+import org.openo.nfvo.resmanagement.service.dao.inf.HostDao;
+import org.openo.nfvo.resmanagement.service.entity.HostEntity;
+import org.openo.nfvo.resmanagement.service.mapper.HostMapper;
+
+/**
+ *
+ * Host DAO implementation class.<br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Sep 10, 2016
+ */
+public class HostDaoImpl extends AbstractDao implements HostDao {
+
+ @Override
+ public HostEntity getHost(String id) {
+ return getMapperManager(HostMapper.class).getHost(id);
+ }
+
+ @Override
+ public List<HostEntity> getHosts(Map<String, Object> condition) {
+ return getMapperManager(HostMapper.class).getHosts(condition);
+ }
+
+ @Override
+ public int deleteHost(String id) {
+ return getMapperManager(HostMapper.class).deleteHost(id);
+ }
+
+ @Override
+ public int deleteHostByVimId(String vimId) {
+ return getMapperManager(HostMapper.class).deleteHostByVimId(vimId);
+ }
+
+ @Override
+ public int addHost(HostEntity hostEntity) {
+ return getMapperManager(HostMapper.class).addHost(hostEntity);
+ }
+
+ @Override
+ public int addHostSelective(HostEntity hostEntity) {
+ return getMapperManager(HostMapper.class).addHostSelective(hostEntity);
+ }
+
+ @Override
+ public int updateHostSelective(HostEntity hostEntity) {
+ return getMapperManager(HostMapper.class).updateHostSelective(hostEntity);
+ }
+
+ @Override
+ public int updateHost(HostEntity hostEntity) {
+ return getMapperManager(HostMapper.class).updateHost(hostEntity);
+ }
+
+ @Override
+ public int updateHostByVimId(HostEntity hostEntity) {
+ return getMapperManager(HostMapper.class).updateHostByVimId(hostEntity);
+ }
+
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/LocationDaoImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/LocationDaoImpl.java
new file mode 100644
index 0000000..949f19f
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/LocationDaoImpl.java
@@ -0,0 +1,83 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.dao.impl;
+
+import java.util.List;
+import java.util.Map;
+
+import org.openo.nfvo.resmanagement.service.dao.impl.AbstractDao;
+import org.openo.nfvo.resmanagement.service.dao.inf.LocationDao;
+import org.openo.nfvo.resmanagement.service.entity.LocationEntity;
+import org.openo.nfvo.resmanagement.service.mapper.LocationMapper;
+
+/**
+ *
+ * Location DAO implemetation class.<br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Sep 10, 2016
+ */
+public class LocationDaoImpl extends AbstractDao implements LocationDao {
+
+ @Override
+ public LocationEntity getLocation(String id) {
+ return getMapperManager(LocationMapper.class).getLocation(id);
+ }
+
+ @Override
+ public List<String> getCountry() {
+ return getMapperManager(LocationMapper.class).getCountry();
+ }
+
+ @Override
+ public List<String> getLocationByCountry(Map<String, Object> condition) {
+ return getMapperManager(LocationMapper.class).getLocationByCountry(condition);
+ }
+
+ @Override
+ public List<LocationEntity> getLocations(Map<String, Object> condition) {
+ return getMapperManager(LocationMapper.class).getLocations(condition);
+ }
+
+ @Override
+ public int deleteLocation(String id) {
+ return getMapperManager(LocationMapper.class).deleteLocation(id);
+ }
+
+ @Override
+ public int addLocation(LocationEntity locationEntity) {
+ return getMapperManager(LocationMapper.class).addLocation(locationEntity);
+ }
+
+ @Override
+ public int addLocationSelective(LocationEntity locationEntity) {
+ return getMapperManager(LocationMapper.class).addLocationSelective(locationEntity);
+ }
+
+ @Override
+ public int updateLocationSelective(LocationEntity locationEntity) {
+ return getMapperManager(LocationMapper.class).updateLocationSelective(locationEntity);
+ }
+
+ @Override
+ public int updateLocation(LocationEntity locationEntity) {
+ return getMapperManager(LocationMapper.class).updateLocation(locationEntity);
+ }
+
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/NetworkDaoImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/NetworkDaoImpl.java
new file mode 100644
index 0000000..12769a2
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/NetworkDaoImpl.java
@@ -0,0 +1,83 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.dao.impl;
+
+import java.util.List;
+import java.util.Map;
+
+import org.openo.nfvo.resmanagement.service.dao.impl.AbstractDao;
+import org.openo.nfvo.resmanagement.service.dao.inf.NetworkDao;
+import org.openo.nfvo.resmanagement.service.entity.NetworkEntity;
+import org.openo.nfvo.resmanagement.service.mapper.NetworkMapper;
+
+/**
+ *
+ * Network DAO implementation class.<br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Sep 10, 2016
+ */
+public class NetworkDaoImpl extends AbstractDao implements NetworkDao {
+
+ @Override
+ public NetworkEntity getNetwork(String id) {
+ return getMapperManager(NetworkMapper.class).getNetwork(id);
+ }
+
+ @Override
+ public List<NetworkEntity> getNetworks(Map<String, Object> condition) {
+ return getMapperManager(NetworkMapper.class).getNetworks(condition);
+ }
+
+ @Override
+ public int deleteNetwork(String id) {
+ return getMapperManager(NetworkMapper.class).deleteNetwork(id);
+ }
+
+ @Override
+ public int deleteNetworkByVimId(String vimId) {
+ return getMapperManager(NetworkMapper.class).deleteNetworkByVimId(vimId);
+ }
+
+ @Override
+ public int addNetwork(NetworkEntity networkEntity) {
+ return getMapperManager(NetworkMapper.class).addNetwork(networkEntity);
+ }
+
+ @Override
+ public int addNetworkSelective(NetworkEntity networkEntity) {
+ return getMapperManager(NetworkMapper.class).addNetworkSelective(networkEntity);
+ }
+
+ @Override
+ public int updateNetworkSelective(NetworkEntity networkEntity) {
+ return getMapperManager(NetworkMapper.class).updateNetworkSelective(networkEntity);
+ }
+
+ @Override
+ public int updateNetwork(NetworkEntity networkEntity) {
+ return getMapperManager(NetworkMapper.class).updateNetwork(networkEntity);
+ }
+
+ @Override
+ public int updateNetworkByVimId(NetworkEntity networkEntity) {
+ return getMapperManager(NetworkMapper.class).updateNetworkByVimId(networkEntity);
+ }
+
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/PortDaoImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/PortDaoImpl.java
new file mode 100644
index 0000000..e113c7a
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/PortDaoImpl.java
@@ -0,0 +1,83 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.dao.impl;
+
+import java.util.List;
+import java.util.Map;
+
+import org.openo.nfvo.resmanagement.service.dao.impl.AbstractDao;
+import org.openo.nfvo.resmanagement.service.dao.inf.PortDao;
+import org.openo.nfvo.resmanagement.service.entity.PortEntity;
+import org.openo.nfvo.resmanagement.service.mapper.PortMapper;
+
+/**
+ *
+ * Port DAO implementation class.<br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Sep 10, 2016
+ */
+public class PortDaoImpl extends AbstractDao implements PortDao {
+
+ @Override
+ public PortEntity getPort(String id) {
+ return getMapperManager(PortMapper.class).getPort(id);
+ }
+
+ @Override
+ public List<PortEntity> getPorts(Map<String, Object> condition) {
+ return getMapperManager(PortMapper.class).getPorts(condition);
+ }
+
+ @Override
+ public int deletePort(String id) {
+ return getMapperManager(PortMapper.class).deletePort(id);
+ }
+
+ @Override
+ public int deletePortByVimId(String vimId) {
+ return getMapperManager(PortMapper.class).deletePortByVimId(vimId);
+ }
+
+ @Override
+ public int addPort(PortEntity portEntity) {
+ return getMapperManager(PortMapper.class).addPort(portEntity);
+ }
+
+ @Override
+ public int addPortSelective(PortEntity portEntity) {
+ return getMapperManager(PortMapper.class).addPortSelective(portEntity);
+ }
+
+ @Override
+ public int updatePortSelective(PortEntity portEntity) {
+ return getMapperManager(PortMapper.class).updatePortSelective(portEntity);
+ }
+
+ @Override
+ public int updatePort(PortEntity portEntity) {
+ return getMapperManager(PortMapper.class).updatePort(portEntity);
+ }
+
+ @Override
+ public int updatePortByVimId(PortEntity portEntity) {
+ return getMapperManager(PortMapper.class).updatePortByVimId(portEntity);
+ }
+
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/SitesDaoImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/SitesDaoImpl.java
new file mode 100644
index 0000000..2d29d7b
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/SitesDaoImpl.java
@@ -0,0 +1,77 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.dao.impl;
+
+import java.util.List;
+import java.util.Map;
+
+import org.openo.nfvo.resmanagement.service.dao.impl.AbstractDao;
+import org.openo.nfvo.resmanagement.service.dao.inf.SitesDao;
+import org.openo.nfvo.resmanagement.service.entity.SitesEntity;
+import org.openo.nfvo.resmanagement.service.mapper.SitesMapper;
+
+/**
+ * DC interface.<br/>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Aug 25, 2016
+ */
+public class SitesDaoImpl extends AbstractDao implements SitesDao {
+
+ @Override
+ public SitesEntity getSite(String id) {
+ return getMapperManager(SitesMapper.class).getSite(id);
+ }
+
+ @Override
+ public List<SitesEntity> getSites(Map<String, Object> condition) {
+ return getMapperManager(SitesMapper.class).getSites(condition);
+ }
+
+ @Override
+ public int deleteSite(String id) {
+ return getMapperManager(SitesMapper.class).deleteSite(id);
+ }
+
+ @Override
+ public int addSite(SitesEntity sitesEntity) {
+ return getMapperManager(SitesMapper.class).addSite(sitesEntity);
+ }
+
+ @Override
+ public int addSiteSelective(SitesEntity sitesEntity) {
+ return getMapperManager(SitesMapper.class).addSiteSelective(sitesEntity);
+ }
+
+ @Override
+ public int updateSiteSelective(SitesEntity sitesEntity) {
+ return getMapperManager(SitesMapper.class).updateSiteSelective(sitesEntity);
+ }
+
+ @Override
+ public int updateSite(SitesEntity sitesEntity) {
+ return getMapperManager(SitesMapper.class).updateSite(sitesEntity);
+ }
+
+ @Override
+ public int updateSiteByVimId(SitesEntity sitesEntity) {
+ return getMapperManager(SitesMapper.class).updateSiteByVimId(sitesEntity);
+ }
+
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/VimDaoImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/VimDaoImpl.java
new file mode 100644
index 0000000..e73b251
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/VimDaoImpl.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.dao.impl;
+
+import java.util.List;
+
+import org.openo.nfvo.resmanagement.service.dao.impl.AbstractDao;
+import org.openo.nfvo.resmanagement.service.dao.inf.VimDao;
+import org.openo.nfvo.resmanagement.service.entity.VimEntity;
+import org.openo.nfvo.resmanagement.service.mapper.VimMapper;
+
+/**
+ * Vim interface.<br/>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Aug 25, 2016
+ */
+public class VimDaoImpl extends AbstractDao implements VimDao {
+
+ @Override
+ public VimEntity getVim(String id) {
+ return getMapperManager(VimMapper.class).getVim(id);
+ }
+
+ @Override
+ public List<VimEntity> getVims() {
+ return getMapperManager(VimMapper.class).getVims();
+ }
+
+ @Override
+ public int deleteVim(String id) {
+ return getMapperManager(VimMapper.class).deleteVim(id);
+ }
+
+ @Override
+ public int addVim(VimEntity vimEntity) {
+ return getMapperManager(VimMapper.class).addVim(vimEntity);
+ }
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/VirtualLinkDaoImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/VirtualLinkDaoImpl.java
new file mode 100644
index 0000000..96ed906
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/VirtualLinkDaoImpl.java
@@ -0,0 +1,84 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.dao.impl;
+
+import java.util.List;
+import java.util.Map;
+
+import org.openo.nfvo.resmanagement.service.dao.inf.VirtualLinkDao;
+import org.openo.nfvo.resmanagement.service.entity.VirtualLinkEntity;
+import org.openo.nfvo.resmanagement.service.mapper.VirtualLinkMapper;
+
+/**
+ * <br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Oct 28, 2016
+ */
+public class VirtualLinkDaoImpl extends AbstractDao implements VirtualLinkDao {
+
+ /**
+ * <br>
+ *
+ * @param id
+ * @return
+ * @since NFVO 0.5
+ */
+ @Override
+ public VirtualLinkEntity getVl(String id) {
+ return getMapperManager(VirtualLinkMapper.class).selectByPrimaryKey(id);
+ }
+
+ /**
+ * <br>
+ *
+ * @param condition
+ * @return
+ * @since NFVO 0.5
+ */
+ @Override
+ public List<VirtualLinkEntity> getVls(Map<String, Object> condition) {
+ return getMapperManager(VirtualLinkMapper.class).getVls(condition);
+ }
+
+ /**
+ * <br>
+ *
+ * @param virtualLinkEntity
+ * @return
+ * @since NFVO 0.5
+ */
+ @Override
+ public int addVl(VirtualLinkEntity virtualLinkEntity) {
+ return getMapperManager(VirtualLinkMapper.class).insert(virtualLinkEntity);
+ }
+
+ /**
+ * <br>
+ *
+ * @param id
+ * @return
+ * @since NFVO 0.5
+ */
+ @Override
+ public int deleteVlById(String id) {
+ return getMapperManager(VirtualLinkMapper.class).deleteByPrimaryKey(id);
+ }
+
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/VmDaoImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/VmDaoImpl.java
new file mode 100644
index 0000000..ee3806c
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/VmDaoImpl.java
@@ -0,0 +1,108 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.dao.impl;
+
+import java.util.List;
+import java.util.Map;
+
+import org.openo.nfvo.resmanagement.service.dao.inf.VmDao;
+import org.openo.nfvo.resmanagement.service.entity.VmEntity;
+import org.openo.nfvo.resmanagement.service.mapper.VmMapper;
+
+/**
+ * <br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Oct 28, 2016
+ */
+public class VmDaoImpl extends AbstractDao implements VmDao {
+
+ /**
+ * <br>
+ *
+ * @param id
+ * @return
+ * @since NFVO 0.5
+ */
+ @Override
+ public VmEntity getVm(String id) {
+ return getMapperManager(VmMapper.class).selectByPrimaryKey(id);
+ }
+
+ /**
+ * <br>
+ *
+ * @param condition
+ * @return
+ * @since NFVO 0.5
+ */
+ @Override
+ public List<VmEntity> getVms(Map<String, Object> condition) {
+ return getMapperManager(VmMapper.class).getVms(condition);
+ }
+
+ /**
+ * <br>
+ *
+ * @param vmEntity
+ * @return
+ * @since NFVO 0.5
+ */
+ @Override
+ public int addVm(VmEntity vmEntity) {
+ return getMapperManager(VmMapper.class).insert(vmEntity);
+ }
+
+ /**
+ * <br>
+ *
+ * @param id
+ * @return
+ * @since NFVO 0.5
+ */
+ @Override
+ public int deleteVmById(String id) {
+ return getMapperManager(VmMapper.class).deleteByPrimaryKey(id);
+ }
+
+ /**
+ * <br>
+ *
+ * @param vmEntity
+ * @return
+ * @since NFVO 0.5
+ */
+ @Override
+ public int updateVm(VmEntity vmEntity) {
+ return getMapperManager(VmMapper.class).updateByPrimaryKeySelective(vmEntity);
+ }
+
+ /**
+ * <br>
+ *
+ * @param vnfInstanceId
+ * @return
+ * @since NFVO 0.5
+ */
+ @Override
+ public int deleteVmByVnfId(String vnfInstanceId) {
+ return getMapperManager(VmMapper.class).deleteByVnfId(vnfInstanceId);
+ }
+
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/VnfDaoImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/VnfDaoImpl.java
new file mode 100644
index 0000000..42bb5b5
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/VnfDaoImpl.java
@@ -0,0 +1,84 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.dao.impl;
+
+import java.util.List;
+import java.util.Map;
+
+import org.openo.nfvo.resmanagement.service.dao.inf.VnfDao;
+import org.openo.nfvo.resmanagement.service.entity.VnfEntity;
+import org.openo.nfvo.resmanagement.service.mapper.VnfMapper;
+
+/**
+ * <br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Oct 28, 2016
+ */
+public class VnfDaoImpl extends AbstractDao implements VnfDao {
+
+ /**
+ * <br>
+ *
+ * @param id
+ * @return
+ * @since NFVO 0.5
+ */
+ @Override
+ public VnfEntity getVnf(String id) {
+ return getMapperManager(VnfMapper.class).selectByPrimaryKey(id);
+ }
+
+ /**
+ * <br>
+ *
+ * @param condition
+ * @return
+ * @since NFVO 0.5
+ */
+ @Override
+ public List<VnfEntity> getVnfs(Map<String, Object> condition) {
+ return getMapperManager(VnfMapper.class).getVnfs(condition);
+ }
+
+ /**
+ * <br>
+ *
+ * @param vnfEntity
+ * @return
+ * @since NFVO 0.5
+ */
+ @Override
+ public int addVnf(VnfEntity vnfEntity) {
+ return getMapperManager(VnfMapper.class).insert(vnfEntity);
+ }
+
+ /**
+ * <br>
+ *
+ * @param id
+ * @return
+ * @since NFVO 0.5
+ */
+ @Override
+ public int deleteVnfById(String id) {
+ return getMapperManager(VnfMapper.class).deleteByPrimaryKey(id);
+ }
+
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/VnfInfoDaoImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/VnfInfoDaoImpl.java
new file mode 100644
index 0000000..6e8d32b
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/VnfInfoDaoImpl.java
@@ -0,0 +1,96 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.dao.impl;
+
+import java.util.List;
+import java.util.Map;
+
+import org.openo.nfvo.resmanagement.service.dao.inf.VnfInfoDao;
+import org.openo.nfvo.resmanagement.service.entity.VnfInfoEntity;
+import org.openo.nfvo.resmanagement.service.mapper.VnfInfoMapper;
+
+/**
+ * <br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Oct 28, 2016
+ */
+public class VnfInfoDaoImpl extends AbstractDao implements VnfInfoDao {
+
+ /**
+ * <br>
+ *
+ * @param id
+ * @return
+ * @since NFVO 0.5
+ */
+ @Override
+ public VnfInfoEntity getVnfInfo(String id) {
+ return getMapperManager(VnfInfoMapper.class).selectByPrimaryKey(id);
+ }
+
+ /**
+ * <br>
+ *
+ * @param condition
+ * @return
+ * @since NFVO 0.5
+ */
+ @Override
+ public List<VnfInfoEntity> getVnfInfos(Map<String, Object> condition) {
+ return getMapperManager(VnfInfoMapper.class).getVnfInfos(condition);
+ }
+
+ /**
+ * <br>
+ *
+ * @param vmEntity
+ * @return
+ * @since NFVO 0.5
+ */
+ @Override
+ public int addVnfInfo(VnfInfoEntity vnfInfoEntity) {
+ return getMapperManager(VnfInfoMapper.class).insert(vnfInfoEntity);
+ }
+
+ /**
+ * <br>
+ *
+ * @param id
+ * @return
+ * @since NFVO 0.5
+ */
+ @Override
+ public int deleteVnfInfoById(String id) {
+ return getMapperManager(VnfInfoMapper.class).deleteByPrimaryKey(id);
+ }
+
+ /**
+ * <br>
+ *
+ * @param vnfInfoEntity
+ * @return
+ * @since NFVO 0.5
+ */
+ @Override
+ public int updateVnfInfo(VnfInfoEntity vnfInfoEntity) {
+ return getMapperManager(VnfInfoMapper.class).updateByPrimaryKeySelective(vnfInfoEntity);
+ }
+
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/VnfStatusDaoImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/VnfStatusDaoImpl.java
new file mode 100644
index 0000000..ed7db95
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/impl/VnfStatusDaoImpl.java
@@ -0,0 +1,96 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.dao.impl;
+
+import java.util.List;
+import java.util.Map;
+
+import org.openo.nfvo.resmanagement.service.dao.inf.VnfStatusDao;
+import org.openo.nfvo.resmanagement.service.entity.VnfStatusEntity;
+import org.openo.nfvo.resmanagement.service.mapper.VnfStatusMapper;
+
+/**
+ * <br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Oct 29, 2016
+ */
+public class VnfStatusDaoImpl extends AbstractDao implements VnfStatusDao {
+
+ /**
+ * <br>
+ *
+ * @param id
+ * @return
+ * @since NFVO 0.5
+ */
+ @Override
+ public VnfStatusEntity getVnfStatus(String id) {
+ return getMapperManager(VnfStatusMapper.class).selectByPrimaryKey(id);
+ }
+
+ /**
+ * <br>
+ *
+ * @param condition
+ * @return
+ * @since NFVO 0.5
+ */
+ @Override
+ public List<VnfStatusEntity> getVnfStatuss(Map<String, Object> condition) {
+ return getMapperManager(VnfStatusMapper.class).getVnfStatuss(condition);
+ }
+
+ /**
+ * <br>
+ *
+ * @param vnfStatusEntity
+ * @return
+ * @since NFVO 0.5
+ */
+ @Override
+ public int addVnfStatus(VnfStatusEntity vnfStatusEntity) {
+ return getMapperManager(VnfStatusMapper.class).insert(vnfStatusEntity);
+ }
+
+ /**
+ * <br>
+ *
+ * @param id
+ * @return
+ * @since NFVO 0.5
+ */
+ @Override
+ public int deleteVnfStatusById(String id) {
+ return getMapperManager(VnfStatusMapper.class).deleteByPrimaryKey(id);
+ }
+
+ /**
+ * <br>
+ *
+ * @param vnfStatusEntity
+ * @return
+ * @since NFVO 0.5
+ */
+ @Override
+ public int updateVnfStatus(VnfStatusEntity vnfStatusEntity) {
+ return getMapperManager(VnfStatusMapper.class).updateByPrimaryKeySelective(vnfStatusEntity);
+ }
+
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/HostDao.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/HostDao.java
new file mode 100644
index 0000000..a48c6aa
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/HostDao.java
@@ -0,0 +1,114 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.dao.inf;
+
+import java.util.List;
+import java.util.Map;
+
+import org.openo.nfvo.resmanagement.service.entity.HostEntity;
+
+/**
+ * Host info interface.<br/>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Aug 24, 2016
+ */
+public interface HostDao {
+
+ /**
+ * It is used to get Host info.<br/>
+ *
+ * @param id
+ * @return The get result
+ * @since NFVO 0.5
+ */
+ HostEntity getHost(String id);
+
+ /**
+ * It is used to get Hosts info.<br/>
+ *
+ * @param condition
+ * @return The get result
+ * @since NFVO 0.5
+ */
+ List<HostEntity> getHosts(Map<String, Object> condition);
+
+ /**
+ * It is used to delete Hosts info.<br/>
+ *
+ * @param id
+ * @return The delete result
+ * @since NFVO 0.5
+ */
+ int deleteHost(String id);
+
+ /**
+ * It is used to delete Hosts info.<br/>
+ *
+ * @param vimId
+ * @return The delete result
+ * @since NFVO 0.5
+ */
+ int deleteHostByVimId(String vimId);
+
+ /**
+ * It is used to add Hosts info. <br/>
+ *
+ * @param hostEntity
+ * @return The add result
+ * @since NFVO 0.5
+ */
+ int addHost(HostEntity hostEntity);
+
+ /**
+ * It is used to add Hosts info. <br/>
+ *
+ * @param hostEntity
+ * @return The add result
+ * @since NFVO 0.5
+ */
+ int addHostSelective(HostEntity hostEntity);
+
+ /**
+ * It is used to update Hosts info. <br/>
+ *
+ * @param hostEntity
+ * @return The update result
+ * @since NFVO 0.5
+ */
+ int updateHostSelective(HostEntity hostEntity);
+
+ /**
+ * It is used to update Hosts info. <br/>
+ *
+ * @param hostEntity
+ * @return The update result
+ * @since NFVO 0.5
+ */
+ int updateHost(HostEntity hostEntity);
+
+ /**
+ * It is used to update Hosts info. <br/>
+ *
+ * @param hostEntity
+ * @return The update result
+ * @since NFVO 0.5
+ */
+ int updateHostByVimId(HostEntity hostEntity);
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/LocationDao.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/LocationDao.java
new file mode 100644
index 0000000..dcf2c9f
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/LocationDao.java
@@ -0,0 +1,123 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.dao.inf;
+
+import java.util.List;
+import java.util.Map;
+
+import org.openo.nfvo.resmanagement.service.entity.LocationEntity;
+
+/**
+ *
+ * Location DAO Class.<br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Sep 10, 2016
+ */
+public interface LocationDao {
+
+ /**
+ *
+ * Get Location.<br>
+ *
+ * @param id
+ * @return
+ * @since NFVO 0.5
+ */
+ LocationEntity getLocation(String id);
+
+ /**
+ *
+ * Get Locations.<br>
+ *
+ * @param condition
+ * @return
+ * @since NFVO 0.5
+ */
+ List<LocationEntity> getLocations(Map<String, Object> condition);
+
+ /**
+ *
+ * Delete Location.<br>
+ *
+ * @param location
+ * @return
+ * @since NFVO 0.5
+ */
+ int deleteLocation(String location);
+
+ /**
+ *
+ * Add Location.<br>
+ *
+ * @param sodoResEntity
+ * @return
+ * @since NFVO 0.5
+ */
+ int addLocation(LocationEntity sodoResEntity);
+
+ /**
+ *
+ * Add Selective Location.<br>
+ *
+ * @param sodoResEntity
+ * @return
+ * @since NFVO 0.5
+ */
+ int addLocationSelective(LocationEntity sodoResEntity);
+
+ /**
+ *
+ * Update selective location.<br>
+ *
+ * @param sodoResEntity
+ * @return
+ * @since NFVO 0.5
+ */
+ int updateLocationSelective(LocationEntity sodoResEntity);
+
+ /**
+ *
+ * Update Location.<br>
+ *
+ * @param sodoResEntity
+ * @return
+ * @since NFVO 0.5
+ */
+ int updateLocation(LocationEntity sodoResEntity);
+
+ /**
+ *
+ * Get Country.<br>
+ *
+ * @return
+ * @since NFVO 0.5
+ */
+ List<String> getCountry();
+
+ /**
+ *
+ * Get Location by Country.<br>
+ *
+ * @param condition
+ * @return
+ * @since NFVO 0.5
+ */
+ List<String> getLocationByCountry(Map<String, Object> condition);
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/NetworkDao.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/NetworkDao.java
new file mode 100644
index 0000000..0725bd9
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/NetworkDao.java
@@ -0,0 +1,125 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.dao.inf;
+
+import java.util.List;
+import java.util.Map;
+
+import org.openo.nfvo.resmanagement.service.entity.NetworkEntity;
+
+/**
+ *
+ * Network DOA Class.<br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Sep 10, 2016
+ */
+public interface NetworkDao {
+
+ /**
+ *
+ * Get Network Details.<br>
+ *
+ * @param id
+ * @return
+ * @since NFVO 0.5
+ */
+ NetworkEntity getNetwork(String id);
+
+ /**
+ *
+ * Get details of available networks.<br>
+ *
+ * @param condition
+ * @return
+ * @since NFVO 0.5
+ */
+ List<NetworkEntity> getNetworks(Map<String, Object> condition);
+
+ /**
+ *
+ * Delete Network.<br>
+ *
+ * @param id
+ * @return
+ * @since NFVO 0.5
+ */
+ int deleteNetwork(String id);
+
+ /**
+ *
+ * Delete network by VIM ID.<br>
+ *
+ * @param vimId
+ * @return
+ * @since NFVO 0.5
+ */
+ int deleteNetworkByVimId(String vimId);
+
+ /**
+ *
+ * Add Network.<br>
+ *
+ * @param networkEntity
+ * @return
+ * @since NFVO 0.5
+ */
+ int addNetwork(NetworkEntity networkEntity);
+
+ /**
+ *
+ * Add selective network.<br>
+ *
+ * @param networkEntity
+ * @return
+ * @since NFVO 0.5
+ */
+ int addNetworkSelective(NetworkEntity networkEntity);
+
+ /**
+ *
+ * Update selective network.<br>
+ *
+ * @param networkEntity
+ * @return
+ * @since NFVO 0.5
+ */
+ int updateNetworkSelective(NetworkEntity networkEntity);
+
+ /**
+ *
+ * Update network.<br>
+ *
+ * @param networkEntity
+ * @return
+ * @since NFVO 0.5
+ */
+ int updateNetwork(NetworkEntity networkEntity);
+
+ /**
+ *
+ * Update network by VIM ID.<br>
+ *
+ * @param networkEntity
+ * @return
+ * @since NFVO 0.5
+ */
+ int updateNetworkByVimId(NetworkEntity networkEntity);
+
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/PortDao.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/PortDao.java
new file mode 100644
index 0000000..f558b5d
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/PortDao.java
@@ -0,0 +1,114 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.dao.inf;
+
+import java.util.List;
+import java.util.Map;
+
+import org.openo.nfvo.resmanagement.service.entity.PortEntity;
+
+/**
+ * Port info interface.<br/>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Aug 24, 2016
+ */
+public interface PortDao {
+
+ /**
+ * It is used to get Port info.<br/>
+ *
+ * @param id
+ * @return The get result
+ * @since NFVO 0.5
+ */
+ PortEntity getPort(String id);
+
+ /**
+ * It is used to get Ports info.<br/>
+ *
+ * @param condition
+ * @return The get result
+ * @since NFVO 0.5
+ */
+ List<PortEntity> getPorts(Map<String, Object> condition);
+
+ /**
+ * It is used to delete Ports info.<br/>
+ *
+ * @param id
+ * @return The delete result
+ * @since NFVO 0.5
+ */
+ int deletePort(String id);
+
+ /**
+ * It is used to delete Ports info.<br/>
+ *
+ * @param vimId
+ * @return The delete result
+ * @since NFVO 0.5
+ */
+ int deletePortByVimId(String vimId);
+
+ /**
+ * It is used to add Ports info. <br/>
+ *
+ * @param portEntity
+ * @return The add result
+ * @since NFVO 0.5
+ */
+ int addPort(PortEntity portEntity);
+
+ /**
+ * It is used to add Ports info. <br/>
+ *
+ * @param portEntity
+ * @return The add result
+ * @since NFVO 0.5
+ */
+ int addPortSelective(PortEntity portEntity);
+
+ /**
+ * It is used to update Ports info. <br/>
+ *
+ * @param portEntity
+ * @return The update result
+ * @since NFVO 0.5
+ */
+ int updatePortSelective(PortEntity portEntity);
+
+ /**
+ * It is used to update Ports info. <br/>
+ *
+ * @param portEntity
+ * @return The update result
+ * @since NFVO 0.5
+ */
+ int updatePort(PortEntity portEntity);
+
+ /**
+ * It is used to update Ports info. <br/>
+ *
+ * @param portEntity
+ * @return The update result
+ * @since NFVO 0.5
+ */
+ int updatePortByVimId(PortEntity portEntity);
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/SitesDao.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/SitesDao.java
new file mode 100644
index 0000000..f978c8b
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/SitesDao.java
@@ -0,0 +1,105 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.dao.inf;
+
+import java.util.List;
+import java.util.Map;
+
+import org.openo.nfvo.resmanagement.service.entity.SitesEntity;
+
+/**
+ * Sites info interface. <br/>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Aug 24, 2016
+ */
+public interface SitesDao {
+
+ /**
+ * It is used to get Sites info.<br/>
+ *
+ * @param id
+ * @return The get result
+ * @since NFVO 0.5
+ */
+ SitesEntity getSite(String id);
+
+ /**
+ * It is used to get Sites info.<br/>
+ *
+ * @param condition
+ * @return The get result
+ * @since NFVO 0.5
+ */
+ List<SitesEntity> getSites(Map<String, Object> condition);
+
+ /**
+ * It is used to get Sites info.<br/>
+ *
+ * @param id
+ * @return The get result
+ * @since NFVO 0.5
+ */
+ int deleteSite(String id);
+
+ /**
+ * It is used to delete Sites info.<br/>
+ *
+ * @param sitesEntity
+ * @return The delete result
+ * @since NFVO 0.5
+ */
+ int addSite(SitesEntity sitesEntity);
+
+ /**
+ * It is used to add Sites info.<br/>
+ *
+ * @param sitesEntity
+ * @return The add result
+ * @since NFVO 0.5
+ */
+ int addSiteSelective(SitesEntity sitesEntity);
+
+ /**
+ * It is used to add Sites info.<br/>
+ *
+ * @param sitesEntity
+ * @return The add result
+ * @since NFVO 0.5
+ */
+ int updateSiteSelective(SitesEntity sitesEntity);
+
+ /**
+ * It is used to update Sites info.<br/>
+ *
+ * @param sitesEntity
+ * @return The update result
+ * @since NFVO 0.5
+ */
+ int updateSite(SitesEntity sitesEntity);
+
+ /**
+ * It is used to update Sites info.<br/>
+ *
+ * @param sitesEntity
+ * @return The update result
+ * @since NFVO 0.5
+ */
+ int updateSiteByVimId(SitesEntity sitesEntity);
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/VimDao.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/VimDao.java
new file mode 100644
index 0000000..1b17a46
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/VimDao.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.dao.inf;
+
+import java.util.List;
+
+import org.openo.nfvo.resmanagement.service.entity.VimEntity;
+
+/**
+ * Vim info interface.<br/>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Aug 24, 2016
+ */
+public interface VimDao {
+
+ /**
+ * It is used to get Vim info.<br/>
+ *
+ * @param id
+ * @return The get result
+ * @since NFVO 0.5
+ */
+ VimEntity getVim(String id);
+
+ /**
+ * It is used to get Vims info.<br/>
+ *
+ * @return The get result
+ * @since NFVO 0.5
+ */
+ List<VimEntity> getVims();
+
+ /**
+ * It is used to delete Vim info.<br/>
+ *
+ * @param id
+ * @return The delete result
+ * @since NFVO 0.5
+ */
+ int deleteVim(String id);
+
+ /**
+ * It is used to add Vim info.<br/>
+ *
+ * @param vimEntity
+ * @return The add result
+ * @since NFVO 0.5
+ */
+ int addVim(VimEntity vimEntity);
+
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/VirtualLinkDao.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/VirtualLinkDao.java
new file mode 100644
index 0000000..ead3975
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/VirtualLinkDao.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.dao.inf;
+
+import java.util.List;
+import java.util.Map;
+
+import org.openo.nfvo.resmanagement.service.entity.VirtualLinkEntity;
+
+/**
+ * <br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Oct 28, 2016
+ */
+public interface VirtualLinkDao {
+
+ /**
+ * <br>
+ *
+ * @param id
+ * @return
+ * @since NFVO 0.5
+ */
+ VirtualLinkEntity getVl(String id);
+
+ /**
+ * <br>
+ *
+ * @param condition
+ * @return
+ * @since NFVO 0.5
+ */
+ List<VirtualLinkEntity> getVls(Map<String, Object> condition);
+
+ /**
+ * <br>
+ *
+ * @param virtualLinkEntity
+ * @return
+ * @since NFVO 0.5
+ */
+ int addVl(VirtualLinkEntity virtualLinkEntity);
+
+ /**
+ * <br>
+ *
+ * @param id
+ * @return
+ * @since NFVO 0.5
+ */
+ int deleteVlById(String id);
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/VmDao.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/VmDao.java
new file mode 100644
index 0000000..6d2b6b6
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/VmDao.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.dao.inf;
+
+import java.util.List;
+import java.util.Map;
+
+import org.openo.nfvo.resmanagement.service.entity.VmEntity;
+
+/**
+ * <br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Oct 28, 2016
+ */
+public interface VmDao {
+
+ VmEntity getVm(String id);
+
+ List<VmEntity> getVms(Map<String, Object> condition);
+
+ int addVm(VmEntity vmEntity);
+
+ int deleteVmById(String id);
+
+ int updateVm(VmEntity vmEntity);
+
+ int deleteVmByVnfId(String vnfInstanceId);
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/VnfDao.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/VnfDao.java
new file mode 100644
index 0000000..7f72ce3
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/VnfDao.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.dao.inf;
+
+import java.util.List;
+import java.util.Map;
+
+import org.openo.nfvo.resmanagement.service.entity.VnfEntity;
+
+/**
+ * <br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Oct 28, 2016
+ */
+public interface VnfDao {
+
+ /**
+ * <br>
+ *
+ * @param id
+ * @return
+ * @since NFVO 0.5
+ */
+ VnfEntity getVnf(String id);
+
+ /**
+ * <br>
+ *
+ * @param condition
+ * @return
+ * @since NFVO 0.5
+ */
+ List<VnfEntity> getVnfs(Map<String, Object> condition);
+
+ /**
+ * <br>
+ *
+ * @param vnfEntity
+ * @return
+ * @since NFVO 0.5
+ */
+ int addVnf(VnfEntity vnfEntity);
+
+ /**
+ * <br>
+ *
+ * @param id
+ * @return
+ * @since NFVO 0.5
+ */
+ int deleteVnfById(String id);
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/VnfInfoDao.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/VnfInfoDao.java
new file mode 100644
index 0000000..9e2aade
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/VnfInfoDao.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.dao.inf;
+
+import java.util.List;
+import java.util.Map;
+
+import org.openo.nfvo.resmanagement.service.entity.VnfInfoEntity;
+
+/**
+ * <br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Oct 28, 2016
+ */
+public interface VnfInfoDao {
+
+ VnfInfoEntity getVnfInfo(String id);
+
+ List<VnfInfoEntity> getVnfInfos(Map<String, Object> condition);
+
+ int addVnfInfo(VnfInfoEntity vnfInfoEntity);
+
+ int deleteVnfInfoById(String id);
+
+ int updateVnfInfo(VnfInfoEntity vnfInfoEntity);
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/VnfStatusDao.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/VnfStatusDao.java
new file mode 100644
index 0000000..ef5ba9b
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/dao/inf/VnfStatusDao.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.dao.inf;
+
+import java.util.List;
+import java.util.Map;
+
+import org.openo.nfvo.resmanagement.service.entity.VnfStatusEntity;
+
+/**
+ * <br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Oct 29, 2016
+ */
+public interface VnfStatusDao {
+
+ VnfStatusEntity getVnfStatus(String id);
+
+ List<VnfStatusEntity> getVnfStatuss(Map<String, Object> condition);
+
+ int addVnfStatus(VnfStatusEntity vnfStatusEntity);
+
+ int deleteVnfStatusById(String id);
+
+ int updateVnfStatus(VnfStatusEntity vnfStatusEntity);
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/HostEntity.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/HostEntity.java
new file mode 100644
index 0000000..f8166da
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/HostEntity.java
@@ -0,0 +1,179 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.entity;
+
+import org.apache.commons.lang3.StringUtils;
+import org.openo.nfvo.resmanagement.common.util.JsonUtil;
+
+import net.sf.json.JSONObject;
+
+/**
+ * Host entity class.<br/>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Aug 31, 2016
+ */
+public class HostEntity {
+
+ private String id;
+
+ private String name;
+
+ private String cpu;
+
+ private String memory;
+
+ private String disk;
+
+ private String vimId;
+
+ private String vimName;
+
+ /**
+ * @return Returns the id.
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * @param id The id to set.
+ */
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ /**
+ * @return Returns the name.
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @param name The name to set.
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * @return Returns the cpu.
+ */
+ public String getCpu() {
+ return cpu;
+ }
+
+ /**
+ * @param cpu The cpu to set.
+ */
+ public void setCpu(String cpu) {
+ this.cpu = cpu;
+ }
+
+ /**
+ * @return Returns the memory.
+ */
+ public String getMemory() {
+ return memory;
+ }
+
+ /**
+ * @param memory The memory to set.
+ */
+ public void setMemory(String memory) {
+ this.memory = memory;
+ }
+
+ /**
+ * @return Returns the disk.
+ */
+ public String getDisk() {
+ return disk;
+ }
+
+ /**
+ * @param disk The disk to set.
+ */
+ public void setDisk(String disk) {
+ this.disk = disk;
+ }
+
+ /**
+ * @return Returns the vimId.
+ */
+ public String getVimId() {
+ return vimId;
+ }
+
+ /**
+ * @param vimId The vimId to set.
+ */
+ public void setVimId(String vimId) {
+ this.vimId = vimId;
+ }
+
+ /**
+ * @return Returns the vimName.
+ */
+ public String getVimName() {
+ return vimName;
+ }
+
+ /**
+ * @param vimName The vimName to set.
+ */
+ public void setVimName(String vimName) {
+ this.vimName = vimName;
+ }
+
+ /**
+ *
+ * To entity.<br>
+ *
+ * @param jsonObject
+ * @return
+ * @since NFVO 0.5
+ */
+ public static HostEntity toEntity(JSONObject jsonObject) {
+ HostEntity hostEntity = new HostEntity();
+ hostEntity.setId(JsonUtil.getJsonFieldStr(jsonObject, "id"));
+ hostEntity.setName(JsonUtil.getJsonFieldStr(jsonObject, "name"));
+ hostEntity.setCpu(JsonUtil.getJsonFieldStr(jsonObject, "cpu"));
+ hostEntity.setMemory(JsonUtil.getJsonFieldStr(jsonObject, "memory"));
+ hostEntity.setDisk(JsonUtil.getJsonFieldStr(jsonObject, "disk"));
+ hostEntity.setVimId(JsonUtil.getJsonFieldStr(jsonObject, "vimId"));
+ hostEntity.setVimName(JsonUtil.getJsonFieldStr(jsonObject, "vimName"));
+ return hostEntity;
+ }
+
+ @Override
+ public String toString() {
+ JSONObject hostResJson = new JSONObject();
+ hostResJson.put("id", StringUtils.trimToEmpty(this.getId()));
+ hostResJson.put("name", StringUtils.trimToEmpty(this.getName()));
+ hostResJson.put("cpu", StringUtils.trimToEmpty(this.getCpu()));
+ hostResJson.put("memory", StringUtils.trimToEmpty(this.getMemory()));
+ hostResJson.put("disk", StringUtils.trimToEmpty(this.getDisk()));
+ hostResJson.put("vimId", StringUtils.trimToEmpty(this.getVimId()));
+ hostResJson.put("vimName", StringUtils.trimToEmpty(this.getVimName()));
+ return hostResJson.toString();
+ }
+
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/LocationEntity.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/LocationEntity.java
new file mode 100644
index 0000000..eab8ca0
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/LocationEntity.java
@@ -0,0 +1,236 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.entity;
+
+import org.apache.commons.lang3.StringUtils;
+import org.openo.nfvo.resmanagement.common.util.JsonUtil;
+
+import net.sf.json.JSONObject;
+
+/**
+ *
+ * Location entity class.<br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Sep 10, 2016
+ */
+public class LocationEntity {
+
+ /**
+ * This field was generated by MyBatis Generator. This field corresponds to
+ * the database column location.ID
+ *
+ * @mbggenerated
+ */
+ private String id;
+
+ /**
+ * This field was generated by MyBatis Generator. This field corresponds to
+ * the database column location.COUNTRY
+ *
+ * @mbggenerated
+ */
+ private String country;
+
+ /**
+ * This field was generated by MyBatis Generator. This field corresponds to
+ * the database column location.LOCATION
+ *
+ * @mbggenerated
+ */
+ private String location;
+
+ /**
+ * This field was generated by MyBatis Generator. This field corresponds to
+ * the database column location.LATITUDE
+ *
+ * @mbggenerated
+ */
+ private String latitude;
+
+ /**
+ * This field was generated by MyBatis Generator. This field corresponds to
+ * the database column location.LONGITUDE
+ *
+ * @mbggenerated
+ */
+ private String longitude;
+
+ private String description;
+
+ /**
+ * This method was generated by MyBatis Generator. This method returns the
+ * value of the database column location.ID
+ *
+ * @return the value of location.ID
+ * @mbggenerated
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * This method was generated by MyBatis Generator. This method sets the
+ * value of the database column location.ID
+ *
+ * @param id
+ * the value for location.ID
+ * @mbggenerated
+ */
+ public void setId(String id) {
+ this.id = id == null ? null : id.trim();
+ }
+
+ /**
+ * This method was generated by MyBatis Generator. This method returns the
+ * value of the database column location.COUNTRY
+ *
+ * @return the value of location.COUNTRY
+ * @mbggenerated
+ */
+ public String getCountry() {
+ return country;
+ }
+
+ /**
+ * This method was generated by MyBatis Generator. This method sets the
+ * value of the database column location.COUNTRY
+ *
+ * @param country
+ * the value for location.COUNTRY
+ * @mbggenerated
+ */
+ public void setCountry(String country) {
+ this.country = country == null ? null : country.trim();
+ }
+
+ /**
+ * This method was generated by MyBatis Generator. This method returns the
+ * value of the database column location.LOCATION
+ *
+ * @return the value of location.LOCATION
+ * @mbggenerated
+ */
+ public String getLocation() {
+ return location;
+ }
+
+ /**
+ * This method was generated by MyBatis Generator. This method sets the
+ * value of the database column location.LOCATION
+ *
+ * @param location
+ * the value for location.LOCATION
+ * @mbggenerated
+ */
+ public void setLocation(String location) {
+ this.location = location == null ? null : location.trim();
+ }
+
+ /**
+ * This method was generated by MyBatis Generator. This method returns the
+ * value of the database column location.LATITUDE
+ *
+ * @return the value of location.LATITUDE
+ * @mbggenerated
+ */
+ public String getLatitude() {
+ return latitude;
+ }
+
+ /**
+ * This method was generated by MyBatis Generator. This method sets the
+ * value of the database column location.LATITUDE
+ *
+ * @param latitude
+ * the value for location.LATITUDE
+ * @mbggenerated
+ */
+ public void setLatitude(String latitude) {
+ this.latitude = latitude == null ? null : latitude.trim();
+ }
+
+ /**
+ * This method was generated by MyBatis Generator. This method returns the
+ * value of the database column location.LONGITUDE
+ *
+ * @return the value of location.LONGITUDE
+ * @mbggenerated
+ */
+ public String getLongitude() {
+ return longitude;
+ }
+
+ /**
+ * This method was generated by MyBatis Generator. This method sets the
+ * value of the database column location.LONGITUDE
+ *
+ * @param longitude
+ * the value for location.LONGITUDE
+ * @mbggenerated
+ */
+ public void setLongitude(String longitude) {
+ this.longitude = longitude == null ? null : longitude.trim();
+ }
+
+ /**
+ * @return Returns the description.
+ */
+ public String getDescription() {
+ return description;
+ }
+
+ /**
+ * @param description The description to set.
+ */
+ public void setDescription(String description) {
+ this.description = description == null ? null : description.trim();
+ }
+
+ /**
+ *
+ * To Entity.<br>
+ *
+ * @param jsonObject
+ * @return
+ * @since NFVO 0.5
+ */
+ public static LocationEntity toEntity(JSONObject jsonObject) {
+ LocationEntity sodoresesEntity = new LocationEntity();
+ sodoresesEntity.setId(JsonUtil.getJsonFieldStr(jsonObject, "id"));
+ sodoresesEntity.setCountry(JsonUtil.getJsonFieldStr(jsonObject, "country"));
+ sodoresesEntity.setLocation(JsonUtil.getJsonFieldStr(jsonObject, "location"));
+ sodoresesEntity.setLatitude(JsonUtil.getJsonFieldStr(jsonObject, "latitude"));
+ sodoresesEntity.setLongitude(JsonUtil.getJsonFieldStr(jsonObject, "longitude"));
+ sodoresesEntity.setDescription(JsonUtil.getJsonFieldStr(jsonObject, "description"));
+ return sodoresesEntity;
+ }
+
+ @Override
+ public String toString() {
+ JSONObject locationJson = new JSONObject();
+ locationJson.put("id", StringUtils.trimToEmpty(this.getId()));
+ locationJson.put("country", StringUtils.trimToEmpty(this.getCountry()));
+ locationJson.put("location", StringUtils.trimToEmpty(this.getLocation()));
+ locationJson.put("latitude", StringUtils.trimToEmpty(this.getLatitude()));
+ locationJson.put("longitude", StringUtils.trimToEmpty(this.getLongitude()));
+ locationJson.put("description", StringUtils.trimToEmpty(this.getDescription()));
+ return locationJson.toString();
+ }
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/NetworkEntity.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/NetworkEntity.java
new file mode 100644
index 0000000..f65ad37
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/NetworkEntity.java
@@ -0,0 +1,271 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.entity;
+
+import org.apache.commons.lang3.StringUtils;
+import org.openo.nfvo.resmanagement.common.util.JsonUtil;
+
+import net.sf.json.JSONObject;
+
+/**
+ *
+ * Network entity class.<br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Sep 10, 2016
+ */
+public class NetworkEntity {
+
+ /**
+ * This field corresponds to the database column network.ID
+ */
+ private String id;
+
+ /**
+ * This field corresponds to the database column network.NAME
+ */
+ private String name;
+
+ /**
+ * This field corresponds to the database column network.TENANT_ID
+ */
+ private String tenantId;
+
+ /**
+ * This field corresponds to the database column network.VIM_ID
+ */
+ private String vimId;
+
+ /**
+ * This field corresponds to the database column ivm.VIM_NAME
+ */
+ private String vimName;
+
+ /**
+ * This field corresponds to the database column network.STATUS
+ */
+ private String status;
+
+ /**
+ * This field corresponds to the database column network.PHYSICAL_NETWORK
+ */
+
+ private String physicalNetwork;
+
+ /**
+ * This field corresponds to the database column network.NETWORK_TYPE
+ */
+ private String networkType;
+
+ /**
+ * This field corresponds to the database column network.SEGMENTATION_ID
+ */
+ private String segmentationId;
+
+ /**
+ * return the value of network.ID
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * This method sets the value of the database column network.ID
+ *
+ * @param id
+ * the value for network.ID
+ */
+ public void setId(String id) {
+ this.id = id == null ? null : id.trim();
+ }
+
+ /**
+ * return the value of network.NAME
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * This method sets the value of the database column network.NAME
+ *
+ * @param name
+ * the value for network.NAME
+ */
+ public void setName(String name) {
+ this.name = name == null ? null : name.trim();
+ }
+
+ /**
+ * return the value of network.TENANT_ID
+ */
+ public String getTenantId() {
+ return tenantId;
+ }
+
+ /**
+ * This method sets the value of the database column network.TENANT_ID
+ *
+ * @param tenantId
+ * the value for network.TENANT_ID
+ */
+ public void setTenantId(String tenantId) {
+ this.tenantId = tenantId == null ? null : tenantId.trim();
+ }
+
+ /**
+ * return the value of network.VIM_ID
+ */
+ public String getVimId() {
+ return vimId;
+ }
+
+ /**
+ * This method sets the value of the database column network.VIM_ID
+ *
+ * @param networkVimId
+ * the value for network.VIM_ID
+ */
+ public void setVimId(String networkVimId) {
+ this.vimId = networkVimId == null ? null : networkVimId.trim();
+ }
+
+ /**
+ * return the value of ivm.VIM_NAME
+ */
+ public String getVimName() {
+ return vimName;
+ }
+
+ /**
+ * This method sets the value of the database column ivm.VIM_NAME
+ *
+ * @param networkVimName
+ * the value for ivm.VIM_NAME
+ */
+ public void setVimName(String networkVimName) {
+ this.vimName = networkVimName == null ? null : networkVimName.trim();
+ }
+
+ /**
+ * return the value of network.STATUS
+ */
+ public String getStatus() {
+ return status;
+ }
+
+ /**
+ * This method sets the value of the database column network.STATUS
+ *
+ * @param networkStatus
+ * the value for network.STATUS
+ */
+ public void setStatus(String networkStatus) {
+ this.status = networkStatus == null ? null : networkStatus.trim().toLowerCase();
+ }
+
+ /**
+ * return the value of network.PHYSICAL_NETWORK
+ */
+ public String getPhysicalNetwork() {
+ return physicalNetwork;
+ }
+
+ /**
+ * This method sets the value of the database column
+ * network.PHYSICAL_NETWORK
+ *
+ * @param physicalNetwork
+ * the value for network.PHYSICAL_NETWORK
+ */
+ public void setPhysicalNetwork(String physicalNetwork) {
+ this.physicalNetwork = physicalNetwork == null ? null : physicalNetwork.trim();
+ }
+
+ /**
+ * return the value of network.NETWORK_TYPE
+ */
+ public String getNetworkType() {
+ return networkType;
+ }
+
+ /**
+ * This method sets the value of the database column network.NETWORK_TYPE
+ *
+ * @param networkType
+ * the value for network.NETWORK_TYPE
+ */
+ public void setNetworkType(String networkType) {
+ this.networkType = networkType == null ? null : networkType.trim();
+ }
+
+ /**
+ * return the value of network.SEGMENTATION_ID
+ */
+ public String getSegmentationId() {
+ return segmentationId;
+ }
+
+ /**
+ * This method sets the value of the database column network.SEGMENTATION_ID
+ *
+ * @param segmentationId
+ * the value for network.SEGMENTATION_ID
+ */
+ public void setSegmentationId(String segmentationId) {
+ this.segmentationId = segmentationId == null ? null : segmentationId.trim();
+ }
+
+ /**
+ *
+ * To Entity.<br>
+ *
+ * @param jsonObject
+ * @return
+ * @since NFVO 0.5
+ */
+ public static NetworkEntity toEntity(JSONObject jsonObject) {
+ NetworkEntity sitesEntity = new NetworkEntity();
+ sitesEntity.setId(JsonUtil.getJsonFieldStr(jsonObject, "id"));
+ sitesEntity.setName(JsonUtil.getJsonFieldStr(jsonObject, "name"));
+ sitesEntity.setTenantId(JsonUtil.getJsonFieldStr(jsonObject, "tenantId"));
+ sitesEntity.setStatus(JsonUtil.getJsonFieldStr(jsonObject, "status"));
+ sitesEntity.setVimId(JsonUtil.getJsonFieldStr(jsonObject, "vimId"));
+ sitesEntity.setVimName(JsonUtil.getJsonFieldStr(jsonObject, "vimName"));
+ sitesEntity.setPhysicalNetwork(JsonUtil.getJsonFieldStr(jsonObject, "physicalNetwork"));
+ sitesEntity.setNetworkType(JsonUtil.getJsonFieldStr(jsonObject, "networkType"));
+ sitesEntity.setSegmentationId(JsonUtil.getJsonFieldStr(jsonObject, "segmentationId"));
+ return sitesEntity;
+ }
+
+ @Override
+ public String toString() {
+ JSONObject networkJson = new JSONObject();
+ networkJson.put("id", StringUtils.trimToEmpty(this.getId()));
+ networkJson.put("name", StringUtils.trimToEmpty(this.getName()));
+ networkJson.put("tenant_id", StringUtils.trimToEmpty(this.getTenantId()));
+ networkJson.put("status", StringUtils.trimToEmpty(this.getStatus()));
+ networkJson.put("vimId", StringUtils.trimToEmpty(this.getVimId()));
+ networkJson.put("vimName", StringUtils.trimToEmpty(this.getVimName()));
+ networkJson.put("provider:physical_network", StringUtils.trimToEmpty(this.getPhysicalNetwork()));
+ networkJson.put("provider:network_type", StringUtils.trimToEmpty(this.getNetworkType()));
+ networkJson.put("provider:segmentation_id", StringUtils.trimToEmpty(this.getSegmentationId()));
+ return networkJson.toString();
+ }
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/PortEntity.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/PortEntity.java
new file mode 100644
index 0000000..4700554
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/PortEntity.java
@@ -0,0 +1,179 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.entity;
+
+import org.apache.commons.lang3.StringUtils;
+import org.openo.nfvo.resmanagement.common.util.JsonUtil;
+
+import net.sf.json.JSONObject;
+
+/**
+ * Port Entity Class.<br/>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Aug 31, 2016
+ */
+public class PortEntity {
+
+ private String id;
+
+ private String name;
+
+ private String networkId;
+
+ private String status;
+
+ private String tenantId;
+
+ private String vimId;
+
+ private String vimName;
+
+ /**
+ * @return Returns the id.
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * @param id The id to set.
+ */
+ public void setId(String id) {
+ this.id = id == null ? null : id.trim();
+ }
+
+ /**
+ * @return Returns the name.
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @param name The name to set.
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * @return Returns the networkId.
+ */
+ public String getNetworkId() {
+ return networkId;
+ }
+
+ /**
+ * @param networkId The networkId to set.
+ */
+ public void setNetworkId(String networkId) {
+ this.networkId = networkId;
+ }
+
+ /**
+ * @return Returns the status.
+ */
+ public String getStatus() {
+ return status;
+ }
+
+ /**
+ * @param status The status to set.
+ */
+ public void setStatus(String status) {
+ this.status = status;
+ }
+
+ /**
+ * @return Returns the tenantId.
+ */
+ public String getTenantId() {
+ return tenantId;
+ }
+
+ /**
+ * @param tenantId The tenantId to set.
+ */
+ public void setTenantId(String tenantId) {
+ this.tenantId = tenantId;
+ }
+
+ /**
+ * @return Returns the vimId.
+ */
+ public String getVimId() {
+ return vimId;
+ }
+
+ /**
+ * @param vimId The vimId to set.
+ */
+ public void setVimId(String vimId) {
+ this.vimId = vimId;
+ }
+
+ /**
+ * @return Returns the vimName.
+ */
+ public String getVimName() {
+ return vimName;
+ }
+
+ /**
+ * @param vimName The vimName to set.
+ */
+ public void setVimName(String vimName) {
+ this.vimName = vimName;
+ }
+
+ /**
+ *
+ * To Entity.<br>
+ *
+ * @param jsonObject
+ * @return
+ * @since NFVO 0.5
+ */
+ public static PortEntity toEntity(JSONObject jsonObject) {
+ PortEntity portEntity = new PortEntity();
+ portEntity.setId(JsonUtil.getJsonFieldStr(jsonObject, "id"));
+ portEntity.setName(JsonUtil.getJsonFieldStr(jsonObject, "name"));
+ portEntity.setNetworkId(JsonUtil.getJsonFieldStr(jsonObject, "networkId"));
+ portEntity.setStatus(JsonUtil.getJsonFieldStr(jsonObject, "status"));
+ portEntity.setTenantId(JsonUtil.getJsonFieldStr(jsonObject, "tenantId"));
+ portEntity.setVimId(JsonUtil.getJsonFieldStr(jsonObject, "vimId"));
+ portEntity.setVimName(JsonUtil.getJsonFieldStr(jsonObject, "vimName"));
+ return portEntity;
+ }
+
+ @Override
+ public String toString() {
+ JSONObject portResJson = new JSONObject();
+ portResJson.put("id", StringUtils.trimToEmpty(this.getId()));
+ portResJson.put("name", StringUtils.trimToEmpty(this.getName()));
+ portResJson.put("networkId", StringUtils.trimToEmpty(this.getNetworkId()));
+ portResJson.put("status", StringUtils.trimToEmpty(this.getStatus()));
+ portResJson.put("tenantId", StringUtils.trimToEmpty(this.getTenantId()));
+ portResJson.put("vimId", StringUtils.trimToEmpty(this.getVimId()));
+ portResJson.put("vimName", StringUtils.trimToEmpty(this.getVimName()));
+ return portResJson.toString();
+ }
+
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/SitesEntity.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/SitesEntity.java
new file mode 100644
index 0000000..33c1942
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/SitesEntity.java
@@ -0,0 +1,309 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.entity;
+
+import org.apache.commons.lang3.StringUtils;
+import org.openo.nfvo.resmanagement.common.util.JsonUtil;
+import org.openo.nfvo.resmanagement.common.util.StringUtil;
+
+import net.sf.json.JSONObject;
+
+/**
+ *
+ * Sites entity class.<br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Sep 10, 2016
+ */
+public class SitesEntity {
+
+ private String id;
+
+ private String name;
+
+ private String location;
+
+ private String country;
+
+ private String vimId;
+
+ private String vimName;
+
+ private String status;
+
+ private String totalCPU = "0";
+
+ private String totalMemory = "0";
+
+ private String totalDisk = "0";
+
+ private String usedCPU = "0";
+
+ private String usedMemory = "0";
+
+ private String usedDisk = "0";
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id == null ? null : id.trim();
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name == null ? null : name.trim();
+ }
+
+ public String getLocation() {
+ return location;
+ }
+
+ public void setLocation(String location) {
+ this.location = location == null ? null : location.trim();
+ }
+
+ public String getCountry() {
+ return country;
+ }
+
+ public void setCountry(String country) {
+ this.country = country == null ? null : country.trim();
+ }
+
+ public String getVimId() {
+ return vimId;
+ }
+
+ public void setVimId(String siteVimId) {
+ this.vimId = siteVimId == null ? null : siteVimId.trim();
+ }
+
+ public String getVimName() {
+ return vimName;
+ }
+
+ public void setVimName(String siteVimName) {
+ this.vimName = siteVimName == null ? null : siteVimName.trim();
+ }
+
+ public String getStatus() {
+ return status;
+ }
+
+ public void setStatus(String siteStatus) {
+ this.status = siteStatus == null ? null : siteStatus.trim().toLowerCase();
+ }
+
+ /**
+ * @return Returns the totalCPU.
+ */
+ public String getTotalCPU() {
+ return totalCPU;
+ }
+
+ /**
+ * @param totalCPU The totalCPU to set.
+ */
+ public void setTotalCPU(String totalCPU) {
+ this.totalCPU = totalCPU == null ? null : totalCPU.trim();
+ }
+
+ /**
+ * @return Returns the totalMemory.
+ */
+ public String getTotalMemory() {
+ return totalMemory;
+ }
+
+ /**
+ * @param totalMemory The totalMemory to set.
+ */
+ public void setTotalMemory(String totalMemory) {
+ this.totalMemory = totalMemory == null ? null : totalMemory.trim();
+ }
+
+ /**
+ * @return Returns the totalDisk.
+ */
+ public String getTotalDisk() {
+ return totalDisk;
+ }
+
+ /**
+ * @param totalDisk The totalDisk to set.
+ */
+ public void setTotalDisk(String totalDisk) {
+ this.totalDisk = totalDisk == null ? null : totalDisk.trim();
+ }
+
+ /**
+ * @return Returns the usedCPU.
+ */
+ public String getUsedCPU() {
+ return usedCPU;
+ }
+
+ /**
+ * @param usedCPU The usedCPU to set.
+ */
+ public void setUsedCPU(String usedCPU) {
+ this.usedCPU = usedCPU == null ? null : usedCPU.trim();
+ }
+
+ /**
+ * @return Returns the usedMemory.
+ */
+ public String getUsedMemory() {
+ return usedMemory;
+ }
+
+ /**
+ * @param usedMemory The usedMemory to set.
+ */
+ public void setUsedMemory(String usedMemory) {
+ this.usedMemory = usedMemory == null ? null : usedMemory.trim();
+ }
+
+ /**
+ * @return Returns the usedDisk.
+ */
+ public String getUsedDisk() {
+ return usedDisk;
+ }
+
+ /**
+ * @param usedDisk The usedDisk to set.
+ */
+ public void setUsedDisk(String usedDisk) {
+ this.usedDisk = usedDisk == null ? null : usedDisk.trim();
+ }
+
+ /**
+ *
+ * To Entity.<br>
+ *
+ * @param jsonObject
+ * @return
+ * @since NFVO 0.5
+ */
+ public static SitesEntity toEntity(JSONObject jsonObject) {
+ SitesEntity sitesEntity = new SitesEntity();
+ sitesEntity.setId(JsonUtil.getJsonFieldStr(jsonObject, "id"));
+ sitesEntity.setName(JsonUtil.getJsonFieldStr(jsonObject, "name"));
+ sitesEntity.setStatus(JsonUtil.getJsonFieldStr(jsonObject, "status"));
+ sitesEntity.setLocation(JsonUtil.getJsonFieldStr(jsonObject, "location"));
+ sitesEntity.setCountry(JsonUtil.getJsonFieldStr(jsonObject, "country"));
+ sitesEntity.setVimId(JsonUtil.getJsonFieldStr(jsonObject, "vimId"));
+ sitesEntity.setVimName(JsonUtil.getJsonFieldStr(jsonObject, "vimName"));
+ sitesEntity.setTotalCPU(JsonUtil.getJsonFieldStr(jsonObject, "totalCPU"));
+ sitesEntity.setTotalMemory(JsonUtil.getJsonFieldStr(jsonObject, "totalMemory"));
+ sitesEntity.setTotalDisk(JsonUtil.getJsonFieldStr(jsonObject, "totalDisk"));
+ sitesEntity.setUsedCPU(JsonUtil.getJsonFieldStr(jsonObject, "usedCPU"));
+ sitesEntity.setUsedMemory(JsonUtil.getJsonFieldStr(jsonObject, "usedMemory"));
+ sitesEntity.setUsedDisk(JsonUtil.getJsonFieldStr(jsonObject, "usedDisk"));
+ return sitesEntity;
+ }
+
+ @Override
+ public String toString() {
+ JSONObject siteResJson = new JSONObject();
+ siteResJson.put("id", StringUtils.trimToEmpty(this.getId()));
+ siteResJson.put("name", StringUtils.trimToEmpty(this.getName()));
+ siteResJson.put("status", StringUtils.trimToEmpty(this.getStatus()));
+ siteResJson.put("location", StringUtils.trimToEmpty(this.getLocation()));
+ siteResJson.put("country", StringUtils.trimToEmpty(this.getCountry()));
+ siteResJson.put("vimId", StringUtils.trimToEmpty(this.getVimId()));
+ siteResJson.put("vimName", StringUtils.trimToEmpty(this.getVimName()));
+ siteResJson.put("totalCPU", StringUtils.trimToEmpty(this.getTotalCPU()));
+ siteResJson.put("totalMemory", StringUtils.trimToEmpty(this.getTotalMemory()));
+ siteResJson.put("totalDisk", StringUtils.trimToEmpty(this.getTotalDisk()));
+ siteResJson.put("usedCPU", StringUtils.trimToEmpty(this.getUsedCPU()));
+ siteResJson.put("usedMemory", StringUtils.trimToEmpty(this.getUsedMemory()));
+ siteResJson.put("usedDisk", StringUtils.trimToEmpty(this.getUsedDisk()));
+
+ return siteResJson.toString();
+ }
+
+ /**
+ *
+ * Check whther the resource is zero.<br>
+ *
+ * @param siteEntity
+ * @return
+ * @since NFVO 0.5
+ */
+ public static boolean checkResourceIsZero(SitesEntity siteEntity) {
+
+ if(StringUtil.isAnyLargeThanZero(siteEntity.getUsedCPU(), siteEntity.getUsedMemory(),
+ siteEntity.getUsedDisk())) {
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ *
+ * Check resource.<br>
+ *
+ * @param siteEntity
+ * @return
+ * @since NFVO 0.5
+ */
+ public static boolean checkResource(SitesEntity siteEntity) {
+ String cpu = siteEntity.getTotalCPU();
+ String memory = siteEntity.getTotalMemory();
+ String disk = siteEntity.getTotalDisk();
+ String cpuUsed = siteEntity.getUsedCPU();
+ String memoryUsed = siteEntity.getUsedMemory();
+ String diskUsed = siteEntity.getUsedDisk();
+
+ if(!StringUtil.isInteger(cpu, cpuUsed)) {
+ return false;
+ }
+
+ if(!StringUtil.isNumeric(memory, disk, memoryUsed, diskUsed)) {
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ *
+ * Format data.<br>
+ *
+ * @param siteEntity
+ * @since NFVO 0.5
+ */
+ public static void dataFramat(SitesEntity siteEntity) {
+ siteEntity.setTotalCPU(StringUtil.numFormat(siteEntity.getTotalCPU()));
+ siteEntity.setTotalMemory(StringUtil.numFormat(siteEntity.getTotalMemory()));
+ siteEntity.setTotalDisk(StringUtil.numFormat(siteEntity.getTotalDisk()));
+ siteEntity.setUsedCPU(StringUtil.numFormat(siteEntity.getUsedCPU()));
+ siteEntity.setUsedMemory(StringUtil.numFormat(siteEntity.getUsedMemory()));
+ siteEntity.setUsedDisk(StringUtil.numFormat(siteEntity.getUsedDisk()));
+
+ }
+
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/VimEntity.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/VimEntity.java
new file mode 100644
index 0000000..9959101
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/VimEntity.java
@@ -0,0 +1,106 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.entity;
+
+import org.apache.commons.lang3.StringUtils;
+import org.openo.nfvo.resmanagement.common.util.JsonUtil;
+
+import net.sf.json.JSONObject;
+
+/**
+ *
+ * Virtualised infrastructure manager entity class.<br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Sep 10, 2016
+ */
+public class VimEntity {
+
+ /**
+ * This field corresponds to the database column vim.ID
+ *
+ * @mbggenerated
+ */
+ private String id;
+
+ /**
+ * This field corresponds to the database column vim.ID
+ *
+ * @mbggenerated
+ */
+ private String name;
+
+ /**
+ * This method was generated by MyBatis Generator. This method returns the
+ * value of the database column vim.ID
+ *
+ * @return the value of vim.ID
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * This method was generated by MyBatis Generator. This method sets the
+ * value of the database column vim.ID
+ *
+ * @param id
+ * the value for vim.ID
+ */
+ public void setId(String id) {
+ this.id = id == null ? null : id.trim();
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ *
+ * To Entity.<br>
+ *
+ * @param jsonObject
+ * @return
+ * @since NFVO 0.5
+ */
+ public static VimEntity toEntity(JSONObject jsonObject) {
+ VimEntity vimEntity = new VimEntity();
+ vimEntity.setId(JsonUtil.getJsonFieldStr(jsonObject, "id"));
+ vimEntity.setName(JsonUtil.getJsonFieldStr(jsonObject, "name"));
+ return vimEntity;
+ }
+
+ /**
+ *
+ * To String.<br>
+ *
+ * @return
+ * @since NFVO 0.5
+ */
+ public String toString() {
+ JSONObject resJson = new JSONObject();
+ resJson.put("id", StringUtils.trimToEmpty(this.getId()));
+ resJson.put("name", StringUtils.trimToEmpty(this.getName()));
+ return resJson.toString();
+ }
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/VirtualLinkEntity.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/VirtualLinkEntity.java
new file mode 100644
index 0000000..c9a38d9
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/VirtualLinkEntity.java
@@ -0,0 +1,285 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.entity;
+
+import java.io.Serializable;
+
+import org.apache.commons.lang3.StringUtils;
+import org.openo.nfvo.resmanagement.common.util.JsonUtil;
+
+import net.sf.json.JSONObject;
+
+/**
+ * @author l00345485
+ * @date 2016-10-27
+ */
+public class VirtualLinkEntity implements Serializable {
+
+ /** */
+ private String id;
+
+ /** */
+ private String name;
+
+ /** */
+ private String backendId;
+
+ /** */
+ private String isPublic;
+
+ /** */
+ private String dcName;
+
+ /** */
+ private String vimId;
+
+ /** */
+ private String vimName;
+
+ /** */
+ private String physicialNet;
+
+ /** */
+ private String nsId;
+
+ /** */
+ private String nsName;
+
+ /** */
+ private String description;
+
+ /** */
+ private String networkType;
+
+ /** */
+ private String segmentation;
+
+ /** */
+ private String mtu;
+
+ /** */
+ private String vlanTransparent;
+
+ /** */
+ private String routerExternal;
+
+ /** */
+ private String resourceProviderType;
+
+ /** */
+ private String resourceProviderId;
+
+ private static final long serialVersionUID = 1L;
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getBackendId() {
+ return backendId;
+ }
+
+ public void setBackendId(String backendId) {
+ this.backendId = backendId;
+ }
+
+ public String getIsPublic() {
+ return isPublic;
+ }
+
+ public void setIsPublic(String isPublic) {
+ this.isPublic = isPublic;
+ }
+
+ public String getDcName() {
+ return dcName;
+ }
+
+ public void setDcName(String dcName) {
+ this.dcName = dcName;
+ }
+
+ public String getVimId() {
+ return vimId;
+ }
+
+ public void setVimId(String vimId) {
+ this.vimId = vimId;
+ }
+
+ public String getVimName() {
+ return vimName;
+ }
+
+ public void setVimName(String vimName) {
+ this.vimName = vimName;
+ }
+
+ public String getPhysicialNet() {
+ return physicialNet;
+ }
+
+ public void setPhysicialNet(String physicialNet) {
+ this.physicialNet = physicialNet;
+ }
+
+ public String getNsId() {
+ return nsId;
+ }
+
+ public void setNsId(String nsId) {
+ this.nsId = nsId;
+ }
+
+ public String getNsName() {
+ return nsName;
+ }
+
+ public void setNsName(String nsName) {
+ this.nsName = nsName;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public String getNetworkType() {
+ return networkType;
+ }
+
+ public void setNetworkType(String networkType) {
+ this.networkType = networkType;
+ }
+
+ public String getSegmentation() {
+ return segmentation;
+ }
+
+ public void setSegmentation(String segmentation) {
+ this.segmentation = segmentation;
+ }
+
+ public String getMtu() {
+ return mtu;
+ }
+
+ public void setMtu(String mtu) {
+ this.mtu = mtu;
+ }
+
+ public String getVlanTransparent() {
+ return vlanTransparent;
+ }
+
+ public void setVlanTransparent(String vlanTransparent) {
+ this.vlanTransparent = vlanTransparent;
+ }
+
+ public String getRouterExternal() {
+ return routerExternal;
+ }
+
+ public void setRouterExternal(String routerExternal) {
+ this.routerExternal = routerExternal;
+ }
+
+ public String getResourceProviderType() {
+ return resourceProviderType;
+ }
+
+ public void setResourceProviderType(String resourceProviderType) {
+ this.resourceProviderType = resourceProviderType;
+ }
+
+ public String getResourceProviderId() {
+ return resourceProviderId;
+ }
+
+ public void setResourceProviderId(String resourceProviderId) {
+ this.resourceProviderId = resourceProviderId;
+ }
+
+ /**
+ * <br>
+ *
+ * @param jsonObject
+ * @return
+ * @since NFVO 0.5
+ */
+ public static VirtualLinkEntity toEntity(JSONObject jsonObject) {
+ VirtualLinkEntity virtualLinkEntity = new VirtualLinkEntity();
+ virtualLinkEntity.setId(JsonUtil.getJsonFieldStr(jsonObject, "vlInstanceId"));
+ virtualLinkEntity.setName(JsonUtil.getJsonFieldStr(jsonObject, "name"));
+ virtualLinkEntity.setBackendId(JsonUtil.getJsonFieldStr(jsonObject, "backendId"));
+ virtualLinkEntity.setIsPublic(JsonUtil.getJsonFieldStr(jsonObject, "isPublic"));
+ virtualLinkEntity.setDcName(JsonUtil.getJsonFieldStr(jsonObject, "dcName"));
+ virtualLinkEntity.setVimId(JsonUtil.getJsonFieldStr(jsonObject, "vimId"));
+ virtualLinkEntity.setVimName(JsonUtil.getJsonFieldStr(jsonObject, "vimName"));
+ virtualLinkEntity.setPhysicialNet(JsonUtil.getJsonFieldStr(jsonObject, "physicialNet"));
+ virtualLinkEntity.setNsId(JsonUtil.getJsonFieldStr(jsonObject, "nsId"));
+ virtualLinkEntity.setNsName(JsonUtil.getJsonFieldStr(jsonObject, "nsName"));
+ virtualLinkEntity.setDescription(JsonUtil.getJsonFieldStr(jsonObject, "description"));
+ virtualLinkEntity.setNetworkType(JsonUtil.getJsonFieldStr(jsonObject, "networkType"));
+ virtualLinkEntity.setSegmentation(JsonUtil.getJsonFieldStr(jsonObject, "segmentation"));
+ virtualLinkEntity.setMtu(JsonUtil.getJsonFieldStr(jsonObject, "mtu"));
+ virtualLinkEntity.setVlanTransparent(JsonUtil.getJsonFieldStr(jsonObject, "vlanTransparent"));
+ virtualLinkEntity.setRouterExternal(JsonUtil.getJsonFieldStr(jsonObject, "routerExternal"));
+ virtualLinkEntity.setResourceProviderId(JsonUtil.getJsonFieldStr(jsonObject, "resourceProviderId"));
+ virtualLinkEntity.setResourceProviderType(JsonUtil.getJsonFieldStr(jsonObject, "resourceProviderType"));
+ return virtualLinkEntity;
+ }
+
+ @Override
+ public String toString() {
+ JSONObject virtualLinkResJson = new JSONObject();
+ virtualLinkResJson.put("id", StringUtils.trimToEmpty(this.getId()));
+ virtualLinkResJson.put("name", StringUtils.trimToEmpty(this.getName()));
+ virtualLinkResJson.put("backendId", StringUtils.trimToEmpty(this.getBackendId()));
+ virtualLinkResJson.put("isPublic", StringUtils.trimToEmpty(this.getIsPublic()));
+ virtualLinkResJson.put("dcName", StringUtils.trimToEmpty(this.getDcName()));
+ virtualLinkResJson.put("vimId", StringUtils.trimToEmpty(this.getVimId()));
+ virtualLinkResJson.put("vimName", StringUtils.trimToEmpty(this.getVimName()));
+ virtualLinkResJson.put("physicialNet", StringUtils.trimToEmpty(this.getPhysicialNet()));
+ virtualLinkResJson.put("nsId", StringUtils.trimToEmpty(this.getNsId()));
+ virtualLinkResJson.put("nsName", StringUtils.trimToEmpty(this.getNsName()));
+ virtualLinkResJson.put("description", StringUtils.trimToEmpty(this.getDescription()));
+ virtualLinkResJson.put("networkType", StringUtils.trimToEmpty(this.getNetworkType()));
+ virtualLinkResJson.put("segmentation", StringUtils.trimToEmpty(this.getSegmentation()));
+ virtualLinkResJson.put("mtu", StringUtils.trimToEmpty(this.getMtu()));
+ virtualLinkResJson.put("vlanTransparent", StringUtils.trimToEmpty(this.getVlanTransparent()));
+ virtualLinkResJson.put("routerExternal", StringUtils.trimToEmpty(this.getRouterExternal()));
+ virtualLinkResJson.put("resourceProviderId", StringUtils.trimToEmpty(this.getResourceProviderId()));
+ virtualLinkResJson.put("resourceProviderType", StringUtils.trimToEmpty(this.getResourceProviderType()));
+ return virtualLinkResJson.toString();
+ }
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/VmEntity.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/VmEntity.java
new file mode 100644
index 0000000..e01cabd
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/VmEntity.java
@@ -0,0 +1,96 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.entity;
+
+import java.io.Serializable;
+
+import org.apache.commons.lang3.StringUtils;
+import org.openo.nfvo.resmanagement.common.util.JsonUtil;
+
+import net.sf.json.JSONObject;
+
+/**
+ * @author l00345485
+ * @date 2016-10-28
+ */
+public class VmEntity implements Serializable {
+
+ /** */
+ private String vmId;
+
+ /** */
+ private String vmName;
+
+ /** */
+ private String vmStatus;
+
+ /** */
+ private String vnfInstanceId;
+
+ private static final long serialVersionUID = 1L;
+
+ public String getVmId() {
+ return vmId;
+ }
+
+ public void setVmId(String vmId) {
+ this.vmId = vmId;
+ }
+
+ public String getVmName() {
+ return vmName;
+ }
+
+ public void setVmName(String vmName) {
+ this.vmName = vmName;
+ }
+
+ public String getVmStatus() {
+ return vmStatus;
+ }
+
+ public void setVmStatus(String vmStatus) {
+ this.vmStatus = vmStatus;
+ }
+
+ public String getVnfInstanceId() {
+ return vnfInstanceId;
+ }
+
+ public void setVnfInstanceId(String vnfInstanceId) {
+ this.vnfInstanceId = vnfInstanceId;
+ }
+
+ public static VmEntity toEntity(JSONObject jsonObject) {
+ VmEntity vmEntity = new VmEntity();
+ vmEntity.setVmId(JsonUtil.getJsonFieldStr(jsonObject, "vmId"));
+ vmEntity.setVmName(JsonUtil.getJsonFieldStr(jsonObject, "vmName"));
+ vmEntity.setVmStatus(JsonUtil.getJsonFieldStr(jsonObject, "vmStatus"));
+ vmEntity.setVnfInstanceId(JsonUtil.getJsonFieldStr(jsonObject, "vnfInstanceId"));
+ return vmEntity;
+ }
+
+ @Override
+ public String toString() {
+ JSONObject vmResJson = new JSONObject();
+ vmResJson.put("vmId", StringUtils.trimToEmpty(this.getVmId()));
+ vmResJson.put("vmName", StringUtils.trimToEmpty(this.getVmName()));
+ vmResJson.put("vmStatus", StringUtils.trimToEmpty(this.getVmStatus()));
+ vmResJson.put("vnfInstanceId", StringUtils.trimToEmpty(this.getVnfInstanceId()));
+ return vmResJson.toString();
+ }
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/VnfEntity.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/VnfEntity.java
new file mode 100644
index 0000000..3a18524
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/VnfEntity.java
@@ -0,0 +1,337 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.entity;
+
+import java.io.Serializable;
+
+import org.apache.commons.lang3.StringUtils;
+import org.openo.nfvo.resmanagement.common.util.JsonUtil;
+
+import net.sf.json.JSONObject;
+
+/**
+ * @author l00345485
+ * @date 2016-10-28
+ */
+public class VnfEntity implements Serializable {
+
+ /** */
+ private String id;
+
+ /** */
+ private String vnfInstanceId;
+
+ /** */
+ private String vnfInstanceName;
+
+ /** */
+ private String nsId;
+
+ /** */
+ private String nsName;
+
+ /** */
+ private String vnfmId;
+
+ /** */
+ private String vnfmName;
+
+ /** */
+ private String vnfPackageName;
+
+ /** */
+ private String vnfDescriptorName;
+
+ /** */
+ private String vimId;
+
+ /** */
+ private String vimName;
+
+ /** */
+ private String vimTenant;
+
+ /** */
+ private String jobId;
+
+ /** */
+ private String vnfStatus;
+
+ /** */
+ private String vnfType;
+
+ /** */
+ private Integer maxVm;
+
+ /** */
+ private Integer maxCpu;
+
+ /** */
+ private Integer maxDisk;
+
+ /** */
+ private Integer maxRam;
+
+ /** */
+ private Integer maxShd;
+
+ /** */
+ private Integer maxNet;
+
+ /** */
+ private String name;
+
+ private static final long serialVersionUID = 1L;
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getVnfInstanceId() {
+ return vnfInstanceId;
+ }
+
+ public void setVnfInstanceId(String vnfInstanceId) {
+ this.vnfInstanceId = vnfInstanceId;
+ }
+
+ public String getVnfInstanceName() {
+ return vnfInstanceName;
+ }
+
+ public void setVnfInstanceName(String vnfInstanceName) {
+ this.vnfInstanceName = vnfInstanceName;
+ }
+
+ public String getNsId() {
+ return nsId;
+ }
+
+ public void setNsId(String nsId) {
+ this.nsId = nsId;
+ }
+
+ public String getNsName() {
+ return nsName;
+ }
+
+ public void setNsName(String nsName) {
+ this.nsName = nsName;
+ }
+
+ public String getVnfmId() {
+ return vnfmId;
+ }
+
+ public void setVnfmId(String vnfmId) {
+ this.vnfmId = vnfmId;
+ }
+
+ public String getVnfmName() {
+ return vnfmName;
+ }
+
+ public void setVnfmName(String vnfmName) {
+ this.vnfmName = vnfmName;
+ }
+
+ public String getVnfPackageName() {
+ return vnfPackageName;
+ }
+
+ public void setVnfPackageName(String vnfPackageName) {
+ this.vnfPackageName = vnfPackageName;
+ }
+
+ public String getVnfDescriptorName() {
+ return vnfDescriptorName;
+ }
+
+ public void setVnfDescriptorName(String vnfDescriptorName) {
+ this.vnfDescriptorName = vnfDescriptorName;
+ }
+
+ public String getVimId() {
+ return vimId;
+ }
+
+ public void setVimId(String vimId) {
+ this.vimId = vimId;
+ }
+
+ public String getVimName() {
+ return vimName;
+ }
+
+ public void setVimName(String vimName) {
+ this.vimName = vimName;
+ }
+
+ public String getVimTenant() {
+ return vimTenant;
+ }
+
+ public void setVimTenant(String vimTenant) {
+ this.vimTenant = vimTenant;
+ }
+
+ public String getJobId() {
+ return jobId;
+ }
+
+ public void setJobId(String jobId) {
+ this.jobId = jobId;
+ }
+
+ public String getVnfStatus() {
+ return vnfStatus;
+ }
+
+ public void setVnfStatus(String vnfStatus) {
+ this.vnfStatus = vnfStatus;
+ }
+
+ public String getVnfType() {
+ return vnfType;
+ }
+
+ public void setVnfType(String vnfType) {
+ this.vnfType = vnfType;
+ }
+
+ public Integer getMaxVm() {
+ return maxVm;
+ }
+
+ public void setMaxVm(Integer maxVm) {
+ this.maxVm = maxVm;
+ }
+
+ public Integer getMaxCpu() {
+ return maxCpu;
+ }
+
+ public void setMaxCpu(Integer maxCpu) {
+ this.maxCpu = maxCpu;
+ }
+
+ public Integer getMaxDisk() {
+ return maxDisk;
+ }
+
+ public void setMaxDisk(Integer maxDisk) {
+ this.maxDisk = maxDisk;
+ }
+
+ public Integer getMaxRam() {
+ return maxRam;
+ }
+
+ public void setMaxRam(Integer maxRam) {
+ this.maxRam = maxRam;
+ }
+
+ public Integer getMaxShd() {
+ return maxShd;
+ }
+
+ public void setMaxShd(Integer maxShd) {
+ this.maxShd = maxShd;
+ }
+
+ public Integer getMaxNet() {
+ return maxNet;
+ }
+
+ public void setMaxNet(Integer maxNet) {
+ this.maxNet = maxNet;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * <br>
+ *
+ * @param jsonObject
+ * @return
+ * @since NFVO 0.5
+ */
+ public static VnfEntity toEntity(JSONObject jsonObject) {
+ VnfEntity vnfEntity = new VnfEntity();
+ vnfEntity.setId(JsonUtil.getJsonFieldStr(jsonObject, "id"));
+ vnfEntity.setName(JsonUtil.getJsonFieldStr(jsonObject, "name"));
+ vnfEntity.setVnfInstanceId(JsonUtil.getJsonFieldStr(jsonObject, "vnfInstanceId"));
+ vnfEntity.setVnfInstanceName(JsonUtil.getJsonFieldStr(jsonObject, "vnfInstanceName"));
+ vnfEntity.setNsId(JsonUtil.getJsonFieldStr(jsonObject, "nsId"));
+ vnfEntity.setNsName(JsonUtil.getJsonFieldStr(jsonObject, "nsName"));
+ vnfEntity.setVnfmId(JsonUtil.getJsonFieldStr(jsonObject, "vnfmId"));
+ vnfEntity.setVnfmName(JsonUtil.getJsonFieldStr(jsonObject, "vnfmName"));
+ vnfEntity.setVnfPackageName(JsonUtil.getJsonFieldStr(jsonObject, "vnfPackageName"));
+ vnfEntity.setVnfDescriptorName(JsonUtil.getJsonFieldStr(jsonObject, "vnfDescriptorName"));
+ vnfEntity.setVimId(JsonUtil.getJsonFieldStr(jsonObject, "vimId"));
+ vnfEntity.setVimName(JsonUtil.getJsonFieldStr(jsonObject, "vimName"));
+ vnfEntity.setVimTenant(JsonUtil.getJsonFieldStr(jsonObject, "vimTenant"));
+ vnfEntity.setJobId(JsonUtil.getJsonFieldStr(jsonObject, "jobId"));
+ vnfEntity.setVnfStatus(JsonUtil.getJsonFieldStr(jsonObject, "vnfStatus"));
+ vnfEntity.setVnfType(JsonUtil.getJsonFieldStr(jsonObject, "vnfType"));
+ vnfEntity.setMaxVm(JsonUtil.getJsonFieldInt(jsonObject, "maxVm"));
+ vnfEntity.setMaxCpu(JsonUtil.getJsonFieldInt(jsonObject, "maxCpu"));
+ vnfEntity.setMaxDisk(JsonUtil.getJsonFieldInt(jsonObject, "maxDisk"));
+ vnfEntity.setMaxRam(JsonUtil.getJsonFieldInt(jsonObject, "maxRam"));
+ vnfEntity.setMaxShd(JsonUtil.getJsonFieldInt(jsonObject, "maxShd"));
+ vnfEntity.setMaxNet(JsonUtil.getJsonFieldInt(jsonObject, "maxNet"));
+ return vnfEntity;
+ }
+
+ @Override
+ public String toString() {
+ JSONObject vnfResJson = new JSONObject();
+ vnfResJson.put("id", StringUtils.trimToEmpty(this.getId()));
+ vnfResJson.put("name", StringUtils.trimToEmpty(this.getName()));
+ vnfResJson.put("vnfInstanceId", StringUtils.trimToEmpty(this.getName()));
+ vnfResJson.put("vnfInstanceName", StringUtils.trimToEmpty(this.getName()));
+ vnfResJson.put("nsId", StringUtils.trimToEmpty(this.getName()));
+ vnfResJson.put("nsName", StringUtils.trimToEmpty(this.getName()));
+ vnfResJson.put("vnfmId", StringUtils.trimToEmpty(this.getName()));
+ vnfResJson.put("vnfmName", StringUtils.trimToEmpty(this.getName()));
+ vnfResJson.put("vnfPackageName", StringUtils.trimToEmpty(this.getId()));
+ vnfResJson.put("vnfDescriptorName", StringUtils.trimToEmpty(this.getName()));
+ vnfResJson.put("vimId", StringUtils.trimToEmpty(this.getName()));
+ vnfResJson.put("vimName", StringUtils.trimToEmpty(this.getName()));
+ vnfResJson.put("vimTenant", StringUtils.trimToEmpty(this.getName()));
+ vnfResJson.put("jobId", StringUtils.trimToEmpty(this.getName()));
+ vnfResJson.put("vnfStatus", StringUtils.trimToEmpty(this.getName()));
+ vnfResJson.put("vnfType", StringUtils.trimToEmpty(this.getName()));
+ vnfResJson.put("maxVm", StringUtils.trimToEmpty(this.getName()));
+ vnfResJson.put("maxCpu", StringUtils.trimToEmpty(this.getName()));
+ vnfResJson.put("maxDisk", StringUtils.trimToEmpty(this.getName()));
+ vnfResJson.put("maxRam", StringUtils.trimToEmpty(this.getName()));
+ vnfResJson.put("maxShd", StringUtils.trimToEmpty(this.getName()));
+ vnfResJson.put("maxNet", StringUtils.trimToEmpty(this.getName()));
+ return vnfResJson.toString();
+ }
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/VnfInfoEntity.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/VnfInfoEntity.java
new file mode 100644
index 0000000..023f491
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/VnfInfoEntity.java
@@ -0,0 +1,83 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.entity;
+
+import java.io.Serializable;
+
+import org.apache.commons.lang3.StringUtils;
+import org.openo.nfvo.resmanagement.common.util.JsonUtil;
+
+import net.sf.json.JSONObject;
+
+/**
+ * @author l00345485
+ * @date 2016-10-28
+ */
+public class VnfInfoEntity implements Serializable {
+
+ /** */
+ private String vnfInstanceId;
+
+ /** */
+ private String nsId;
+
+ /** */
+ private String vnfmId;
+
+ private static final long serialVersionUID = 1L;
+
+ public String getVnfInstanceId() {
+ return vnfInstanceId;
+ }
+
+ public void setVnfInstanceId(String vnfInstanceId) {
+ this.vnfInstanceId = vnfInstanceId;
+ }
+
+ public String getNsId() {
+ return nsId;
+ }
+
+ public void setNsId(String nsId) {
+ this.nsId = nsId;
+ }
+
+ public String getVnfmId() {
+ return vnfmId;
+ }
+
+ public void setVnfmId(String vnfmId) {
+ this.vnfmId = vnfmId;
+ }
+
+ public static VnfInfoEntity toEntity(JSONObject jsonObject) {
+ VnfInfoEntity vnfInfoEntity = new VnfInfoEntity();
+ vnfInfoEntity.setVnfInstanceId(JsonUtil.getJsonFieldStr(jsonObject, "vnfInstanceId"));
+ vnfInfoEntity.setNsId(JsonUtil.getJsonFieldStr(jsonObject, "nsId"));
+ vnfInfoEntity.setVnfmId(JsonUtil.getJsonFieldStr(jsonObject, "vnfmId"));
+ return vnfInfoEntity;
+ }
+
+ @Override
+ public String toString() {
+ JSONObject vnfInfoResJson = new JSONObject();
+ vnfInfoResJson.put("vnfInstanceId", StringUtils.trimToEmpty(this.getVnfInstanceId()));
+ vnfInfoResJson.put("nsId", StringUtils.trimToEmpty(this.getNsId()));
+ vnfInfoResJson.put("vnfmId", StringUtils.trimToEmpty(this.getVnfmId()));
+ return vnfInfoResJson.toString();
+ }
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/VnfStatusEntity.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/VnfStatusEntity.java
new file mode 100644
index 0000000..290f264
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/entity/VnfStatusEntity.java
@@ -0,0 +1,213 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.entity;
+
+import java.io.Serializable;
+
+import org.apache.commons.lang3.StringUtils;
+import org.openo.nfvo.resmanagement.common.util.JsonUtil;
+
+import net.sf.json.JSONObject;
+
+/**
+ * @author l00345485
+ * @date 2016-10-29
+ */
+public class VnfStatusEntity implements Serializable {
+
+ /** */
+ private String vnfInstanceId;
+
+ /** */
+ private String jobId;
+
+ /** */
+ private String nsId;
+
+ /** */
+ private String vnfmId;
+
+ /** */
+ private String responseDescriptor;
+
+ /** */
+ private String status;
+
+ /** */
+ private String progress;
+
+ /** */
+ private String statusDescription;
+
+ /** */
+ private String errorCode;
+
+ /** */
+ private String responseId;
+
+ /** */
+ private String responseHistoryList;
+
+ /** */
+ private String addVm;
+
+ /** */
+ private String delVm;
+
+ private static final long serialVersionUID = 1L;
+
+ public String getVnfInstanceId() {
+ return vnfInstanceId;
+ }
+
+ public void setVnfInstanceId(String vnfInstanceId) {
+ this.vnfInstanceId = vnfInstanceId;
+ }
+
+ public String getJobId() {
+ return jobId;
+ }
+
+ public void setJobId(String jobId) {
+ this.jobId = jobId;
+ }
+
+ public String getNsId() {
+ return nsId;
+ }
+
+ public void setNsId(String nsId) {
+ this.nsId = nsId;
+ }
+
+ public String getVnfmId() {
+ return vnfmId;
+ }
+
+ public void setVnfmId(String vnfmId) {
+ this.vnfmId = vnfmId;
+ }
+
+ public String getResponseDescriptor() {
+ return responseDescriptor;
+ }
+
+ public void setResponseDescriptor(String responseDescriptor) {
+ this.responseDescriptor = responseDescriptor;
+ }
+
+ public String getStatus() {
+ return status;
+ }
+
+ public void setStatus(String status) {
+ this.status = status;
+ }
+
+ public String getProgress() {
+ return progress;
+ }
+
+ public void setProgress(String progress) {
+ this.progress = progress;
+ }
+
+ public String getStatusDescription() {
+ return statusDescription;
+ }
+
+ public void setStatusDescription(String statusDescription) {
+ this.statusDescription = statusDescription;
+ }
+
+ public String getErrorCode() {
+ return errorCode;
+ }
+
+ public void setErrorCode(String errorCode) {
+ this.errorCode = errorCode;
+ }
+
+ public String getResponseId() {
+ return responseId;
+ }
+
+ public void setResponseId(String responseId) {
+ this.responseId = responseId;
+ }
+
+ public String getResponseHistoryList() {
+ return responseHistoryList;
+ }
+
+ public void setResponseHistoryList(String responseHistoryList) {
+ this.responseHistoryList = responseHistoryList;
+ }
+
+ public String getAddVm() {
+ return addVm;
+ }
+
+ public void setAddVm(String addVm) {
+ this.addVm = addVm;
+ }
+
+ public String getDelVm() {
+ return delVm;
+ }
+
+ public void setDelVm(String delVm) {
+ this.delVm = delVm;
+ }
+
+ public static VnfStatusEntity toEntity(JSONObject jsonObject) {
+ VnfStatusEntity vnfStatusEntity = new VnfStatusEntity();
+ vnfStatusEntity.setVnfInstanceId(JsonUtil.getJsonFieldStr(jsonObject, "vnfInstanceId"));
+ vnfStatusEntity.setJobId(JsonUtil.getJsonFieldStr(jsonObject, "jobId"));
+ vnfStatusEntity.setNsId(JsonUtil.getJsonFieldStr(jsonObject, "nsId"));
+ vnfStatusEntity.setVnfmId(JsonUtil.getJsonFieldStr(jsonObject, "vnfmId"));
+ vnfStatusEntity.setResponseDescriptor(JsonUtil.getJsonFieldStr(jsonObject, "responseDescriptor"));
+ vnfStatusEntity.setStatus(JsonUtil.getJsonFieldStr(jsonObject, "status"));
+ vnfStatusEntity.setProgress(JsonUtil.getJsonFieldStr(jsonObject, "progress"));
+ vnfStatusEntity.setStatusDescription(JsonUtil.getJsonFieldStr(jsonObject, "statusDescription"));
+ vnfStatusEntity.setErrorCode(JsonUtil.getJsonFieldStr(jsonObject, "errorCode"));
+ vnfStatusEntity.setResponseId(JsonUtil.getJsonFieldStr(jsonObject, "responseId"));
+ vnfStatusEntity.setResponseHistoryList(JsonUtil.getJsonFieldStr(jsonObject, "responseHistoryList"));
+ vnfStatusEntity.setAddVm(JsonUtil.getJsonFieldStr(jsonObject, "addVm"));
+ vnfStatusEntity.setDelVm(JsonUtil.getJsonFieldStr(jsonObject, "delVm"));
+ return vnfStatusEntity;
+ }
+
+ @Override
+ public String toString() {
+ JSONObject vnfStatusResJson = new JSONObject();
+ vnfStatusResJson.put("vnfInstanceId", StringUtils.trimToEmpty(this.getVnfInstanceId()));
+ vnfStatusResJson.put("jobId", StringUtils.trimToEmpty(this.getJobId()));
+ vnfStatusResJson.put("nsId", StringUtils.trimToEmpty(this.getNsId()));
+ vnfStatusResJson.put("vnfmId", StringUtils.trimToEmpty(this.getVnfmId()));
+ vnfStatusResJson.put("responseDescriptor", StringUtils.trimToEmpty(this.getResponseDescriptor()));
+ vnfStatusResJson.put("status", StringUtils.trimToEmpty(this.getStatus()));
+ vnfStatusResJson.put("progress", StringUtils.trimToEmpty(this.getProgress()));
+ vnfStatusResJson.put("statusDescription", StringUtils.trimToEmpty(this.getStatusDescription()));
+ vnfStatusResJson.put("errorCode", StringUtils.trimToEmpty(this.getErrorCode()));
+ vnfStatusResJson.put("responseId", StringUtils.trimToEmpty(this.getResponseId()));
+ vnfStatusResJson.put("responseHistoryList", StringUtils.trimToEmpty(this.getResponseHistoryList()));
+ vnfStatusResJson.put("addVm", StringUtils.trimToEmpty(this.getAddVm()));
+ vnfStatusResJson.put("delVm", StringUtils.trimToEmpty(this.getDelVm()));
+ return vnfStatusResJson.toString();
+ }
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/GrantResServiceImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/GrantResServiceImpl.java
new file mode 100644
index 0000000..4a8a633
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/GrantResServiceImpl.java
@@ -0,0 +1,206 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.group.impl;
+
+import org.openo.baseservice.remoteservice.exception.ServiceException;
+import org.openo.nfvo.resmanagement.common.VimUtil;
+import org.openo.nfvo.resmanagement.service.base.openstack.inf.Sites;
+import org.openo.nfvo.resmanagement.service.group.inf.GrantResService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import net.sf.json.JSONArray;
+import net.sf.json.JSONObject;
+
+/**
+ * <br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Oct 29, 2016
+ */
+public class GrantResServiceImpl implements GrantResService {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(GrantResServiceImpl.class);
+
+ private Sites sites;
+
+ /**
+ * <br>
+ *
+ * @param object
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ @Override
+ public JSONObject grantResource(JSONObject object) throws ServiceException {
+ LOGGER.info("function=grantResource; object: {}", object.toString());
+ JSONObject additionalparam = object.getJSONObject("additionalParam");
+ String vimId = additionalparam.getString("vimid");
+ JSONObject vimJson = VimUtil.getVimById(vimId);
+ String tenant = vimJson.getString("tenant");
+ JSONObject accessinfo = new JSONObject();
+ accessinfo.put("tenant", tenant);
+ JSONObject vim = new JSONObject();
+ vim.put("vimid", vimId);
+ vim.put("accessinfo", accessinfo);
+ LOGGER.info("function=grantResource; vim: {}", vim.toString());
+ JSONObject result = new JSONObject();
+ result.put("vim", vim);
+ return result;
+ }
+
+ @Override
+ public JSONObject grantResourceReal(JSONObject object) throws ServiceException {
+ LOGGER.info("function=grantResource; object: {}", object.toString());
+ String vimId = object.getString("vimId");
+ JSONObject vimJson = VimUtil.getVimById(vimId);
+ JSONObject vim = parseVim(vimJson);
+ String resType = "";
+ JSONArray resArr = new JSONArray();
+ if(object.containsKey("addResource")) {
+ resType = "addResource";
+ resArr = parseResource(object, resType);
+ } else if(object.containsKey("removeResource")) {
+ resType = "removeResource";
+ resArr = parseResource(object, resType);
+ }
+ JSONObject resInfo = getResInfo(object, resType);
+ resInfo.put("vimId", vimId);
+ sites.update(resInfo);
+
+ JSONObject result = new JSONObject();
+ result.put("vim", vim);
+ result.put("zone", "");
+ result.put("zoneGroup", "");
+ result.put(resType, resArr);
+ result.put("tempResource", "");
+ result.put("updateResource", "");
+ result.put("vimAssets", new JSONObject());
+ result.put("additionalParam", "");
+ LOGGER.info("function=grantResource; result: {}", result.toString());
+ return result;
+ }
+
+ private JSONObject getResInfo(JSONObject object, String type) {
+ JSONArray arr = object.getJSONArray(type);
+ LOGGER.info("function=getResInfo; arr: {}, type: {}", arr, type);
+ JSONObject resourceObj = new JSONObject();
+ if("addResource".equals(type)) {
+ resourceObj = getGrantResource(arr);
+ resourceObj.put("action", "online");
+ } else if("removeResource".equals(type)) {
+ resourceObj = getGrantResource(arr);
+ resourceObj.put("action", "offline");
+ }
+ LOGGER.info("function=getResInfo; resutl: {}", resourceObj.toString());
+ return resourceObj;
+ }
+
+ /**
+ * <br>
+ *
+ * @param addResource
+ * @return
+ * @since NFVO 0.5
+ */
+ private JSONObject getGrantResource(JSONArray resource) {
+ int cpuNum = 0;
+ int memNum = 0;
+ int diskNum = 0;
+ for(int i = 0; i < resource.size(); i++) {
+ JSONObject res = resource.getJSONObject(i);
+ JSONObject vCpu = res.getJSONObject("resourceTemplate").getJSONObject("virtualComputeDescriptor")
+ .getJSONObject("virtualCpu");
+ int vCpuNum = vCpu.getInt("numVirtualCpu");
+ JSONObject vMem = res.getJSONObject("resourceTemplate").getJSONObject("virtualComputeDescriptor")
+ .getJSONObject("virtualMemory");
+ int vMemNum = vMem.getInt("virtualMemSize");
+ JSONObject vDisk = res.getJSONObject("resourceTemplate").getJSONObject("virtualStorageDescriptor");
+ int vDiskNum = vDisk.getInt("sizeOfStorage");
+ cpuNum = cpuNum + vCpuNum;
+ memNum = memNum + vMemNum;
+ diskNum = diskNum + vDiskNum;
+ }
+ JSONObject obj = new JSONObject();
+ obj.put("usedCPU", String.valueOf(cpuNum));
+ obj.put("usedMemory", String.valueOf(memNum));
+ obj.put("usedDisk", String.valueOf(diskNum));
+ return obj;
+ }
+
+ /**
+ * <br>
+ *
+ * @param object
+ * @return
+ * @since NFVO 0.5
+ */
+ private JSONArray parseResource(JSONObject object, String key) {
+ JSONArray newResources = new JSONArray();
+ JSONArray oldResource = object.getJSONArray(key);
+ LOGGER.info("function=parseResource; Resource: {}", oldResource.toString());
+ for(int i = 0; i < oldResource.size(); i++) {
+ JSONObject res = oldResource.getJSONObject(i);
+ JSONObject obj = new JSONObject();
+ obj.put("reservationId", "");
+ obj.put("resourceProviderId", "");
+ obj.put("zoneId", "");
+ obj.put("vimId", object.getString("vimId"));
+ obj.put("resourceDefinitionId", res.getString("resourceDefinitionId"));
+ newResources.add(obj);
+ }
+ LOGGER.info("function=parseResource; Parse Resource result: {}", newResources.toString());
+ return newResources;
+ }
+
+ /**
+ * <br>
+ *
+ * @param vimJson
+ * @return
+ * @since NFVO 0.5
+ */
+ private JSONObject parseVim(JSONObject vimJson) {
+ LOGGER.info("function=grantResource; vimJson: {}", vimJson.toString());
+ JSONObject interfaceInfo = new JSONObject();
+ interfaceInfo.put("vimType", vimJson.getString("type"));
+ interfaceInfo.put("apiVersion", "v2");
+ interfaceInfo.put("protocolType", "http");
+ JSONObject accessInfo = new JSONObject();
+ accessInfo.put("tenant", vimJson.getString("tenant"));
+ accessInfo.put("username", vimJson.getString("userName"));
+ accessInfo.put("password", vimJson.getString("password"));
+ JSONObject vim = new JSONObject();
+ vim.put("vimInfoId", vimJson.getString("vimId"));
+ vim.put("vimId", vimJson.getString("vimId"));
+ vim.put("interfaceInfo", interfaceInfo);
+ vim.put("accessInfo", accessInfo);
+ vim.put("interfaceEndpoint", vimJson.getString("url"));
+ return vim;
+ }
+
+ /**
+ * @param sites The sites to set.
+ */
+ public void setSites(Sites sites) {
+ this.sites = sites;
+ }
+
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/IResourceAddServiceImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/IResourceAddServiceImpl.java
new file mode 100644
index 0000000..0699b98
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/IResourceAddServiceImpl.java
@@ -0,0 +1,159 @@
+/*
+ * Copyright 2016-2017 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.group.impl;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.openo.baseservice.remoteservice.exception.ServiceException;
+import org.openo.baseservice.roa.util.restclient.RestfulParametes;
+import org.openo.nfvo.resmanagement.common.constant.ParamConstant;
+import org.openo.nfvo.resmanagement.common.constant.UrlConstant;
+import org.openo.nfvo.resmanagement.common.util.JsonUtil;
+import org.openo.nfvo.resmanagement.common.util.RestfulUtil;
+import org.openo.nfvo.resmanagement.service.base.openstack.inf.InterfaceResManagement;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.transaction.annotation.Transactional;
+
+import net.sf.json.JSONArray;
+import net.sf.json.JSONObject;
+
+/**
+ * iResource add service implementation.<br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Sep 10, 2016
+ */
+public class IResourceAddServiceImpl {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(IResourceAddServiceImpl.class);
+
+ /**
+ * Add iResource.<br>
+ *
+ * @param restParametes
+ * @param iResMap
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ @Transactional(rollbackFor = ServiceException.class)
+ public void addIRes(RestfulParametes restParametes, Map<String, InterfaceResManagement> iResMap)
+ throws ServiceException {
+ addIResources(iResMap, createResUrlMap(), restParametes);
+ }
+
+ private void addIResources(Map<String, InterfaceResManagement> iResMap, HashMap<String, String> urlMap,
+ RestfulParametes restParametes) throws ServiceException {
+ for(String iResName : iResMap.keySet()) {
+ if(ParamConstant.PARAM_HOST.equals(iResName)) {
+ addHostResource(iResMap, restParametes, String.format(urlMap.get(iResName),
+ restParametes.get(ParamConstant.PARAM_VIMID), restParametes.get(ParamConstant.PARAM_TENANTID)),
+ iResName);
+ } else {
+ String url = String.format(urlMap.get(iResName), restParametes.get(ParamConstant.PARAM_VIMID),
+ restParametes.get(ParamConstant.PARAM_TENANTID));
+ JSONArray iResArray = RestfulUtil.getResponseRes(new RestfulParametes(), url, iResName);
+ LOGGER.warn("function=addIResources; iResArray={}", iResArray);
+ for(Object object : iResArray) {
+ JSONObject iRes = JSONObject.fromObject(object);
+ int result = iResMap.get(iResName).add(iRes);
+ LOGGER.warn("function=addIResources; msg=iRes name is [{}],result is [{}]", iResName, result);
+ }
+ }
+ }
+ }
+
+ /**
+ * Add Host Resource.<br>
+ *
+ * @param iResMap
+ * @param restParametes
+ * @param url
+ * @param iResName
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ public static void addHostResource(Map<String, InterfaceResManagement> iResMap, RestfulParametes restParametes,
+ String url, String iResName) throws ServiceException {
+ JSONArray hostResArray = RestfulUtil.getResponseRes(new RestfulParametes(), url, iResName);
+ LOGGER.warn("function=addHostResource; hostResArray={}", hostResArray);
+ for(Object object : hostResArray) {
+ JSONObject hostRes = JSONObject.fromObject(object);
+ String hostZone = hostRes.getString("zone");
+ if("internal".equals(hostZone)) {
+ continue;
+ }
+ String hostName = hostRes.getString("name");
+ String hostUrl = String.format(UrlConstant.GET_HOSTDETAIL_URL, restParametes.get(ParamConstant.PARAM_VIMID),
+ restParametes.get(ParamConstant.PARAM_TENANTID), hostName);
+
+ String result = RestfulUtil.getResponseContent(hostUrl, new RestfulParametes(), ParamConstant.PARAM_GET);
+ if(result == null) {
+ continue;
+ }
+ JSONObject hostObj = JSONObject.fromObject(result);
+ JSONObject host = hostDataParse(hostObj, hostName);
+ int res = iResMap.get(iResName).add(host);
+ LOGGER.warn("function=addHostResource; result={}, res={}", result, res);
+ if(res < 0) {
+ LOGGER.error("function=addHostResource; add into DB fail!");
+ }
+
+ }
+ }
+
+ /**
+ * <br>
+ *
+ * @param hostObj
+ * @param hostName
+ * @return
+ * @since NFVO 0.5
+ */
+ public static JSONObject hostDataParse(JSONObject hostObj, String hostName) {
+ LOGGER.warn("function=hostDataParse; hostObj={}, hostName={}", hostObj, hostName);
+ JSONArray hostArray = hostObj.getJSONArray("host");
+ for(Object object : hostArray) {
+ JSONObject hostObject = JSONObject.fromObject(object);
+ if(hostObject.getString("project").contains("total")) {
+ String vimId = JsonUtil.getJsonFieldStr(hostObj, "vimId");
+ String hostId = vimId + hostName;
+ JSONObject host = new JSONObject();
+ host.put("id", hostId);
+ host.put("name", hostName);
+ host.put("cpu", JsonUtil.getJsonFieldStr(hostObject, "cpu"));
+ host.put("memory", JsonUtil.getJsonFieldStr(hostObject, "memory_mb"));
+ host.put("disk", JsonUtil.getJsonFieldStr(hostObject, "disk_gb"));
+ host.put("vimId", JsonUtil.getJsonFieldStr(hostObj, "vimId"));
+ host.put("vimName", JsonUtil.getJsonFieldStr(hostObj, "vimName"));
+ return host;
+ }
+ }
+ return new JSONObject();
+ }
+
+ private HashMap<String, String> createResUrlMap() {
+ HashMap<String, String> urlMap = new HashMap<String, String>(10);
+ urlMap.put(ParamConstant.PARAM_NETWORK, UrlConstant.GET_NETWORK_URL);
+ urlMap.put(ParamConstant.PARAM_HOST, UrlConstant.GET_HOST_URL);
+ urlMap.put(ParamConstant.PARAM_PORT, UrlConstant.GET_PORT_URL);
+ return urlMap;
+ }
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/IResourceDelServiceImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/IResourceDelServiceImpl.java
new file mode 100644
index 0000000..59cff09
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/IResourceDelServiceImpl.java
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.group.impl;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.openo.baseservice.remoteservice.exception.ServiceException;
+import org.openo.nfvo.resmanagement.common.ResourceUtil;
+import org.openo.nfvo.resmanagement.common.constant.ParamConstant;
+import org.openo.nfvo.resmanagement.service.base.openstack.inf.InterfaceResManagement;
+import org.openo.nfvo.resmanagement.service.base.openstack.inf.Vim;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ *
+ * iResource delete service implementation.<br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Sep 10, 2016
+ */
+public class IResourceDelServiceImpl {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(IResourceDelServiceImpl.class);
+
+ /**
+ *
+ * Delete iResource.<br>
+ *
+ * @param vimId
+ * @param iResMap
+ * @param vim
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ public int deleteIRes(String vimId, Map<String, InterfaceResManagement> iResMap, Vim vim) throws ServiceException {
+ Map<String, Object> map = new HashMap<>(10);
+ map.put(ParamConstant.PARAM_VIMID, vimId);
+
+ checkIResDelResult(vimId, iResMap);
+ return vim.delete(vimId);
+ }
+
+ private void checkIResDelResult(String vimId, Map<String, InterfaceResManagement> iResMap) throws ServiceException {
+ for(String keyName : iResMap.keySet()) {
+ if(iResMap.get(keyName).deleteResByVimId(vimId) < 0) {
+ LOGGER.error("function=checkIResDelResult; msg=delete {} failed,", keyName);
+ throw new ServiceException(
+ ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.group.resoperate.add.res.delete.fail")
+ + keyName);
+ }
+ LOGGER.warn("function=checkIResDelResult; msg=delete {} success", keyName);
+ }
+
+ }
+
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/IResourceUpdateServiceImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/IResourceUpdateServiceImpl.java
new file mode 100644
index 0000000..b789bf9
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/IResourceUpdateServiceImpl.java
@@ -0,0 +1,120 @@
+/*
+ * Copyright 2016-2017 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.group.impl;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.openo.baseservice.remoteservice.exception.ServiceException;
+import org.openo.baseservice.roa.util.restclient.RestfulParametes;
+import org.openo.nfvo.resmanagement.common.constant.ParamConstant;
+import org.openo.nfvo.resmanagement.common.constant.UrlConstant;
+import org.openo.nfvo.resmanagement.common.util.RestfulUtil;
+import org.openo.nfvo.resmanagement.service.base.openstack.inf.InterfaceResManagement;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.transaction.annotation.Transactional;
+
+import net.sf.json.JSONArray;
+import net.sf.json.JSONObject;
+
+/**
+ * iResource update service implementation class.<br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Sep 10, 2016
+ */
+public class IResourceUpdateServiceImpl {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(IResourceUpdateServiceImpl.class);
+
+ /**
+ * Update iResource.<br>
+ *
+ * @param vimId
+ * @param restParametes
+ * @param iResMap
+ * @param sites
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ @Transactional(rollbackFor = ServiceException.class)
+ public void updateIRes(String vimId, RestfulParametes restParametes, Map<String, InterfaceResManagement> iResMap)
+ throws ServiceException {
+
+ updateIResByName(iResMap, createResUrlMap(), restParametes, vimId);
+ }
+
+ private void updateIResByName(Map<String, InterfaceResManagement> iResMap, HashMap<String, String> updateUrlMap,
+ RestfulParametes restParametes, String vimId) throws ServiceException {
+ for(String resName : updateUrlMap.keySet()) {
+ if(ParamConstant.PARAM_HOST.equals(resName)) {
+ updateHostResource(iResMap, restParametes, String.format(updateUrlMap.get(resName),
+ restParametes.get(ParamConstant.PARAM_VIMID), restParametes.get(ParamConstant.PARAM_TENANTID)),
+ resName);
+ } else if(iResMap.get(resName).deleteResByVimId(vimId) >= 0) {
+ String url = String.format(updateUrlMap.get(resName), restParametes.get(ParamConstant.PARAM_VIMID),
+ restParametes.get(ParamConstant.PARAM_TENANTID));
+ JSONArray iResArray = RestfulUtil.getResponseRes(new RestfulParametes(), url, resName);
+ LOGGER.warn("function=addIResources; iResArray={}", iResArray);
+ for(Object object : iResArray) {
+ JSONObject iRes = JSONObject.fromObject(object);
+ int result = iResMap.get(resName).add(iRes);
+ LOGGER.warn("function=updateIResByName; msg=iRes name is [{}],result is [{}]", resName, result);
+
+ }
+ }
+ }
+ }
+
+ private void updateHostResource(Map<String, InterfaceResManagement> iResMap, RestfulParametes restParametes,
+ String url, String iResName) throws ServiceException {
+
+ JSONArray hostResArray = RestfulUtil.getResponseRes(new RestfulParametes(), url, iResName);
+ LOGGER.warn("function=updateHostResource; hostResArray={}", hostResArray);
+ for(Object object : hostResArray) {
+ JSONObject hostRes = JSONObject.fromObject(object);
+ String hostZone = hostRes.getString("zone");
+ if("internal".equals(hostZone)) {
+ continue;
+ }
+ String hostName = hostRes.getString("name");
+ String hostUrl = String.format(UrlConstant.GET_HOSTDETAIL_URL, restParametes.get(ParamConstant.PARAM_VIMID),
+ restParametes.get(ParamConstant.PARAM_TENANTID), hostName);
+
+ String result = RestfulUtil.getResponseContent(hostUrl, new RestfulParametes(), ParamConstant.PARAM_GET);
+ JSONObject hostObj = JSONObject.fromObject(result);
+ JSONObject host = IResourceAddServiceImpl.hostDataParse(hostObj, hostName);
+ int res = iResMap.get(ParamConstant.PARAM_HOST).update(host);
+ LOGGER.warn("function=updateHostResource; result={}, res={}", result, res);
+ if(res < 0) {
+ LOGGER.error("function=updateHostResource; add into DB fail!");
+ }
+
+ }
+ }
+
+ private HashMap<String, String> createResUrlMap() {
+ HashMap<String, String> updateUrlMap = new HashMap<String, String>(10);
+ updateUrlMap.put(ParamConstant.PARAM_NETWORK, UrlConstant.GET_NETWORK_URL);
+ updateUrlMap.put(ParamConstant.PARAM_HOST, UrlConstant.GET_HOST_URL);
+ updateUrlMap.put(ParamConstant.PARAM_PORT, UrlConstant.GET_PORT_URL);
+ return updateUrlMap;
+ }
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/ResOperateServiceImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/ResOperateServiceImpl.java
new file mode 100644
index 0000000..788e487
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/ResOperateServiceImpl.java
@@ -0,0 +1,257 @@
+/*
+ * Copyright 2016-2017 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.group.impl;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.lang3.StringUtils;
+import org.openo.baseservice.remoteservice.exception.ServiceException;
+import org.openo.baseservice.roa.util.restclient.RestfulParametes;
+import org.openo.nfvo.resmanagement.common.ResourceUtil;
+import org.openo.nfvo.resmanagement.common.constant.Constant;
+import org.openo.nfvo.resmanagement.common.constant.ParamConstant;
+import org.openo.nfvo.resmanagement.common.constant.UrlConstant;
+import org.openo.nfvo.resmanagement.common.util.JsonUtil;
+import org.openo.nfvo.resmanagement.common.util.RestfulUtil;
+import org.openo.nfvo.resmanagement.common.util.StringUtil;
+import org.openo.nfvo.resmanagement.service.base.openstack.inf.Host;
+import org.openo.nfvo.resmanagement.service.base.openstack.inf.InterfaceResManagement;
+import org.openo.nfvo.resmanagement.service.base.openstack.inf.Network;
+import org.openo.nfvo.resmanagement.service.base.openstack.inf.Port;
+import org.openo.nfvo.resmanagement.service.base.openstack.inf.Sites;
+import org.openo.nfvo.resmanagement.service.base.openstack.inf.Vim;
+import org.openo.nfvo.resmanagement.service.entity.HostEntity;
+import org.openo.nfvo.resmanagement.service.entity.VimEntity;
+import org.openo.nfvo.resmanagement.service.group.inf.ResOperateService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.transaction.annotation.Transactional;
+
+import net.sf.json.JSONArray;
+import net.sf.json.JSONObject;
+
+/**
+ * Resource operation service implementation class.<br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Sep 10, 2016
+ */
+public class ResOperateServiceImpl implements ResOperateService {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(ResOperateServiceImpl.class);
+
+ private Sites sites;
+
+ private Network network;
+
+ private Host host;
+
+ private Port port;
+
+ private Vim vim;
+
+ private IResourceAddServiceImpl iResourceAddServiceImpl;
+
+ private IResourceUpdateServiceImpl iResourceUpdateServiceImpl;
+
+ private IResourceDelServiceImpl iResourceDelServiceImpl;
+
+ @Override
+ @Transactional(rollbackFor = ServiceException.class)
+ public void addIRes(String tenantId, String vimId, JSONObject header) throws ServiceException {
+ LOGGER.warn("function=addIRes; msg=add IResource by vimId:[{}], tenantId:[{}]", vimId, tenantId);
+ if(!StringUtil.isValidString(vimId) || !StringUtil.isValidString(tenantId)) {
+ LOGGER.warn("function=addIRes; msg=vimId[{}] is valid", vimId);
+ throw new ServiceException(
+ ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.group.resoperate.add.res.no.vimId"));
+ }
+
+ RestfulParametes restParametes = createRestfulParametes(tenantId, vimId, header);
+ HashMap<String, InterfaceResManagement> iResMap = createMap();
+
+ if(vim.add(vimId) <= 0) {
+ LOGGER.error("VimId exists");
+ throw new ServiceException("VimId exists");
+ }
+
+ iResourceAddServiceImpl.addIRes(restParametes, iResMap);
+ }
+
+ @Override
+ @Transactional(rollbackFor = ServiceException.class)
+ public void updateIRes(String tenantId, String vimId, JSONObject header) throws ServiceException {
+ if(!StringUtil.isValidString(vimId)) {
+ LOGGER.error("function=updateIRes; msg=vimId is not exist");
+ throw new ServiceException(
+ ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.group.resoperate.update.res.no.vimId"));
+ }
+
+ RestfulParametes restParametes = createRestfulParametes(tenantId, vimId, header);
+ HashMap<String, InterfaceResManagement> iResMap = createMap();
+ iResourceUpdateServiceImpl.updateIRes(vimId, restParametes, iResMap);
+ }
+
+ @Override
+ public void updateAllIRes() throws ServiceException {
+ LOGGER.warn("function=updateAllIRes; msg=update all IResource");
+ List<VimEntity> vims = vim.getList();
+ if(vims.isEmpty()) {
+ LOGGER.error("function=updateAllIRes; msg=vimId is not exist");
+ throw new ServiceException(
+ ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.group.resoperate.update.res.no.vimId"));
+ }
+ for(VimEntity vimEntity : vims) {
+ String vimId = vimEntity.getId();
+ LOGGER.warn("function=updateAllIRes; msg=start update vimId:{}", vimId);
+ updateIRes(null, vimId, new JSONObject());
+ }
+ }
+
+ @Override
+ @Transactional(rollbackFor = ServiceException.class)
+ public int deleteIRes(String vimId) throws ServiceException {
+ LOGGER.warn("function=deleteAllRes; msg=deleteResPool vimId: {}", vimId);
+ if(StringUtils.isEmpty(vimId)) {
+ LOGGER.error("function=deleteAllRes; msg=vimId is null");
+ throw new ServiceException(
+ ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.group.resoperate.res.no.vimId"));
+ }
+
+ return iResourceDelServiceImpl.deleteIRes(vimId, createMap(), vim);
+ }
+
+ private RestfulParametes createRestfulParametes(String tenantId, String vimId, JSONObject header) {
+ RestfulParametes restParametes = new RestfulParametes();
+ restParametes.put("vimId", vimId);
+ restParametes.put("tenantId", tenantId);
+ restParametes.putHttpContextHeader("Content-Type", "application/json");
+ JSONObject headers = JsonUtil.getJsonFieldJson(header, "header");
+ if(null == headers || !headers.has("x-auth-token")) {
+ String token = "TestToken";
+ LOGGER.warn("function=createRestfulParametes; msg=create token.");
+ restParametes.putHttpContextHeader(Constant.IAM_AUTH_TOKEN, token);
+ return restParametes;
+ }
+ restParametes.putHttpContextHeader(Constant.IAM_AUTH_TOKEN,
+ JsonUtil.getJsonFieldStr(headers, Constant.IAM_AUTH_TOKEN));
+ return restParametes;
+ }
+
+ private HashMap<String, InterfaceResManagement> createMap() {
+ HashMap<String, InterfaceResManagement> iResMap = new HashMap<String, InterfaceResManagement>(10);
+ iResMap.put(ParamConstant.PARAM_NETWORK, network);
+ iResMap.put(ParamConstant.PARAM_HOST, host);
+ iResMap.put(ParamConstant.PARAM_PORT, port);
+ return iResMap;
+ }
+
+ public void setSites(Sites sites) {
+ this.sites = sites;
+ }
+
+ public void setNetwork(Network network) {
+ this.network = network;
+ }
+
+ public void setHost(Host host) {
+ this.host = host;
+ }
+
+ public void setPort(Port port) {
+ this.port = port;
+ }
+
+ public void setVim(Vim vim) {
+ this.vim = vim;
+ }
+
+ /**
+ * Set iResource Add service implemtation.<br>
+ *
+ * @param iResourceAddServiceImpl
+ * @since NFVO 0.5
+ */
+ public void setiResourceAddServiceImpl(IResourceAddServiceImpl iResourceAddServiceImpl) {
+ this.iResourceAddServiceImpl = iResourceAddServiceImpl;
+ }
+
+ /**
+ * Set iResource update service implementation.<br>
+ *
+ * @param iResourceUpdateServiceImpl
+ * @since NFVO 0.5
+ */
+ public void setiResourceUpdateServiceImpl(IResourceUpdateServiceImpl iResourceUpdateServiceImpl) {
+ this.iResourceUpdateServiceImpl = iResourceUpdateServiceImpl;
+ }
+
+ /**
+ * Set iresource delete service implementation.<br>
+ *
+ * @param iResourceDelServiceImpl
+ * @since NFVO 0.5
+ */
+ public void setiResourceDelServiceImpl(IResourceDelServiceImpl iResourceDelServiceImpl) {
+ this.iResourceDelServiceImpl = iResourceDelServiceImpl;
+ }
+
+ /**
+ * <br>
+ *
+ * @param string
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ @Override
+ public void sendMsgMonitor(String operateType, String vimId) throws ServiceException {
+ LOGGER.info("Enter sendMsgMonitor!");
+ Map<String, Object> map = new HashMap<>(10);
+ map.put("vimId", vimId);
+ List<HostEntity> hosts = host.getList(map);
+ for(HostEntity entity : hosts) {
+ JSONObject msgObj = new JSONObject();
+ msgObj.put("operationType", operateType);
+ msgObj.put("resourceType", "HOST");
+ msgObj.put("label", entity.getName());
+ if("delete".equals(operateType)) {
+ JSONArray deleteIds = new JSONArray();
+ deleteIds.add(entity.getId());
+ msgObj.put("deleteIds", deleteIds);
+ } else {
+ JSONArray data = new JSONArray();
+ JSONObject obj = JSONObject.fromObject(entity);
+ obj.put("oid", entity.getId());
+ obj.put("moc", "nfv.host.linux");
+ data.add(obj);
+ msgObj.put("data", data);
+ }
+ RestfulParametes restfulParametes = new RestfulParametes();
+ Map<String, String> headerMap = new HashMap<>(3);
+ headerMap.put("Content-Type", "application/json");
+ restfulParametes.setHeaderMap(headerMap);
+ restfulParametes.setRawData(msgObj.toString());
+ LOGGER.info("sendMsgMonitor msgObj: {}", msgObj);
+ String result = RestfulUtil.getResponseContent(UrlConstant.SEND_MSG_MONITOR, restfulParametes,
+ ParamConstant.PARAM_POST);
+ LOGGER.warn(result);
+ }
+ }
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/VirtualLinkServiceImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/VirtualLinkServiceImpl.java
new file mode 100644
index 0000000..5dd726c
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/VirtualLinkServiceImpl.java
@@ -0,0 +1,123 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.group.impl;
+
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+import org.apache.commons.lang3.StringUtils;
+import org.openo.baseservice.remoteservice.exception.ServiceException;
+import org.openo.nfvo.resmanagement.common.ResourceUtil;
+import org.openo.nfvo.resmanagement.service.dao.inf.VirtualLinkDao;
+import org.openo.nfvo.resmanagement.service.entity.VirtualLinkEntity;
+import org.openo.nfvo.resmanagement.service.group.inf.VirtualLinkService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import net.sf.json.JSONObject;
+
+/**
+ * <br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Oct 27, 2016
+ */
+public class VirtualLinkServiceImpl implements VirtualLinkService {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(VirtualLinkServiceImpl.class);
+
+ private VirtualLinkDao virtualLinkDao;
+
+ /**
+ * <br>
+ *
+ * @param virtualLinkEntity
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ @Override
+ public JSONObject addVl(VirtualLinkEntity virtualLinkEntity) throws ServiceException {
+ if(!checkId(virtualLinkEntity.getId())) {
+ LOGGER.error("function=addVl; msg=add error, because id is already exist.");
+ throw new ServiceException(ResourceUtil
+ .getMessage("org.openo.nfvo.resmanagement.service.group.impl.VirtualLinkServiceImpl.add.id.check"));
+ }
+ if(StringUtils.isEmpty(virtualLinkEntity.getId())) {
+ virtualLinkEntity.setId(UUID.randomUUID().toString());
+ }
+ int result = virtualLinkDao.addVl(virtualLinkEntity);
+ JSONObject restJson = new JSONObject();
+ if(result > 0) {
+ restJson.put("id", virtualLinkEntity.getId());
+ restJson.put("name", virtualLinkEntity.getName());
+ } else {
+ LOGGER.error("function=addVl; msg=add vl into DB error.");
+ restJson.put("message", "Add Vl into DB error.");
+ }
+ return restJson;
+
+ }
+
+ /**
+ * <br>
+ *
+ * @param id
+ * @return
+ * @since NFVO 0.5
+ */
+ private boolean checkId(String id) {
+ VirtualLinkEntity vl = virtualLinkDao.getVl(id);
+ if(null == vl) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * <br>
+ *
+ * @param map
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ @Override
+ public List<VirtualLinkEntity> getList(Map<String, Object> map) throws ServiceException {
+ return virtualLinkDao.getVls(map);
+ }
+
+ /**
+ * <br>
+ *
+ * @param id
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ @Override
+ public int delete(String id) throws ServiceException {
+ return virtualLinkDao.deleteVlById(id);
+ }
+
+ public void setVirtualLinkDao(VirtualLinkDao virtualLinkDao) {
+ this.virtualLinkDao = virtualLinkDao;
+ }
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/VmServiceImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/VmServiceImpl.java
new file mode 100644
index 0000000..51ec0dd
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/VmServiceImpl.java
@@ -0,0 +1,177 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.group.impl;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+import org.apache.commons.lang3.StringUtils;
+import org.openo.baseservice.remoteservice.exception.ServiceException;
+import org.openo.baseservice.roa.util.restclient.RestfulParametes;
+import org.openo.nfvo.resmanagement.common.constant.ParamConstant;
+import org.openo.nfvo.resmanagement.common.constant.UrlConstant;
+import org.openo.nfvo.resmanagement.common.util.RestfulUtil;
+import org.openo.nfvo.resmanagement.service.dao.inf.VmDao;
+import org.openo.nfvo.resmanagement.service.entity.VmEntity;
+import org.openo.nfvo.resmanagement.service.group.inf.VmService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import net.sf.json.JSONArray;
+import net.sf.json.JSONObject;
+
+/**
+ * <br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Oct 29, 2016
+ */
+public class VmServiceImpl implements VmService {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(VmServiceImpl.class);
+
+ private VmDao vmDao;
+
+ /**
+ * <br>
+ *
+ * @param vmEntity
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ @Override
+ public JSONObject addVm(VmEntity vmEntity) throws ServiceException {
+ int result;
+ if(!checkId(vmEntity.getVmId())) {
+ result = vmDao.updateVm(vmEntity);
+ sendMsgMonitor("create", vmEntity);
+ } else {
+ if(StringUtils.isEmpty(vmEntity.getVmId())) {
+ vmEntity.setVmId(UUID.randomUUID().toString());
+ }
+ result = vmDao.addVm(vmEntity);
+ sendMsgMonitor("update", vmEntity);
+ }
+ JSONObject restJson = new JSONObject();
+ if(result > 0) {
+ restJson.put("id", vmEntity.getVmId());
+ restJson.put("name", vmEntity.getVmName());
+ } else {
+ LOGGER.error("function=addVm; msg=add vm into DB error.");
+ restJson.put("message", "Add vm into DB error.");
+ }
+ return restJson;
+ }
+
+ /**
+ * <br>
+ *
+ * @param vmId
+ * @return
+ * @since NFVO 0.5
+ */
+ private boolean checkId(String vmId) {
+ VmEntity vm = vmDao.getVm(vmId);
+ if(null == vm) {
+ return true;
+ }
+ return false;
+ }
+
+ public void sendMsgMonitor(String operateType, VmEntity vmEntity) throws ServiceException {
+ JSONObject msgObj = new JSONObject();
+ msgObj.put("operationType", operateType);
+ msgObj.put("resourceType", "VDU");
+ msgObj.put("label", vmEntity.getVmName());
+ if("delete".equals(operateType)) {
+ JSONArray deleteIds = new JSONArray();
+ deleteIds.add(vmEntity.getVmId());
+ msgObj.put("deleteIds", deleteIds);
+ } else {
+ JSONArray data = new JSONArray();
+ JSONObject obj = JSONObject.fromObject(vmEntity);
+ obj.put("oid", vmEntity.getVmId());
+ obj.put("moc", "nfv.vdu.linux");
+ data.add(obj);
+ msgObj.put("data", data);
+ }
+ LOGGER.info("sendMsgMonitor msgObj: {}", msgObj);
+ RestfulParametes restfulParametes = new RestfulParametes();
+ Map<String, String> headerMap = new HashMap<>(3);
+ headerMap.put("Content-Type", "application/json");
+ restfulParametes.setHeaderMap(headerMap);
+ restfulParametes.setRawData(msgObj.toString());
+ String result = RestfulUtil.getResponseContent(UrlConstant.SEND_MSG_MONITOR, restfulParametes,
+ ParamConstant.PARAM_POST);
+ LOGGER.warn(result);
+
+ }
+
+ /**
+ * <br>
+ *
+ * @param map
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ @Override
+ public List<VmEntity> getList(Map<String, Object> map) throws ServiceException {
+ return vmDao.getVms(map);
+ }
+
+ /**
+ * <br>
+ *
+ * @param id
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ @Override
+ public int delete(String id) throws ServiceException {
+ return vmDao.deleteVmById(id);
+ }
+
+ public void setVmDao(VmDao vmDao) {
+ this.vmDao = vmDao;
+ }
+
+ /**
+ * <br>
+ *
+ * @param vnfInstanceId
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ @Override
+ public int deleteByVnfId(String vnfInstanceId) throws ServiceException {
+ Map<String, Object> map = new HashMap<>(10);
+ map.put("vnfInstanceId", vnfInstanceId);
+ List<VmEntity> vms = vmDao.getVms(map);
+ for(int i = 0; i < vms.size(); i++) {
+ VmEntity vm = vms.get(i);
+ sendMsgMonitor("delete", vm);
+ }
+ return vmDao.deleteVmByVnfId(vnfInstanceId);
+ }
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/VnfInfoServiceImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/VnfInfoServiceImpl.java
new file mode 100644
index 0000000..fb34127
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/VnfInfoServiceImpl.java
@@ -0,0 +1,150 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.group.impl;
+
+import java.util.List;
+import java.util.Map;
+
+import org.openo.baseservice.remoteservice.exception.ServiceException;
+import org.openo.nfvo.resmanagement.service.dao.inf.VnfInfoDao;
+import org.openo.nfvo.resmanagement.service.entity.VmEntity;
+import org.openo.nfvo.resmanagement.service.entity.VnfInfoEntity;
+import org.openo.nfvo.resmanagement.service.group.inf.VmService;
+import org.openo.nfvo.resmanagement.service.group.inf.VnfInfoService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import net.sf.json.JSONArray;
+import net.sf.json.JSONObject;
+
+/**
+ * <br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Oct 28, 2016
+ */
+public class VnfInfoServiceImpl implements VnfInfoService {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(VnfInfoServiceImpl.class);
+
+ private VnfInfoDao vnfInfoDao;
+
+ private VmService vmService;
+
+ /**
+ * <br>
+ *
+ * @param object
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ @Override
+ public JSONObject addVnfInfo(JSONObject object) throws ServiceException {
+ LOGGER.info("function=addVnfInfo; object: {}", object);
+ saveVm(object);
+ JSONObject vnf = new JSONObject();
+ vnf.put("vnfInstanceId", object.get("vnfInstanceId"));
+ vnf.put("nsId", object.get("nsId"));
+ vnf.put("vnfmId", object.get("vnfmId"));
+ VnfInfoEntity vnfInfoEntity = VnfInfoEntity.toEntity(vnf);
+ int result;
+ if(!checkId(vnfInfoEntity.getVnfInstanceId())) {
+ result = vnfInfoDao.updateVnfInfo(vnfInfoEntity);
+ } else {
+ result = vnfInfoDao.addVnfInfo(vnfInfoEntity);
+ }
+ JSONObject resultObj = new JSONObject();
+ if(result > 0) {
+ resultObj.put("vnfInstanceId", object.get("vnfInstanceId"));
+ } else {
+ LOGGER.error("function=addVnfInfo; msg=add vnfInfo into DB error.");
+ resultObj.put("message", "Add vnfInfo into DB error.");
+ }
+ return resultObj;
+ }
+
+ /**
+ * <br>
+ *
+ * @param vnfInstanceId
+ * @return
+ * @since NFVO 0.5
+ */
+ private boolean checkId(String vnfInstanceId) {
+ VnfInfoEntity vnf = vnfInfoDao.getVnfInfo(vnfInstanceId);
+ if(null == vnf) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * <br>
+ *
+ * @param object
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ private void saveVm(JSONObject object) throws ServiceException {
+ String vnfInstanceId = object.getString("vnfInstanceId");
+ JSONArray vms = object.getJSONArray("vms");
+ for(int i = 0; i < vms.size(); i++) {
+ JSONObject vmObj = vms.getJSONObject(i);
+ vmObj.put("vnfInstanceId", vnfInstanceId);
+ vmService.addVm(VmEntity.toEntity(vmObj));
+ }
+
+ }
+
+ /**
+ * <br>
+ *
+ * @param map
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ @Override
+ public List<VnfInfoEntity> getList(Map<String, Object> map) throws ServiceException {
+ return vnfInfoDao.getVnfInfos(map);
+ }
+
+ /**
+ * <br>
+ *
+ * @param id
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ @Override
+ public int delete(String id) throws ServiceException {
+ vmService.deleteByVnfId(id);
+ return vnfInfoDao.deleteVnfInfoById(id);
+ }
+
+ public void setVnfInfoDao(VnfInfoDao vnfInfoDao) {
+ this.vnfInfoDao = vnfInfoDao;
+ }
+
+ public void setVmService(VmService vmService) {
+ this.vmService = vmService;
+ }
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/VnfServiceImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/VnfServiceImpl.java
new file mode 100644
index 0000000..3a1a02e
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/VnfServiceImpl.java
@@ -0,0 +1,141 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.group.impl;
+
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+import org.apache.commons.lang3.StringUtils;
+import org.openo.baseservice.remoteservice.exception.ServiceException;
+import org.openo.nfvo.resmanagement.common.ResourceUtil;
+import org.openo.nfvo.resmanagement.service.dao.inf.VnfDao;
+import org.openo.nfvo.resmanagement.service.entity.VnfEntity;
+import org.openo.nfvo.resmanagement.service.group.inf.VnfInfoService;
+import org.openo.nfvo.resmanagement.service.group.inf.VnfService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import net.sf.json.JSONObject;
+
+/**
+ * <br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Oct 28, 2016
+ */
+public class VnfServiceImpl implements VnfService {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(VnfServiceImpl.class);
+
+ private VnfDao vnfDao;
+
+ private VnfInfoService vnfInfoService;
+
+ /**
+ * <br>
+ *
+ * @param vnfEntity
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ @Override
+ public JSONObject addVnf(VnfEntity vnfEntity) throws ServiceException {
+ if(!checkId(vnfEntity.getId())) {
+ LOGGER.error("function=addVnf; msg=add error, because id is already exist.");
+ throw new ServiceException(ResourceUtil
+ .getMessage("org.openo.nfvo.resmanagement.service.group.impl.VnfServiceImpl.add.id.check"));
+ }
+ if(StringUtils.isEmpty(vnfEntity.getId())) {
+ vnfEntity.setId(UUID.randomUUID().toString());
+ }
+ int result = vnfDao.addVnf(vnfEntity);
+ JSONObject restJson = new JSONObject();
+ if(result > 0) {
+ restJson.put("id", vnfEntity.getId());
+ restJson.put("name", vnfEntity.getName());
+ } else {
+ LOGGER.error("function=addVnf; msg=add vnf into DB error.");
+ restJson.put("message", "Add vnf into DB error.");
+ }
+ return restJson;
+ }
+
+ /**
+ * <br>
+ *
+ * @param id
+ * @return
+ * @since NFVO 0.5
+ */
+ private boolean checkId(String id) {
+ VnfEntity vnf = vnfDao.getVnf(id);
+ if(null == vnf) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * <br>
+ *
+ * @param map
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ @Override
+ public List<VnfEntity> getList(Map<String, Object> map) throws ServiceException {
+ return vnfDao.getVnfs(map);
+ }
+
+ /**
+ * <br>
+ *
+ * @param id
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ @Override
+ public int delete(String id) throws ServiceException {
+ deleteVnfInfo(id);
+ return vnfDao.deleteVnfById(id);
+ }
+
+ /**
+ * <br>
+ *
+ * @param id
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ private void deleteVnfInfo(String vnfInstanceId) throws ServiceException {
+ vnfInfoService.delete(vnfInstanceId);
+ }
+
+ public void setVnfDao(VnfDao vnfDao) {
+ this.vnfDao = vnfDao;
+ }
+
+ public void setVnfInfoService(VnfInfoService vnfInfoService) {
+ this.vnfInfoService = vnfInfoService;
+ }
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/VnfStatusServiceImpl.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/VnfStatusServiceImpl.java
new file mode 100644
index 0000000..7e37561
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/impl/VnfStatusServiceImpl.java
@@ -0,0 +1,117 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.group.impl;
+
+import java.util.List;
+import java.util.Map;
+
+import org.openo.baseservice.remoteservice.exception.ServiceException;
+import org.openo.nfvo.resmanagement.service.dao.inf.VnfStatusDao;
+import org.openo.nfvo.resmanagement.service.entity.VnfStatusEntity;
+import org.openo.nfvo.resmanagement.service.group.inf.VnfStatusService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import net.sf.json.JSONObject;
+
+/**
+ * <br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Oct 29, 2016
+ */
+public class VnfStatusServiceImpl implements VnfStatusService {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(VnfStatusServiceImpl.class);
+
+ private VnfStatusDao vnfStatusDao;
+
+ /**
+ * <br>
+ *
+ * @param object
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ @Override
+ public JSONObject addVnfStatus(JSONObject object) throws ServiceException {
+ LOGGER.info("function=addVnfStatus; object: {}", object);
+ VnfStatusEntity vnfStatusEntity = VnfStatusEntity.toEntity(object);
+ int result;
+ if(!checkId(vnfStatusEntity.getVnfInstanceId())) {
+ result = vnfStatusDao.updateVnfStatus(vnfStatusEntity);
+ } else {
+ result = vnfStatusDao.addVnfStatus(vnfStatusEntity);
+ }
+ JSONObject resultObj = new JSONObject();
+ if(result > 0) {
+ resultObj.put("vnfInstanceId", object.get("vnfInstanceId"));
+ } else {
+ LOGGER.error("function=addVnfStatus; msg=add vnfStatus into DB error.");
+ resultObj.put("message", "Add vnfStatus into DB error.");
+ }
+ return resultObj;
+ }
+
+ /**
+ * <br>
+ *
+ * @param vnfInstanceId
+ * @return
+ * @since NFVO 0.5
+ */
+ private boolean checkId(String vnfInstanceId) {
+ VnfStatusEntity vnfStatus = vnfStatusDao.getVnfStatus(vnfInstanceId);
+ if(null == vnfStatus) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * <br>
+ *
+ * @param map
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ @Override
+ public List<VnfStatusEntity> getList(Map<String, Object> map) throws ServiceException {
+ return vnfStatusDao.getVnfStatuss(map);
+ }
+
+ /**
+ * <br>
+ *
+ * @param id
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ @Override
+ public int delete(String id) throws ServiceException {
+ return vnfStatusDao.deleteVnfStatusById(id);
+ }
+
+ public void setVnfStatusDao(VnfStatusDao vnfStatusDao) {
+ this.vnfStatusDao = vnfStatusDao;
+ }
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/inf/GrantResService.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/inf/GrantResService.java
new file mode 100644
index 0000000..4c52b9c
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/inf/GrantResService.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.group.inf;
+
+import org.openo.baseservice.remoteservice.exception.ServiceException;
+
+import net.sf.json.JSONObject;
+
+/**
+ * <br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Oct 29, 2016
+ */
+public interface GrantResService {
+
+ /**
+ * <br>
+ *
+ * @param object
+ * @return
+ * @since NFVO 0.5
+ */
+ JSONObject grantResource(JSONObject object) throws ServiceException;
+
+ JSONObject grantResourceReal(JSONObject object) throws ServiceException;
+
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/inf/ResOperateService.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/inf/ResOperateService.java
new file mode 100644
index 0000000..7e2069f
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/inf/ResOperateService.java
@@ -0,0 +1,82 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.group.inf;
+
+import org.openo.baseservice.remoteservice.exception.ServiceException;
+
+import net.sf.json.JSONObject;
+
+/**
+ * resource operational service class.<br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Sep 10, 2016
+ */
+public interface ResOperateService {
+
+ /**
+ * Update iresource.<br>
+ *
+ * @param tenantId
+ * @param vimId
+ * @param header
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ void updateIRes(String tenantId, String vimId, JSONObject header) throws ServiceException;
+
+ /**
+ * Update all iResource.<br>
+ *
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ void updateAllIRes() throws ServiceException;
+
+ /**
+ * Add iResource.<br>
+ *
+ * @param tenantId
+ * @param vimId
+ * @param header
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ void addIRes(String tenantId, String vimId, JSONObject header) throws ServiceException;
+
+ /**
+ * Delete iResource.<br>
+ *
+ * @param vimId
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ int deleteIRes(String vimId) throws ServiceException;
+
+ /**
+ * <br>
+ *
+ * @param operateType
+ * @param vimId
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ void sendMsgMonitor(String operateType, String vimId) throws ServiceException;
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/inf/VirtualLinkService.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/inf/VirtualLinkService.java
new file mode 100644
index 0000000..cd1ea93
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/inf/VirtualLinkService.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.group.inf;
+
+import java.util.List;
+import java.util.Map;
+
+import org.openo.baseservice.remoteservice.exception.ServiceException;
+import org.openo.nfvo.resmanagement.service.entity.VirtualLinkEntity;
+
+import net.sf.json.JSONObject;
+
+/**
+ * <br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Oct 27, 2016
+ */
+public interface VirtualLinkService {
+
+ /**
+ * <br>
+ *
+ * @param virtualLinkEntity
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ JSONObject addVl(VirtualLinkEntity virtualLinkEntity) throws ServiceException;
+
+ /**
+ * <br>
+ *
+ * @param map
+ * @return
+ * @since NFVO 0.5
+ */
+ List<VirtualLinkEntity> getList(Map<String, Object> map) throws ServiceException;
+
+ /**
+ * <br>
+ *
+ * @param id
+ * @return
+ * @since NFVO 0.5
+ */
+ int delete(String id) throws ServiceException;
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/inf/VmService.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/inf/VmService.java
new file mode 100644
index 0000000..668f9d3
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/inf/VmService.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.group.inf;
+
+import java.util.List;
+import java.util.Map;
+
+import org.openo.baseservice.remoteservice.exception.ServiceException;
+import org.openo.nfvo.resmanagement.service.entity.VmEntity;
+
+import net.sf.json.JSONObject;
+
+/**
+ * <br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Oct 29, 2016
+ */
+public interface VmService {
+
+ JSONObject addVm(VmEntity vmEntity) throws ServiceException;
+
+ List<VmEntity> getList(Map<String, Object> map) throws ServiceException;
+
+ int delete(String id) throws ServiceException;
+
+ int deleteByVnfId(String vnfInstanceId) throws ServiceException;
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/inf/VnfInfoService.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/inf/VnfInfoService.java
new file mode 100644
index 0000000..6e736d6
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/inf/VnfInfoService.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.group.inf;
+
+import java.util.List;
+import java.util.Map;
+
+import org.openo.baseservice.remoteservice.exception.ServiceException;
+import org.openo.nfvo.resmanagement.service.entity.VnfInfoEntity;
+
+import net.sf.json.JSONObject;
+
+/**
+ * <br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Oct 28, 2016
+ */
+public interface VnfInfoService {
+
+ JSONObject addVnfInfo(JSONObject object) throws ServiceException;
+
+ List<VnfInfoEntity> getList(Map<String, Object> map) throws ServiceException;
+
+ int delete(String id) throws ServiceException;
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/inf/VnfService.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/inf/VnfService.java
new file mode 100644
index 0000000..4fbe45e
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/inf/VnfService.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.group.inf;
+
+import java.util.List;
+import java.util.Map;
+
+import org.openo.baseservice.remoteservice.exception.ServiceException;
+import org.openo.nfvo.resmanagement.service.entity.VnfEntity;
+
+import net.sf.json.JSONObject;
+
+/**
+ * <br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Oct 28, 2016
+ */
+public interface VnfService {
+
+ /**
+ * <br>
+ *
+ * @param vnfEntity
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ JSONObject addVnf(VnfEntity vnfEntity) throws ServiceException;
+
+ /**
+ * <br>
+ *
+ * @param map
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ List<VnfEntity> getList(Map<String, Object> map) throws ServiceException;
+
+ /**
+ * <br>
+ *
+ * @param id
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ int delete(String id) throws ServiceException;
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/inf/VnfStatusService.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/inf/VnfStatusService.java
new file mode 100644
index 0000000..cdc826c
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/group/inf/VnfStatusService.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.group.inf;
+
+import java.util.List;
+import java.util.Map;
+
+import org.openo.baseservice.remoteservice.exception.ServiceException;
+import org.openo.nfvo.resmanagement.service.entity.VnfStatusEntity;
+
+import net.sf.json.JSONObject;
+
+/**
+ * <br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Oct 29, 2016
+ */
+public interface VnfStatusService {
+
+ JSONObject addVnfStatus(JSONObject object) throws ServiceException;
+
+ List<VnfStatusEntity> getList(Map<String, Object> map) throws ServiceException;
+
+ int delete(String id) throws ServiceException;
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/HostMapper.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/HostMapper.java
new file mode 100644
index 0000000..643c581
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/HostMapper.java
@@ -0,0 +1,114 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.mapper;
+
+import java.util.List;
+import java.util.Map;
+
+import org.openo.nfvo.resmanagement.service.entity.HostEntity;
+
+/**
+ * Host info interface.<br/>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Aug 24, 2016
+ */
+public interface HostMapper {
+
+ /**
+ * It is used to get Host info.<br/>
+ *
+ * @param id
+ * @return The get result
+ * @since NFVO 0.5
+ */
+ HostEntity getHost(String id);
+
+ /**
+ * It is used to get Hosts info.<br/>
+ *
+ * @param condition
+ * @return The get result
+ * @since NFVO 0.5
+ */
+ List<HostEntity> getHosts(Map<String, Object> condition);
+
+ /**
+ * It is used to delete Hosts info.<br/>
+ *
+ * @param id
+ * @return The delete result
+ * @since NFVO 0.5
+ */
+ int deleteHost(String id);
+
+ /**
+ * It is used to delete Hosts info.<br/>
+ *
+ * @param vimId
+ * @return The delete result
+ * @since NFVO 0.5
+ */
+ int deleteHostByVimId(String vimId);
+
+ /**
+ * It is used to add Hosts info. <br/>
+ *
+ * @param hostEntity
+ * @return The add result
+ * @since NFVO 0.5
+ */
+ int addHost(HostEntity hostEntity);
+
+ /**
+ * It is used to add Hosts info. <br/>
+ *
+ * @param hostEntity
+ * @return The add result
+ * @since NFVO 0.5
+ */
+ int addHostSelective(HostEntity hostEntity);
+
+ /**
+ * It is used to update Hosts info. <br/>
+ *
+ * @param hostEntity
+ * @return The update result
+ * @since NFVO 0.5
+ */
+ int updateHostSelective(HostEntity hostEntity);
+
+ /**
+ * It is used to update Hosts info. <br/>
+ *
+ * @param hostEntity
+ * @return The update result
+ * @since NFVO 0.5
+ */
+ int updateHost(HostEntity hostEntity);
+
+ /**
+ * It is used to update Hosts info. <br/>
+ *
+ * @param hostEntity
+ * @return The update result
+ * @since NFVO 0.5
+ */
+ int updateHostByVimId(HostEntity hostEntity);
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/LocationMapper.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/LocationMapper.java
new file mode 100644
index 0000000..2a2ec5c
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/LocationMapper.java
@@ -0,0 +1,123 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.mapper;
+
+import java.util.List;
+import java.util.Map;
+
+import org.openo.nfvo.resmanagement.service.entity.LocationEntity;
+
+/**
+ *
+ * Location Mapper Class.<br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Sep 10, 2016
+ */
+public interface LocationMapper {
+
+ /**
+ *
+ * Get location.<br>
+ *
+ * @param id
+ * @return
+ * @since NFVO 0.5
+ */
+ LocationEntity getLocation(String id);
+
+ /**
+ *
+ * Get Country.<br>
+ *
+ * @return
+ * @since NFVO 0.5
+ */
+ List<String> getCountry();
+
+ /**
+ *
+ * Get location by country.<br>
+ *
+ * @param condition
+ * @return
+ * @since NFVO 0.5
+ */
+ List<String> getLocationByCountry(Map<String, Object> condition);
+
+ /**
+ *
+ * get locations.<br>
+ *
+ * @param condition
+ * @return
+ * @since NFVO 0.5
+ */
+ List<LocationEntity> getLocations(Map<String, Object> condition);
+
+ /**
+ *
+ * Delete location.<br>
+ *
+ * @param location
+ * @return
+ * @since NFVO 0.5
+ */
+ int deleteLocation(String location);
+
+ /**
+ *
+ * Add location.<br>
+ *
+ * @param locationEntity
+ * @return
+ * @since NFVO 0.5
+ */
+ int addLocation(LocationEntity locationEntity);
+
+ /**
+ *
+ * Add selective location.<br>
+ *
+ * @param locationEntity
+ * @return
+ * @since NFVO 0.5
+ */
+ int addLocationSelective(LocationEntity locationEntity);
+
+ /**
+ *
+ * Update selective location.<br>
+ *
+ * @param locationEntity
+ * @return
+ * @since NFVO 0.5
+ */
+ int updateLocationSelective(LocationEntity locationEntity);
+
+ /**
+ *
+ * Update location.<br>
+ *
+ * @param locationEntity
+ * @return
+ * @since NFVO 0.5
+ */
+ int updateLocation(LocationEntity locationEntity);
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/NetworkMapper.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/NetworkMapper.java
new file mode 100644
index 0000000..b727f4f
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/NetworkMapper.java
@@ -0,0 +1,125 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.mapper;
+
+import java.util.List;
+import java.util.Map;
+
+import org.openo.nfvo.resmanagement.service.entity.NetworkEntity;
+
+/**
+ *
+ * Network Mapper Class.<br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Sep 10, 2016
+ */
+public interface NetworkMapper {
+
+ /**
+ *
+ * Get network details.<br>
+ *
+ * @param id
+ * @return
+ * @since NFVO 0.5
+ */
+ NetworkEntity getNetwork(String id);
+
+ /**
+ *
+ * Get details of networks.<br>
+ *
+ * @param condition
+ * @return
+ * @since NFVO 0.5
+ */
+ List<NetworkEntity> getNetworks(Map<String, Object> condition);
+
+ /**
+ *
+ * Delete network.<br>
+ *
+ * @param id
+ * @return
+ * @since NFVO 0.5
+ */
+ int deleteNetwork(String id);
+
+ /**
+ *
+ * Delete network by VIM ID.<br>
+ *
+ * @param vimId
+ * @return
+ * @since NFVO 0.5
+ */
+ int deleteNetworkByVimId(String vimId);
+
+ /**
+ *
+ * Add network.<br>
+ *
+ * @param networkEntity
+ * @return
+ * @since NFVO 0.5
+ */
+ int addNetwork(NetworkEntity networkEntity);
+
+ /**
+ *
+ * Add selective network.<br>
+ *
+ * @param networkEntity
+ * @return
+ * @since NFVO 0.5
+ */
+ int addNetworkSelective(NetworkEntity networkEntity);
+
+ /**
+ *
+ * Update selective network.<br>
+ *
+ * @param networkEntity
+ * @return
+ * @since NFVO 0.5
+ */
+ int updateNetworkSelective(NetworkEntity networkEntity);
+
+ /**
+ *
+ * Update network.<br>
+ *
+ * @param networkEntity
+ * @return
+ * @since NFVO 0.5
+ */
+ int updateNetwork(NetworkEntity networkEntity);
+
+ /**
+ *
+ * Update network by VIM Id.<br>
+ *
+ * @param networkEntity
+ * @return
+ * @since NFVO 0.5
+ */
+ int updateNetworkByVimId(NetworkEntity networkEntity);
+
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/PortMapper.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/PortMapper.java
new file mode 100644
index 0000000..9cae421
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/PortMapper.java
@@ -0,0 +1,114 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.mapper;
+
+import java.util.List;
+import java.util.Map;
+
+import org.openo.nfvo.resmanagement.service.entity.PortEntity;
+
+/**
+ * Port info interface.<br/>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Aug 24, 2016
+ */
+public interface PortMapper {
+
+ /**
+ * It is used to get Port info.<br/>
+ *
+ * @param id
+ * @return The get result
+ * @since NFVO 0.5
+ */
+ PortEntity getPort(String id);
+
+ /**
+ * It is used to get Ports info.<br/>
+ *
+ * @param condition
+ * @return The get result
+ * @since NFVO 0.5
+ */
+ List<PortEntity> getPorts(Map<String, Object> condition);
+
+ /**
+ * It is used to delete Ports info.<br/>
+ *
+ * @param id
+ * @return The delete result
+ * @since NFVO 0.5
+ */
+ int deletePort(String id);
+
+ /**
+ * It is used to delete Ports info.<br/>
+ *
+ * @param vimId
+ * @return The delete result
+ * @since NFVO 0.5
+ */
+ int deletePortByVimId(String vimId);
+
+ /**
+ * It is used to add Ports info. <br/>
+ *
+ * @param portEntity
+ * @return The add result
+ * @since NFVO 0.5
+ */
+ int addPort(PortEntity portEntity);
+
+ /**
+ * It is used to add Ports info. <br/>
+ *
+ * @param portEntity
+ * @return The add result
+ * @since NFVO 0.5
+ */
+ int addPortSelective(PortEntity portEntity);
+
+ /**
+ * It is used to update Ports info. <br/>
+ *
+ * @param portEntity
+ * @return The update result
+ * @since NFVO 0.5
+ */
+ int updatePortSelective(PortEntity portEntity);
+
+ /**
+ * It is used to update Ports info. <br/>
+ *
+ * @param portEntity
+ * @return The update result
+ * @since NFVO 0.5
+ */
+ int updatePort(PortEntity portEntity);
+
+ /**
+ * It is used to update Ports info. <br/>
+ *
+ * @param portEntity
+ * @return The update result
+ * @since NFVO 0.5
+ */
+ int updatePortByVimId(PortEntity portEntity);
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/SitesMapper.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/SitesMapper.java
new file mode 100644
index 0000000..e86d5e1
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/SitesMapper.java
@@ -0,0 +1,111 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.mapper;
+
+import java.util.List;
+import java.util.Map;
+
+import org.openo.nfvo.resmanagement.service.entity.SitesEntity;
+
+/**
+ * ResPool info interface.<br/>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Aug 24, 2016
+ */
+public interface SitesMapper {
+
+ /**
+ * It is used to get Sites info.<br/>
+ *
+ * @param id
+ * @return The get result
+ * @since NFVO 0.5
+ */
+ SitesEntity getSite(String id);
+
+ /**
+ *
+ * It is used to get Sites info.<br>
+ *
+ * @param map
+ * @return
+ * @since NFVO 0.5
+ */
+ List<SitesEntity> getSites(Map<String, Object> map);
+
+ /**
+ * It is used to get Sites info.<br/>
+ *
+ * @param id
+ * @return The get result
+ * @since NFVO 0.5
+ */
+ int deleteSite(String id);
+
+ /**
+ *
+ * It is used to delete Site info.<br>
+ *
+ * @param entity
+ * @return
+ * @since NFVO 0.5
+ */
+ int addSite(SitesEntity entity);
+
+ /**
+ *
+ * It is used to add Sites info.<br>
+ *
+ * @param entity
+ * @return
+ * @since NFVO 0.5
+ */
+ int addSiteSelective(SitesEntity entity);
+
+ /**
+ *
+ * It is used to add Site info.<br>
+ *
+ * @param entity
+ * @return
+ * @since NFVO 0.5
+ */
+ int updateSiteSelective(SitesEntity entity);
+
+ /**
+ *
+ * It is used to update Sites info.<br>
+ *
+ * @param entity
+ * @return
+ * @since NFVO 0.5
+ */
+ int updateSite(SitesEntity entity);
+
+ /**
+ *
+ * It is used to update Site info.<br>
+ *
+ * @param entity
+ * @return
+ * @since NFVO 0.5
+ */
+ int updateSiteByVimId(SitesEntity entity);
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/VimMapper.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/VimMapper.java
new file mode 100644
index 0000000..1c4573a
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/VimMapper.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.mapper;
+
+import java.util.List;
+
+import org.openo.nfvo.resmanagement.service.entity.VimEntity;
+
+/**
+ * Vim info interface.<br/>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Aug 24, 2016
+ */
+public interface VimMapper {
+
+ /**
+ * It is used to get Vim info.<br/>
+ *
+ * @param id
+ * @return The get result
+ * @since NFVO 0.5
+ */
+ VimEntity getVim(String id);
+
+ /**
+ * It is used to get Vims info.<br/>
+ *
+ * @return The get result
+ * @since NFVO 0.5
+ */
+ List<VimEntity> getVims();
+
+ /**
+ * It is used to delete Vim info.<br/>
+ *
+ * @param id
+ * @return The delete result
+ * @since NFVO 0.5
+ */
+ int deleteVim(String id);
+
+ /**
+ * It is used to add Vim info.<br/>
+ *
+ * @param vimEntity
+ * @return The add result
+ * @since NFVO 0.5
+ */
+ int addVim(VimEntity vimEntity);
+
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/VirtualLinkMapper.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/VirtualLinkMapper.java
new file mode 100644
index 0000000..c4cba74
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/VirtualLinkMapper.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.mapper;
+
+import java.util.List;
+import java.util.Map;
+
+import org.openo.nfvo.resmanagement.service.entity.VirtualLinkEntity;
+
+public interface VirtualLinkMapper {
+
+ int deleteByPrimaryKey(String id);
+
+ int insert(VirtualLinkEntity record);
+
+ int insertSelective(VirtualLinkEntity record);
+
+ VirtualLinkEntity selectByPrimaryKey(String id);
+
+ List<VirtualLinkEntity> getVls(Map<String, Object> condition);
+
+ int updateByPrimaryKeySelective(VirtualLinkEntity record);
+
+ int updateByPrimaryKey(VirtualLinkEntity record);
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/VmMapper.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/VmMapper.java
new file mode 100644
index 0000000..4cb4878
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/VmMapper.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.mapper;
+
+import java.util.List;
+import java.util.Map;
+
+import org.openo.nfvo.resmanagement.service.entity.VmEntity;
+
+public interface VmMapper {
+
+ int deleteByPrimaryKey(String vmId);
+
+ int deleteByVnfId(String vnfInstanceId);
+
+ int insert(VmEntity record);
+
+ int insertSelective(VmEntity record);
+
+ VmEntity selectByPrimaryKey(String vmId);
+
+ List<VmEntity> getVms(Map<String, Object> condition);
+
+ int updateByPrimaryKeySelective(VmEntity record);
+
+ int updateByPrimaryKey(VmEntity record);
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/VnfInfoMapper.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/VnfInfoMapper.java
new file mode 100644
index 0000000..45d4f45
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/VnfInfoMapper.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.mapper;
+
+import java.util.List;
+import java.util.Map;
+
+import org.openo.nfvo.resmanagement.service.entity.VnfInfoEntity;
+
+public interface VnfInfoMapper {
+
+ int deleteByPrimaryKey(String vnfInstanceId);
+
+ int insert(VnfInfoEntity record);
+
+ int insertSelective(VnfInfoEntity record);
+
+ VnfInfoEntity selectByPrimaryKey(String vnfInstanceId);
+
+ List<VnfInfoEntity> getVnfInfos(Map<String, Object> condition);
+
+ int updateByPrimaryKeySelective(VnfInfoEntity record);
+
+ int updateByPrimaryKey(VnfInfoEntity record);
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/VnfMapper.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/VnfMapper.java
new file mode 100644
index 0000000..5d0078f
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/VnfMapper.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.mapper;
+
+import java.util.List;
+import java.util.Map;
+
+import org.openo.nfvo.resmanagement.service.entity.VnfEntity;
+
+public interface VnfMapper {
+
+ int deleteByPrimaryKey(String vnfInstanceId);
+
+ int insert(VnfEntity record);
+
+ int insertSelective(VnfEntity record);
+
+ VnfEntity selectByPrimaryKey(String id);
+
+ List<VnfEntity> getVnfs(Map<String, Object> condition);
+
+ int updateByPrimaryKeySelective(VnfEntity record);
+
+ int updateByPrimaryKey(VnfEntity record);
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/VnfStatusMapper.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/VnfStatusMapper.java
new file mode 100644
index 0000000..c7e5c7a
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/mapper/VnfStatusMapper.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.mapper;
+
+import java.util.List;
+import java.util.Map;
+
+import org.openo.nfvo.resmanagement.service.entity.VnfStatusEntity;
+
+public interface VnfStatusMapper {
+
+ int deleteByPrimaryKey(String vnfInstanceId);
+
+ int insert(VnfStatusEntity record);
+
+ int insertSelective(VnfStatusEntity record);
+
+ VnfStatusEntity selectByPrimaryKey(String vnfInstanceId);
+
+ List<VnfStatusEntity> getVnfStatuss(Map<String, Object> condition);
+
+ int updateByPrimaryKeySelective(VnfStatusEntity record);
+
+ int updateByPrimaryKey(VnfStatusEntity record);
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/GrantResourseRoa.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/GrantResourseRoa.java
new file mode 100644
index 0000000..47a9a02
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/GrantResourseRoa.java
@@ -0,0 +1,94 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.rest;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+
+import org.openo.baseservice.remoteservice.exception.ServiceException;
+import org.openo.nfvo.resmanagement.common.ResourceUtil;
+import org.openo.nfvo.resmanagement.common.constant.HttpConstant;
+import org.openo.nfvo.resmanagement.common.constant.UrlConstant;
+import org.openo.nfvo.resmanagement.common.util.request.RequestUtil;
+import org.openo.nfvo.resmanagement.common.util.response.ResponseUtil;
+import org.openo.nfvo.resmanagement.service.group.inf.GrantResService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import net.sf.json.JSONObject;
+
+/**
+ * <br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Oct 29, 2016
+ */
+@Path(UrlConstant.GRANTRES_URL)
+@Produces(MediaType.APPLICATION_JSON)
+@Consumes(MediaType.APPLICATION_JSON)
+public class GrantResourseRoa {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(GrantResourseRoa.class);
+
+ private GrantResService grantResService;
+
+ @PUT
+ @Path("/stub")
+ public JSONObject grantResource(@Context HttpServletRequest context) throws ServiceException {
+ JSONObject object = RequestUtil.getJsonRequestBody(context);
+ if(null == object) {
+ LOGGER.error("function=grantResource; msg=grantResource error, because body is null.");
+ throw new ServiceException(ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.grantResource.null"));
+ }
+
+ LOGGER.info("GrantResourseRoa::grantResource:{}", object.toString());
+ try {
+ return grantResService.grantResource(object);
+ } catch(ServiceException se) {
+ LOGGER.error("GrantResourseRoa::grantResource error:{}" + se);
+ return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage());
+ }
+ }
+
+ @PUT
+ public JSONObject grantResourceReal(@Context HttpServletRequest context) throws ServiceException {
+ JSONObject object = RequestUtil.getJsonRequestBody(context);
+ if(null == object) {
+ LOGGER.error("function=grantResource; msg=grantResource error, because body is null.");
+ throw new ServiceException(ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.grantResource.null"));
+ }
+
+ LOGGER.info("GrantResourseRoa::grantResource:{}", object.toString());
+ try {
+ return grantResService.grantResourceReal(object);
+ } catch(ServiceException se) {
+ LOGGER.error("GrantResourseRoa::grantResource error:{}" + se);
+ return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage());
+ }
+ }
+
+ public void setGrantResService(GrantResService grantResService) {
+ this.grantResService = grantResService;
+ }
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/HostRoa.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/HostRoa.java
new file mode 100644
index 0000000..98e7da0
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/HostRoa.java
@@ -0,0 +1,183 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.rest;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+
+import org.openo.baseservice.remoteservice.exception.ServiceException;
+import org.openo.nfvo.resmanagement.common.constant.HttpConstant;
+import org.openo.nfvo.resmanagement.common.constant.ParamConstant;
+import org.openo.nfvo.resmanagement.common.constant.UrlConstant;
+import org.openo.nfvo.resmanagement.common.util.request.RequestUtil;
+import org.openo.nfvo.resmanagement.common.util.response.ResponseUtil;
+import org.openo.nfvo.resmanagement.common.util.response.RoaResponseUtil;
+import org.openo.nfvo.resmanagement.service.base.openstack.inf.Host;
+import org.openo.nfvo.resmanagement.service.entity.HostEntity;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import net.sf.json.JSONObject;
+
+/**
+ *
+ * Host ROA Class.<br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Sep 10, 2016
+ */
+@Path(UrlConstant.HOST_URL)
+@Produces(MediaType.APPLICATION_JSON)
+@Consumes(MediaType.APPLICATION_JSON)
+public class HostRoa {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(HostRoa.class);
+
+ private Host host;
+
+ /**
+ *
+ * Get hosts.<br>
+ *
+ * @param context
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ @GET
+ public JSONObject getHosts(@Context HttpServletRequest context) throws ServiceException {
+ Map<String, Object> map = new HashMap<>(10);
+ List<HostEntity> hosts = host.getList(map);
+
+ JSONObject result = new JSONObject();
+ result.put("hosts", hosts);
+ return result;
+ }
+
+ /**
+ *
+ * Get host.<br>
+ *
+ * @param context
+ * @param id
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ @GET
+ @Path("/{hostId}")
+ public JSONObject getHost(@Context HttpServletRequest context, @PathParam("hostId") String id)
+ throws ServiceException {
+ LOGGER.info("HostRoa::getHost id:{}", id);
+ Map<String, Object> map = new HashMap<>(10);
+ map.put(ParamConstant.PARAM_ID, id);
+ List<HostEntity> hosts = host.getList(map);
+
+ JSONObject result = new JSONObject();
+ result.put("hosts", hosts);
+ return result;
+ }
+
+ /**
+ *
+ * Add host.<br>
+ *
+ * @param context
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ @POST
+ public JSONObject addHost(@Context HttpServletRequest context) throws ServiceException {
+ JSONObject object = RequestUtil.getJsonRequestBody(context);
+
+ LOGGER.info("HostRoa::addHost:{}", object.toString());
+ try {
+ int result = host.add(object);
+ return RoaResponseUtil.add(result);
+ } catch(ServiceException se) {
+ LOGGER.error("HostRoa::addHost error:{}" + se);
+ return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage());
+ }
+ }
+
+ /**
+ *
+ * Delete host.<br>
+ *
+ * @param context
+ * @param id
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ @DELETE
+ public JSONObject deleteHost(@Context HttpServletRequest context, @QueryParam(ParamConstant.PARAM_ID) String id)
+ throws ServiceException {
+ LOGGER.info("HostRoa::deleteHost id:{}", id);
+ try {
+ int result = host.delete(id);
+ return RoaResponseUtil.delete(result);
+ } catch(ServiceException se) {
+ LOGGER.error("HostRoa::deleteHost error:{}" + se);
+ return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage());
+ }
+ }
+
+ /**
+ *
+ * Update host.<br>
+ *
+ * @param context
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ @PUT
+ public JSONObject updateHost(@Context HttpServletRequest context) throws ServiceException {
+ JSONObject object = RequestUtil.getJsonRequestBody(context);
+
+ LOGGER.info("HostRoa::updateHost:{}", object.toString());
+ try {
+ int result = host.update(object);
+ return RoaResponseUtil.update(result);
+ } catch(ServiceException se) {
+ LOGGER.error("HostRoa::updateHost error:{}" + se);
+ return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage());
+ }
+ }
+
+ public void setHost(Host host) {
+ this.host = host;
+ }
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/LimitsRoa.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/LimitsRoa.java
new file mode 100644
index 0000000..5275dfe
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/LimitsRoa.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2016-2017 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.rest;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+
+import org.openo.baseservice.remoteservice.exception.ServiceException;
+import org.openo.nfvo.resmanagement.common.constant.ParamConstant;
+import org.openo.nfvo.resmanagement.common.constant.UrlConstant;
+import org.openo.nfvo.resmanagement.service.business.inf.LimitsBusiness;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import net.sf.json.JSONObject;
+
+/**
+ * <br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Sep 10, 2016
+ */
+@Path(UrlConstant.LIMITS_URL)
+@Consumes(MediaType.APPLICATION_JSON)
+@Produces(MediaType.APPLICATION_JSON)
+public class LimitsRoa {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(LimitsRoa.class);
+
+ private LimitsBusiness limitsBusiness;
+
+ /**
+ * <br>
+ *
+ * @param context
+ * @param vimId
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ @GET
+ public JSONObject getLimits(@Context HttpServletRequest context,
+ @QueryParam(ParamConstant.PARAM_VIMID) String vimId) throws ServiceException {
+ LOGGER.warn("function=getLimits, vimId={}", vimId);
+ return limitsBusiness.getLimits(vimId);
+ }
+
+ public void setLimitsBusiness(LimitsBusiness limitsBusiness) {
+ this.limitsBusiness = limitsBusiness;
+ }
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/LocationRoa.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/LocationRoa.java
new file mode 100644
index 0000000..f3bb351
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/LocationRoa.java
@@ -0,0 +1,316 @@
+/*
+ * Copyright 2016-2017 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.rest;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+
+import org.openo.baseservice.remoteservice.exception.ServiceException;
+import org.openo.nfvo.resmanagement.common.ResourceUtil;
+import org.openo.nfvo.resmanagement.common.constant.HttpConstant;
+import org.openo.nfvo.resmanagement.common.constant.ParamConstant;
+import org.openo.nfvo.resmanagement.common.constant.UrlConstant;
+import org.openo.nfvo.resmanagement.common.util.JsonUtil;
+import org.openo.nfvo.resmanagement.common.util.request.RequestUtil;
+import org.openo.nfvo.resmanagement.common.util.response.ResponseUtil;
+import org.openo.nfvo.resmanagement.common.util.response.RoaResponseUtil;
+import org.openo.nfvo.resmanagement.service.base.openstack.inf.Location;
+import org.openo.nfvo.resmanagement.service.base.openstack.inf.Sites;
+import org.openo.nfvo.resmanagement.service.entity.LocationEntity;
+import org.openo.nfvo.resmanagement.service.entity.SitesEntity;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import net.sf.json.JSONObject;
+
+/**
+ * Location ROA Class.<br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Sep 10, 2016
+ */
+@Path(UrlConstant.LOCATION_URL)
+@Produces(MediaType.APPLICATION_JSON)
+@Consumes(MediaType.APPLICATION_JSON)
+public class LocationRoa {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(LocationRoa.class);
+
+ private Location location;
+
+ private Sites sites;
+
+ /**
+ * Get Locations Base.<br>
+ *
+ * @param context
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ @GET
+ public JSONObject getLocationsbase(@Context HttpServletRequest context) throws ServiceException {
+ Map<String, Object> condition = new HashMap<>();
+ List<LocationEntity> locations = location.get(condition);
+
+ JSONObject result = new JSONObject();
+ result.put("locations", locations);
+ return result;
+ }
+
+ /**
+ * Get Locations Base.<br>
+ *
+ * @param context
+ * @param id
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ @GET
+ @Path("/{locationId}")
+ public JSONObject getLocationbase(@Context HttpServletRequest context, @PathParam("locationId") String id)
+ throws ServiceException {
+ LOGGER.info("LocationRoa::getLocationbase id:{}", id);
+ Map<String, Object> map = new HashMap<>();
+ map.put(ParamConstant.PARAM_ID, id);
+ List<LocationEntity> locations = location.get(map);
+
+ JSONObject result = new JSONObject();
+ result.put("locations", locations);
+ return result;
+ }
+
+ /**
+ * Get Country.<br>
+ *
+ * @param context
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ @GET
+ @Path("/country")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ public JSONObject getCountry(@Context HttpServletRequest context) throws ServiceException {
+ return RoaResponseUtil.get(location.getCountry());
+ }
+
+ /**
+ * Get Location by Country.<br>
+ *
+ * @param context
+ * @param country
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ @GET
+ @Path("/locationbycountry")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ public JSONObject getLocationByCountry(@Context HttpServletRequest context,
+ @QueryParam(ParamConstant.PARAM_COUNTRY) String country) throws ServiceException {
+ LOGGER.info("LocationRoa::getLocationByCountry country:{}", country);
+ Map<String, Object> condition = new HashMap<>();
+ condition.put(ParamConstant.PARAM_COUNTRY, country);
+ return RoaResponseUtil.get(location.getLocationByCountry(condition));
+ }
+
+ /**
+ * Get Cloud Service.<br>
+ *
+ * @param context
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ @GET
+ @Path("/cloudservice")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ public JSONObject getCloudservice(@Context HttpServletRequest context) throws ServiceException {
+ return RoaResponseUtil.get(location.getCloudservice());
+ }
+
+ /**
+ * Get location details.<br>
+ *
+ * @param context
+ * @param locations
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ @GET
+ @Path("/site")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ public JSONObject getLocation(@Context HttpServletRequest context,
+ @QueryParam(ParamConstant.PARAM_LOCATION) String locations) throws ServiceException {
+ LOGGER.info("LocationRoa::getLocation locations:{}", locations);
+ Map<String, Object> condition = new HashMap<>();
+ List<LocationEntity> loca = new ArrayList<LocationEntity>();
+ condition.put(ParamConstant.PARAM_LOCATION, locations);
+ loca = location.get(condition);
+ LOGGER.info("LocationRoa::getLocation loca:{}", loca);
+ return RoaResponseUtil.get(location.getLocationInfo(loca));
+ }
+
+ /**
+ * Add Location.<br>
+ *
+ * @param context
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ @POST
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ public JSONObject addLocation(@Context HttpServletRequest context) throws ServiceException {
+ JSONObject object = RequestUtil.getJsonRequestBody(context);
+
+ LOGGER.info("LocationRoa::addLocation : " + object.toString());
+ try {
+ int result = location.add(object);
+ return RoaResponseUtil.add(result);
+ } catch(ServiceException se) {
+ LOGGER.error("LocationRoa::addLocation error:{}" + se);
+ return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage());
+ }
+ }
+
+ /**
+ * Delete Location Base.<br>
+ *
+ * @param context
+ * @param locations
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ @DELETE
+ @Path("/{location}")
+ public JSONObject deleteLocationbase(@Context HttpServletRequest context,
+ @PathParam(ParamConstant.PARAM_LOCATION) String locations) throws ServiceException {
+ LOGGER.info("LocationRoa::deleteLocation locations:{}", locations);
+ Map<String, Object> condition = new HashMap<>();
+ condition.put(ParamConstant.PARAM_LOCATION, locations);
+ try {
+ int result = location.delete(locations);
+ return RoaResponseUtil.delete(result);
+ } catch(ServiceException se) {
+ LOGGER.error("LocationRoa::deleteLocationbase error:{}" + se);
+ return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage());
+ }
+ }
+
+ /**
+ * Delete Location.<br>
+ *
+ * @param context
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ @DELETE
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ public JSONObject deleteLocation(@Context HttpServletRequest context) throws ServiceException {
+
+ JSONObject object = RequestUtil.getJsonRequestBody(context);
+ String locations = JsonUtil.getJsonFieldStr(object, ParamConstant.PARAM_LOCATION);
+ String id = JsonUtil.getJsonFieldStr(object, ParamConstant.PARAM_ID);
+ LOGGER.info("LocationRoa::deleteLocation locations:{}", locations);
+
+ Map<String, Object> condition = new HashMap<>();
+ condition.put(ParamConstant.PARAM_LOCATION, locations);
+ SitesEntity sitesEntity = sites.get(condition);
+ try {
+ if(sitesEntity != null) {
+ return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE,
+ ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.location.delete.used.check"));
+ }
+ int result = location.delete(id);
+ return RoaResponseUtil.delete(result);
+ } catch(ServiceException se) {
+ LOGGER.error("LocationRoa::deleteLocation error:{}" + se);
+ return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage());
+ }
+ }
+
+ /**
+ * Update Location.<br>
+ *
+ * @param context
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ @PUT
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ public JSONObject updateLocation(@Context HttpServletRequest context) throws ServiceException {
+ JSONObject object = RequestUtil.getJsonRequestBody(context);
+ String local = JsonUtil.getJsonFieldStr(object, ParamConstant.PARAM_LOCATION);
+ Map<String, Object> localInfo = new HashMap<>();
+ localInfo.put(ParamConstant.PARAM_LOCATION, local);
+ SitesEntity sitesEntity = sites.get(localInfo);
+ if(sitesEntity != null) {
+ LOGGER.error("function=updateLocation; msg=update error, because location is used.");
+ return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE,
+ ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.base.location.update.used.check"));
+ }
+ LOGGER.info("LocationRoa::updateLocation : " + object.toString());
+
+ try {
+ int result = location.update(object);
+ return RoaResponseUtil.update(result);
+ } catch(ServiceException se) {
+ LOGGER.error("LocationRoa::update Location error:{}" + se);
+ return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage());
+ }
+ }
+
+ public void setLocation(Location location) {
+ this.location = location;
+ }
+
+ public void setSites(Sites sites) {
+ this.sites = sites;
+ }
+
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/NetworkRoa.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/NetworkRoa.java
new file mode 100644
index 0000000..8a3e0bd
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/NetworkRoa.java
@@ -0,0 +1,189 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.rest;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+
+import org.openo.baseservice.remoteservice.exception.ServiceException;
+import org.openo.nfvo.resmanagement.common.constant.HttpConstant;
+import org.openo.nfvo.resmanagement.common.constant.ParamConstant;
+import org.openo.nfvo.resmanagement.common.constant.UrlConstant;
+import org.openo.nfvo.resmanagement.common.util.request.RequestUtil;
+import org.openo.nfvo.resmanagement.common.util.response.ResponseUtil;
+import org.openo.nfvo.resmanagement.common.util.response.RoaResponseUtil;
+import org.openo.nfvo.resmanagement.service.base.openstack.inf.Network;
+import org.openo.nfvo.resmanagement.service.entity.NetworkEntity;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import net.sf.json.JSONObject;
+
+/**
+ *
+ * Network ROA Class.<br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Sep 10, 2016
+ */
+@Path(UrlConstant.NETWORKS_URL)
+@Consumes({MediaType.APPLICATION_JSON})
+@Produces({MediaType.APPLICATION_JSON})
+public class NetworkRoa {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(NetworkRoa.class);
+
+ private Network network;
+
+ /**
+ *
+ * Get details of networks.<br>
+ *
+ * @param context
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ @GET
+ public JSONObject getNetworks(@Context HttpServletRequest context) throws ServiceException {
+ Map<String, Object> map = new HashMap<>(10);
+ List<NetworkEntity> networks = network.getList(map);
+
+ JSONObject result = new JSONObject();
+ result.put("networks", networks.toString());
+ return result;
+ }
+
+ /**
+ *
+ * Get network details.<br>
+ *
+ * @param context
+ * @param id
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ @GET
+ @Path("/{networkId}")
+ public JSONObject getNetwork(@Context HttpServletRequest context, @PathParam("networkId") String id)
+ throws ServiceException {
+ LOGGER.info("NetworkRoa::getNetwork id:{}", id);
+ Map<String, Object> map = new HashMap<>(10);
+ map.put(ParamConstant.PARAM_ID, id);
+ List<NetworkEntity> networks = network.getList(map);
+
+ JSONObject result = new JSONObject();
+ result.put("networks", networks.toString());
+ return result;
+ }
+
+ /**
+ *
+ * Add network.<br>
+ *
+ * @param context
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ @POST
+ @Consumes({MediaType.APPLICATION_JSON})
+ @Produces({MediaType.APPLICATION_JSON})
+ public JSONObject addNetwork(@Context HttpServletRequest context) throws ServiceException {
+ JSONObject object = RequestUtil.getJsonRequestBody(context);
+
+ LOGGER.info("NetworkRoa::addNetwork:{}", object.toString());
+ try {
+ int result = network.add(NetworkEntity.toEntity(object));
+ return RoaResponseUtil.add(result);
+ } catch(ServiceException se) {
+ LOGGER.error("NetworkRoa::addNetwork error:{}" + se);
+ return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage());
+ }
+ }
+
+ /**
+ *
+ * Delete network.<br>
+ *
+ * @param context
+ * @param id
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ @DELETE
+ @Consumes({MediaType.APPLICATION_JSON})
+ @Produces({MediaType.APPLICATION_JSON})
+ public JSONObject deleteNetwork(@Context HttpServletRequest context, @QueryParam(ParamConstant.PARAM_ID) String id)
+ throws ServiceException {
+ LOGGER.info("NetworkRoa::deleteNetwork id:{}", id);
+ try {
+ int result = network.delete(id);
+ return RoaResponseUtil.delete(result);
+ } catch(ServiceException se) {
+ LOGGER.error("NetworkRoa::deleteNetwork error:{}" + se);
+ return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage());
+ }
+ }
+
+ /**
+ *
+ * Update network.<br>
+ *
+ * @param context
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ @PUT
+ @Consumes({MediaType.APPLICATION_JSON})
+ @Produces({MediaType.APPLICATION_JSON})
+ public JSONObject updateNetwork(@Context HttpServletRequest context) throws ServiceException {
+ JSONObject object = RequestUtil.getJsonRequestBody(context);
+
+ LOGGER.info("NetworkRoa::updateNetwork:{}", object.toString());
+ try {
+ int result = network.update(object);
+ return RoaResponseUtil.update(result);
+ } catch(ServiceException se) {
+ LOGGER.error("NetworkRoa::updateNetwork error:{}" + se);
+ return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage());
+ }
+ }
+
+ public void setNetwork(Network network) {
+ this.network = network;
+ }
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/PortRoa.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/PortRoa.java
new file mode 100644
index 0000000..1d79f93
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/PortRoa.java
@@ -0,0 +1,183 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.rest;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+
+import org.openo.baseservice.remoteservice.exception.ServiceException;
+import org.openo.nfvo.resmanagement.common.constant.HttpConstant;
+import org.openo.nfvo.resmanagement.common.constant.ParamConstant;
+import org.openo.nfvo.resmanagement.common.constant.UrlConstant;
+import org.openo.nfvo.resmanagement.common.util.request.RequestUtil;
+import org.openo.nfvo.resmanagement.common.util.response.ResponseUtil;
+import org.openo.nfvo.resmanagement.common.util.response.RoaResponseUtil;
+import org.openo.nfvo.resmanagement.service.base.openstack.inf.Port;
+import org.openo.nfvo.resmanagement.service.entity.PortEntity;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import net.sf.json.JSONObject;
+
+/**
+ *
+ * Port ROA Class.<br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Sep 10, 2016
+ */
+@Path(UrlConstant.PORT_URL)
+@Produces(MediaType.APPLICATION_JSON)
+@Consumes(MediaType.APPLICATION_JSON)
+public class PortRoa {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(PortRoa.class);
+
+ private Port port;
+
+ /**
+ *
+ * Get details of Ports.<br>
+ *
+ * @param context
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ @GET
+ public JSONObject getPorts(@Context HttpServletRequest context) throws ServiceException {
+ Map<String, Object> map = new HashMap<>(10);
+ List<PortEntity> ports = port.getList(map);
+
+ JSONObject result = new JSONObject();
+ result.put("ports", ports);
+ return result;
+ }
+
+ /**
+ *
+ * Get port details.<br>
+ *
+ * @param context
+ * @param id
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ @GET
+ @Path("/{portId}")
+ public JSONObject getPort(@Context HttpServletRequest context, @PathParam("portId") String id)
+ throws ServiceException {
+ LOGGER.info("PortRoa::getPort id:{}", id);
+ Map<String, Object> map = new HashMap<>(10);
+ map.put(ParamConstant.PARAM_ID, id);
+ List<PortEntity> ports = port.getList(map);
+
+ JSONObject result = new JSONObject();
+ result.put("ports", ports);
+ return result;
+ }
+
+ /**
+ *
+ * Add port.<br>
+ *
+ * @param context
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ @POST
+ public JSONObject addPort(@Context HttpServletRequest context) throws ServiceException {
+ JSONObject object = RequestUtil.getJsonRequestBody(context);
+
+ LOGGER.info("PortRoa::addPort:{}", object.toString());
+ try {
+ int result = port.add(PortEntity.toEntity(object));
+ return RoaResponseUtil.add(result);
+ } catch(ServiceException se) {
+ LOGGER.error("PortRoa::addPort error:{}" + se);
+ return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage());
+ }
+ }
+
+ /**
+ *
+ * Delete port.<br>
+ *
+ * @param context
+ * @param id
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ @DELETE
+ public JSONObject deletePort(@Context HttpServletRequest context, @QueryParam(ParamConstant.PARAM_ID) String id)
+ throws ServiceException {
+ LOGGER.info("PortRoa::deletePort id:{}", id);
+ try {
+ int result = port.delete(id);
+ return RoaResponseUtil.delete(result);
+ } catch(ServiceException se) {
+ LOGGER.error("PortRoa::deletePort error:{}" + se);
+ return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage());
+ }
+ }
+
+ /**
+ *
+ * Update port.<br>
+ *
+ * @param context
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ @PUT
+ public JSONObject updatePort(@Context HttpServletRequest context) throws ServiceException {
+ JSONObject object = RequestUtil.getJsonRequestBody(context);
+
+ LOGGER.info("PortRoa::updatePort:{}", object.toString());
+ try {
+ int result = port.update(object);
+ return RoaResponseUtil.update(result);
+ } catch(ServiceException se) {
+ LOGGER.error("PortRoa::updatePort error:{}" + se);
+ return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage());
+ }
+ }
+
+ public void setPort(Port port) {
+ this.port = port;
+ }
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/ResOperateRoa.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/ResOperateRoa.java
new file mode 100644
index 0000000..1e68e83
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/ResOperateRoa.java
@@ -0,0 +1,151 @@
+/*
+ * Copyright 2016-2017 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.rest;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+
+import org.openo.baseservice.remoteservice.exception.ServiceException;
+import org.openo.nfvo.resmanagement.common.VimUtil;
+import org.openo.nfvo.resmanagement.common.constant.HttpConstant;
+import org.openo.nfvo.resmanagement.common.constant.ParamConstant;
+import org.openo.nfvo.resmanagement.common.constant.UrlConstant;
+import org.openo.nfvo.resmanagement.common.util.request.RequestUtil;
+import org.openo.nfvo.resmanagement.common.util.response.ResponseUtil;
+import org.openo.nfvo.resmanagement.common.util.response.RoaResponseUtil;
+import org.openo.nfvo.resmanagement.service.group.inf.ResOperateService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import net.sf.json.JSONObject;
+
+/**
+ * Resource Operate ROA Class.<br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Sep 10, 2016
+ */
+@Path(UrlConstant.RESOPERATE_URL)
+@Consumes(MediaType.APPLICATION_JSON)
+@Produces(MediaType.APPLICATION_JSON)
+public class ResOperateRoa {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(ResOperateRoa.class);
+
+ private ResOperateService resOperateService;
+
+ /**
+ * Update iResource pool.<br>
+ *
+ * @param context
+ * @param tenantId
+ * @param vimId
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ @PUT
+ @Path(UrlConstant.MODRES_URL)
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ public JSONObject updateIResPool(@Context HttpServletRequest context,
+ @QueryParam(ParamConstant.PARAM_VIMID) String vimId) throws ServiceException {
+ JSONObject json = RequestUtil.getAllJsonRequestBody(context);
+ LOGGER.warn("ResPoolRoa::modVimId :{}", vimId);
+ JSONObject vimInfo = VimUtil.getVimById(vimId);
+ String tenant = vimInfo.getString("tenant");
+ String tenantId = VimUtil.getTenantIdByName(tenant, vimId);
+ try {
+ resOperateService.updateIRes(tenantId, vimId, json);
+ resOperateService.sendMsgMonitor("update", vimId);
+ return RoaResponseUtil.update(HttpConstant.OK_CODE);
+ } catch(ServiceException se) {
+ LOGGER.error("ResOperateRoa::updateIResPool error:{}" + se);
+ return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage());
+ }
+ }
+
+ /**
+ * Add all resource pool.<br>
+ *
+ * @param context
+ * @param tenantId
+ * @param vimId
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ @POST
+ @Path(UrlConstant.ADDRES_URL)
+ @Consumes(UrlConstant.APPLICATION_TYPE)
+ @Produces(MediaType.APPLICATION_JSON)
+ public JSONObject addAllResPool(@Context HttpServletRequest context,
+ @QueryParam(ParamConstant.PARAM_TENANTID) String tenantId,
+ @QueryParam(ParamConstant.PARAM_VIMID) String vimId) throws ServiceException {
+ JSONObject json = RequestUtil.getAllJsonRequestBody(context);
+ LOGGER.warn("ResOperateRoa::vimId :{}", vimId);
+
+ try {
+ resOperateService.addIRes(tenantId, vimId, json);
+ resOperateService.sendMsgMonitor("create", vimId);
+ return RoaResponseUtil.add(HttpConstant.OK_CODE);
+ } catch(ServiceException se) {
+ LOGGER.error("ResOperateRoa::addAllResPool error:{}" + se);
+ return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage());
+ }
+ }
+
+ /**
+ * Delete iResource.<br>
+ *
+ * @param context
+ * @param vimId
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ @DELETE
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ public JSONObject deleteIRes(@Context HttpServletRequest context,
+ @QueryParam(ParamConstant.PARAM_VIMID) String vimId) throws ServiceException {
+ LOGGER.warn("ResOperateRoa::deleteIResource vimId:{}", vimId);
+
+ try {
+ resOperateService.sendMsgMonitor("delete", vimId);
+ int result = resOperateService.deleteIRes(vimId);
+ return RoaResponseUtil.delete(result);
+ } catch(ServiceException se) {
+ LOGGER.error("ResOperateRoa::deleteIRes error:{}" + se);
+ return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage());
+ }
+ }
+
+ public void setResOperateService(ResOperateService resOperateService) {
+ this.resOperateService = resOperateService;
+ }
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/SitesRoa.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/SitesRoa.java
new file mode 100644
index 0000000..192d33d
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/SitesRoa.java
@@ -0,0 +1,224 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.rest;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+
+import org.openo.baseservice.remoteservice.exception.ServiceException;
+import org.openo.nfvo.resmanagement.common.VimUtil;
+import org.openo.nfvo.resmanagement.common.constant.HttpConstant;
+import org.openo.nfvo.resmanagement.common.constant.ParamConstant;
+import org.openo.nfvo.resmanagement.common.constant.UrlConstant;
+import org.openo.nfvo.resmanagement.common.util.request.RequestUtil;
+import org.openo.nfvo.resmanagement.common.util.response.ResponseUtil;
+import org.openo.nfvo.resmanagement.common.util.response.RoaResponseUtil;
+import org.openo.nfvo.resmanagement.service.base.openstack.inf.Sites;
+import org.openo.nfvo.resmanagement.service.entity.SitesEntity;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import net.sf.json.JSONArray;
+import net.sf.json.JSONObject;
+
+/**
+ * Sites ROA method<br/>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Aug 24, 2016
+ */
+@Path(UrlConstant.SITES_URL)
+@Consumes(MediaType.APPLICATION_JSON)
+@Produces(MediaType.APPLICATION_JSON)
+public class SitesRoa {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(SitesRoa.class);
+
+ private Sites sites;
+
+ /**
+ * getSites ROA method<br/>
+ *
+ * @param context
+ * @return the get result
+ * @throws ServiceException When get failed.
+ * @since NFVO 0.5
+ */
+ @GET
+ public JSONObject getSites(@Context HttpServletRequest context) throws ServiceException {
+ Map<String, Object> map = new HashMap<String, Object>(10);
+ List<SitesEntity> datacenters = sites.getList(map);
+
+ JSONObject result = new JSONObject();
+ result.put("datacenters", datacenters);
+ return result;
+ }
+
+ /**
+ * getSite ROA method<br/>
+ *
+ * @param context
+ * @param id
+ * @return the get result
+ * @throws ServiceException When get failed.
+ * @since NFVO 0.5
+ */
+ @GET
+ @Path("/{datacenterId}")
+ public JSONObject getSite(@Context HttpServletRequest context, @PathParam("datacenterId") String id)
+ throws ServiceException {
+ LOGGER.warn("SitesRoa::getSitesById id:{}", id);
+ Map<String, Object> map = new HashMap<String, Object>(10);
+ map.put(ParamConstant.PARAM_ID, id);
+ List<SitesEntity> datacenters = sites.getList(map);
+
+ JSONObject result = new JSONObject();
+ result.put("datacenters", datacenters);
+ return result;
+ }
+
+ /**
+ * addSites ROA method<br/>
+ *
+ * @param context
+ * @param id
+ * @return the add result
+ * @throws ServiceException When add failed.
+ * @since NFVO 0.5
+ */
+ @POST
+ public JSONObject addSites(@Context HttpServletRequest context) throws ServiceException {
+ JSONObject json = RequestUtil.getAllJsonRequestBody(context);
+
+ LOGGER.warn("SitesRoa:: start add Sites");
+ try {
+ int result = sites.add(json);
+ sites.sendToMonitor(json);
+ return RoaResponseUtil.add(result);
+ } catch(ServiceException se) {
+ LOGGER.error("SitesRoa::addSites error:{}" + se);
+ return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage());
+ }
+ }
+
+ /**
+ * deleteSites ROA method<br/>
+ *
+ * @param context
+ * @param id
+ * @return the delete result
+ * @throws ServiceException When delete failed.
+ * @since NFVO 0.5
+ */
+ @DELETE
+ @Path("/{datacenterId}")
+ public JSONObject deleteSites(@Context HttpServletRequest context, @PathParam("datacenterId") String id)
+ throws ServiceException {
+ LOGGER.warn("SitesRoa::deleteSites siteId:{}", id);
+ try {
+ int result = sites.delete(id);
+ return RoaResponseUtil.delete(result);
+ } catch(ServiceException se) {
+ LOGGER.error("SitesRoa::deleteSites error: " + se);
+ return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage());
+ }
+ }
+
+ /**
+ * updateSites ROA method<br/>
+ *
+ * @param context
+ * @param id
+ * @return the update result
+ * @throws ServiceException When update failed.
+ * @since NFVO 0.5
+ */
+ @PUT
+ public JSONObject updateSites(@Context HttpServletRequest context) throws ServiceException {
+ JSONObject json = RequestUtil.getAllJsonRequestBody(context);
+
+ LOGGER.warn("SitesRoa::start update Sites");
+ try {
+ int result = sites.update(SitesEntity.toEntity(json));
+ return RoaResponseUtil.update(result);
+ } catch(ServiceException se) {
+ LOGGER.error("SitesRoa::updateSites error:" + se);
+ return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage());
+ }
+ }
+
+ /**
+ * grant resource method
+ * <br>
+ *
+ * @param context
+ * @return
+ * @throws ServiceException
+ * @since NFVO 0.5
+ */
+ @PUT
+ @Path("/grant")
+ public JSONObject grantResource(@Context HttpServletRequest context) throws ServiceException {
+ JSONObject json = RequestUtil.getAllJsonRequestBody(context);
+
+ LOGGER.warn("SitesRoa::grant resource");
+ try {
+ int result = sites.update(json);
+ return RoaResponseUtil.update(result);
+ } catch(ServiceException se) {
+ LOGGER.error("SitesRoa::grant resource:" + se);
+ return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage());
+ }
+ }
+
+ @GET
+ @Path("/vims")
+ public String getVims(@Context HttpServletRequest context) throws ServiceException {
+ LOGGER.info("SitesRoa::get vims");
+ JSONArray vims = VimUtil.getVims();
+ JSONObject result = new JSONObject();
+ result.put("data", vims);
+ return result.toString();
+ }
+
+ @GET
+ @Path("/vims/{vimId}")
+ public String getVim(@Context HttpServletRequest context, @PathParam("vimId") String vimId)
+ throws ServiceException {
+ LOGGER.info("SitesRoa::get vim by id: {}", vimId);
+ return VimUtil.getVimById(vimId).toString();
+ }
+
+ public void setSites(Sites sites) {
+ this.sites = sites;
+ }
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/SwaggerRoa.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/SwaggerRoa.java
new file mode 100644
index 0000000..0e9bf48
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/SwaggerRoa.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.rest;
+
+import java.io.IOException;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+import org.apache.commons.io.IOUtils;
+
+/**
+ * Swagger API Doc.<br/>
+ *
+ * @author
+ * @version NFVO 0.5 Oct 24, 2016
+ */
+@Path("/v1")
+@Produces({MediaType.APPLICATION_JSON})
+public class SwaggerRoa {
+ /**
+ * API doc.
+ * @param filename
+ * @return
+ * @throws IOException
+ */
+ @GET
+ @Path("/swagger.json")
+ public String apidoc() throws IOException{
+ ClassLoader classLoader = getClass().getClassLoader();
+ return IOUtils.toString(classLoader.getResourceAsStream("swagger.json"));
+ }
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/VirtualLinkRoa.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/VirtualLinkRoa.java
new file mode 100644
index 0000000..524a474
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/VirtualLinkRoa.java
@@ -0,0 +1,129 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.rest;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+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.Context;
+import javax.ws.rs.core.MediaType;
+
+import org.openo.baseservice.remoteservice.exception.ServiceException;
+import org.openo.nfvo.resmanagement.common.ResourceUtil;
+import org.openo.nfvo.resmanagement.common.constant.HttpConstant;
+import org.openo.nfvo.resmanagement.common.constant.ParamConstant;
+import org.openo.nfvo.resmanagement.common.constant.UrlConstant;
+import org.openo.nfvo.resmanagement.common.util.request.RequestUtil;
+import org.openo.nfvo.resmanagement.common.util.response.ResponseUtil;
+import org.openo.nfvo.resmanagement.common.util.response.RoaResponseUtil;
+import org.openo.nfvo.resmanagement.service.entity.VirtualLinkEntity;
+import org.openo.nfvo.resmanagement.service.group.inf.VirtualLinkService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import net.sf.json.JSONObject;
+
+/**
+ * <br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Oct 27, 2016
+ */
+@Path(UrlConstant.VL_URL)
+@Produces(MediaType.APPLICATION_JSON)
+@Consumes(MediaType.APPLICATION_JSON)
+public class VirtualLinkRoa {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(VirtualLinkRoa.class);
+
+ private VirtualLinkService virtualLink;
+
+ @GET
+ public JSONObject getVls(@Context HttpServletRequest context) throws ServiceException {
+ Map<String, Object> map = new HashMap<>(10);
+ List<VirtualLinkEntity> vls = virtualLink.getList(map);
+ LOGGER.info("VirtualLinkRoa::getVls:{}", vls.toString());
+ JSONObject result = new JSONObject();
+ result.put("vls", vls);
+ return result;
+ }
+
+ @GET
+ @Path("/{vlId}")
+ public JSONObject getVl(@Context HttpServletRequest context, @PathParam("vlId") String id) throws ServiceException {
+ LOGGER.info("VirtualLinkRoa::getVl id:{}", id);
+ Map<String, Object> map = new HashMap<>(10);
+ map.put(ParamConstant.PARAM_ID, id);
+ List<VirtualLinkEntity> vls = virtualLink.getList(map);
+ LOGGER.info("VirtualLinkRoa::getVl:{}", vls.toString());
+ JSONObject result = new JSONObject();
+ result.put("vls", vls);
+ return result;
+ }
+
+ @POST
+ public JSONObject addVl(@Context HttpServletRequest context) throws ServiceException {
+ JSONObject object = RequestUtil.getJsonRequestBody(context);
+ if(null == object) {
+ LOGGER.error("function=addVl; msg=add error, because vl is null.");
+ throw new ServiceException(
+ ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.virtualLink.add.null"));
+ }
+
+ LOGGER.info("VirtualLinkRoa::addVl:{}", object.toString());
+ try {
+ return virtualLink.addVl(VirtualLinkEntity.toEntity(object));
+ } catch(ServiceException se) {
+ LOGGER.error("VirtualLinkRoa::addVl error:{}" + se);
+ return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage());
+ }
+ }
+
+ @DELETE
+ @Path("/{id}")
+ public JSONObject deleteVl(@Context HttpServletRequest context, @PathParam(ParamConstant.PARAM_ID) String id)
+ throws ServiceException {
+ if(id == null) {
+ LOGGER.error("function=deleteVl; msg=delete error, because vlId is null.");
+ throw new ServiceException(
+ ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.virtualLink.delete.vlId.null"));
+ }
+ LOGGER.info("VirtualLinkRoa::deleteVl id:{}", id);
+ try {
+ int result = virtualLink.delete(id);
+ return RoaResponseUtil.delete(result);
+ } catch(ServiceException se) {
+ LOGGER.error("VirtualLinkRoa::deleteVl error:{}" + se);
+ return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage());
+ }
+ }
+
+ public void setVirtualLink(VirtualLinkService virtualLink) {
+ this.virtualLink = virtualLink;
+ }
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/VmRoa.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/VmRoa.java
new file mode 100644
index 0000000..cb9d2b6
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/VmRoa.java
@@ -0,0 +1,127 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.rest;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+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.Context;
+import javax.ws.rs.core.MediaType;
+
+import org.openo.baseservice.remoteservice.exception.ServiceException;
+import org.openo.nfvo.resmanagement.common.ResourceUtil;
+import org.openo.nfvo.resmanagement.common.constant.HttpConstant;
+import org.openo.nfvo.resmanagement.common.constant.ParamConstant;
+import org.openo.nfvo.resmanagement.common.constant.UrlConstant;
+import org.openo.nfvo.resmanagement.common.util.request.RequestUtil;
+import org.openo.nfvo.resmanagement.common.util.response.ResponseUtil;
+import org.openo.nfvo.resmanagement.common.util.response.RoaResponseUtil;
+import org.openo.nfvo.resmanagement.service.entity.VmEntity;
+import org.openo.nfvo.resmanagement.service.group.inf.VmService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import net.sf.json.JSONObject;
+
+/**
+ * <br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Oct 29, 2016
+ */
+@Path(UrlConstant.VM_URL)
+@Produces(MediaType.APPLICATION_JSON)
+@Consumes(MediaType.APPLICATION_JSON)
+public class VmRoa {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(VmRoa.class);
+
+ private VmService vmService;
+
+ @GET
+ public JSONObject getVms(@Context HttpServletRequest context) throws ServiceException {
+ Map<String, Object> map = new HashMap<>(10);
+ List<VmEntity> vms = vmService.getList(map);
+ LOGGER.info("VmRoa::getVms:{}", vms.toString());
+ JSONObject result = new JSONObject();
+ result.put("vms", vms);
+ return result;
+ }
+
+ @GET
+ @Path("/{vmId}")
+ public JSONObject getVm(@Context HttpServletRequest context, @PathParam("vmId") String id) throws ServiceException {
+ LOGGER.info("VmRoa::getVm id:{}", id);
+ Map<String, Object> map = new HashMap<>(10);
+ map.put(ParamConstant.PARAM_ID, id);
+ List<VmEntity> vms = vmService.getList(map);
+ LOGGER.info("VmRoa::getVm:{}", vms.toString());
+ JSONObject result = new JSONObject();
+ result.put("vms", vms);
+ return result;
+ }
+
+ @POST
+ public JSONObject addVm(@Context HttpServletRequest context) throws ServiceException {
+ JSONObject object = RequestUtil.getJsonRequestBody(context);
+ if(null == object) {
+ LOGGER.error("function=addVm; msg=add error, because vm is null.");
+ throw new ServiceException(ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.vm.add.null"));
+ }
+
+ LOGGER.info("VmRoa::addVm:{}", object.toString());
+ try {
+ return vmService.addVm(VmEntity.toEntity(object));
+ } catch(ServiceException se) {
+ LOGGER.error("VmRoa::addVm error:{}" + se);
+ return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage());
+ }
+ }
+
+ @DELETE
+ @Path("/{id}")
+ public JSONObject deleteVm(@Context HttpServletRequest context, @PathParam(ParamConstant.PARAM_ID) String id)
+ throws ServiceException {
+ if(id == null) {
+ LOGGER.error("function=deleteVm; msg=delete error, because id is null.");
+ throw new ServiceException(ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.vm.delete.id.null"));
+ }
+ LOGGER.info("VmRoa::deleteVm id:{}", id);
+ try {
+ int result = vmService.delete(id);
+ return RoaResponseUtil.delete(result);
+ } catch(ServiceException se) {
+ LOGGER.error("VmRoa::deleteVm error:{}" + se);
+ return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage());
+ }
+ }
+
+ public void setVmService(VmService vmService) {
+ this.vmService = vmService;
+ }
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/VnfInfoRoa.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/VnfInfoRoa.java
new file mode 100644
index 0000000..b6fd5a5
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/VnfInfoRoa.java
@@ -0,0 +1,129 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.rest;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+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.Context;
+import javax.ws.rs.core.MediaType;
+
+import org.openo.baseservice.remoteservice.exception.ServiceException;
+import org.openo.nfvo.resmanagement.common.ResourceUtil;
+import org.openo.nfvo.resmanagement.common.constant.HttpConstant;
+import org.openo.nfvo.resmanagement.common.constant.ParamConstant;
+import org.openo.nfvo.resmanagement.common.constant.UrlConstant;
+import org.openo.nfvo.resmanagement.common.util.request.RequestUtil;
+import org.openo.nfvo.resmanagement.common.util.response.ResponseUtil;
+import org.openo.nfvo.resmanagement.common.util.response.RoaResponseUtil;
+import org.openo.nfvo.resmanagement.service.entity.VnfInfoEntity;
+import org.openo.nfvo.resmanagement.service.group.inf.VnfInfoService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import net.sf.json.JSONObject;
+
+/**
+ * <br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Oct 28, 2016
+ */
+@Path(UrlConstant.VNFINFO_URL)
+@Produces(MediaType.APPLICATION_JSON)
+@Consumes(MediaType.APPLICATION_JSON)
+public class VnfInfoRoa {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(VnfInfoRoa.class);
+
+ private VnfInfoService vnfInfoService;
+
+ @GET
+ public JSONObject getVnfInfos(@Context HttpServletRequest context) throws ServiceException {
+ Map<String, Object> map = new HashMap<>(10);
+ List<VnfInfoEntity> vnfInfos = vnfInfoService.getList(map);
+ LOGGER.info("VnfInfoRoa::getVnfInfos:{}", vnfInfos.toString());
+ JSONObject result = new JSONObject();
+ result.put("vnfInfos", vnfInfos);
+ return result;
+ }
+
+ @GET
+ @Path("/{id}")
+ public JSONObject getVnfInfo(@Context HttpServletRequest context, @PathParam("id") String id)
+ throws ServiceException {
+ LOGGER.info("VnfInfoRoa::getVnfInfo id:{}", id);
+ Map<String, Object> map = new HashMap<>(10);
+ map.put(ParamConstant.PARAM_ID, id);
+ List<VnfInfoEntity> vnfInfos = vnfInfoService.getList(map);
+ LOGGER.info("VnfInfoRoa::getVnfInfo:{}", vnfInfos.toString());
+ JSONObject result = new JSONObject();
+ result.put("vnfInfos", vnfInfos);
+ return result;
+ }
+
+ @POST
+ public JSONObject addVnfInfo(@Context HttpServletRequest context) throws ServiceException {
+ JSONObject object = RequestUtil.getJsonRequestBody(context);
+ if(null == object) {
+ LOGGER.error("function=addVnfInfo; msg=add error, because vnfInfo is null.");
+ throw new ServiceException(ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.vnfInfo.add.null"));
+ }
+
+ LOGGER.info("VnfInfoRoa::addVnfInfo:{}", object.toString());
+ try {
+ return vnfInfoService.addVnfInfo(object);
+ } catch(ServiceException se) {
+ LOGGER.error("VnfInfoRoa::addVnfInfo error:{}" + se);
+ return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage());
+ }
+ }
+
+ @DELETE
+ @Path("/{id}")
+ public JSONObject deleteVnfInfo(@Context HttpServletRequest context, @PathParam(ParamConstant.PARAM_ID) String id)
+ throws ServiceException {
+ if(id == null) {
+ LOGGER.error("function=deleteVnfInfo; msg=delete error, because id is null.");
+ throw new ServiceException(
+ ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.vnfInfo.delete.id.null"));
+ }
+ LOGGER.info("VnfInfoRoa::deleteVnfInfo id:{}", id);
+ try {
+ int result = vnfInfoService.delete(id);
+ return RoaResponseUtil.delete(result);
+ } catch(ServiceException se) {
+ LOGGER.error("VnfInfoRoa::deleteVnfInfo error:{}" + se);
+ return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage());
+ }
+ }
+
+ public void setVnfInfoService(VnfInfoService vnfInfoService) {
+ this.vnfInfoService = vnfInfoService;
+ }
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/VnfRoa.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/VnfRoa.java
new file mode 100644
index 0000000..4d5fc47
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/VnfRoa.java
@@ -0,0 +1,128 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.rest;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+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.Context;
+import javax.ws.rs.core.MediaType;
+
+import org.openo.baseservice.remoteservice.exception.ServiceException;
+import org.openo.nfvo.resmanagement.common.ResourceUtil;
+import org.openo.nfvo.resmanagement.common.constant.HttpConstant;
+import org.openo.nfvo.resmanagement.common.constant.ParamConstant;
+import org.openo.nfvo.resmanagement.common.constant.UrlConstant;
+import org.openo.nfvo.resmanagement.common.util.request.RequestUtil;
+import org.openo.nfvo.resmanagement.common.util.response.ResponseUtil;
+import org.openo.nfvo.resmanagement.common.util.response.RoaResponseUtil;
+import org.openo.nfvo.resmanagement.service.entity.VnfEntity;
+import org.openo.nfvo.resmanagement.service.group.inf.VnfService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import net.sf.json.JSONObject;
+
+/**
+ * <br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Oct 28, 2016
+ */
+@Path(UrlConstant.VNF_URL)
+@Produces(MediaType.APPLICATION_JSON)
+@Consumes(MediaType.APPLICATION_JSON)
+public class VnfRoa {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(VirtualLinkRoa.class);
+
+ private VnfService vnfService;
+
+ @GET
+ public JSONObject getVnfs(@Context HttpServletRequest context) throws ServiceException {
+ Map<String, Object> map = new HashMap<>(10);
+ List<VnfEntity> vnfs = vnfService.getList(map);
+ LOGGER.info("VnfRoa::getVnfs:{}", vnfs.toString());
+ JSONObject result = new JSONObject();
+ result.put("vnfs", vnfs);
+ return result;
+ }
+
+ @GET
+ @Path("/{vnfId}")
+ public JSONObject getVnf(@Context HttpServletRequest context, @PathParam("vnfId") String id)
+ throws ServiceException {
+ LOGGER.info("VnfRoa::getVnf id:{}", id);
+ Map<String, Object> map = new HashMap<>(10);
+ map.put(ParamConstant.PARAM_ID, id);
+ List<VnfEntity> vnfs = vnfService.getList(map);
+ LOGGER.info("VnfRoa::getVnf:{}", vnfs.toString());
+ JSONObject result = new JSONObject();
+ result.put("vnfs", vnfs);
+ return result;
+ }
+
+ @POST
+ public JSONObject addVnf(@Context HttpServletRequest context) throws ServiceException {
+ JSONObject object = RequestUtil.getJsonRequestBody(context);
+ if(null == object) {
+ LOGGER.error("function=addVnf; msg=add error, because vnf is null.");
+ throw new ServiceException(ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.vnf.add.null"));
+ }
+
+ LOGGER.info("VnfRoa::addVnf:{}", object.toString());
+ try {
+ return vnfService.addVnf(VnfEntity.toEntity(object));
+ } catch(ServiceException se) {
+ LOGGER.error("VnfRoa::addVnf error:{}" + se);
+ return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage());
+ }
+ }
+
+ @DELETE
+ @Path("/{id}")
+ public JSONObject deleteVnf(@Context HttpServletRequest context, @PathParam(ParamConstant.PARAM_ID) String id)
+ throws ServiceException {
+ if(id == null) {
+ LOGGER.error("function=deleteVnf; msg=delete error, because id is null.");
+ throw new ServiceException(ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.vnf.delete.id.null"));
+ }
+ LOGGER.info("VnfRoa::deleteVnf id:{}", id);
+ try {
+ int result = vnfService.delete(id);
+ return RoaResponseUtil.delete(result);
+ } catch(ServiceException se) {
+ LOGGER.error("VnfRoa::deleteVnf error:{}" + se);
+ return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage());
+ }
+ }
+
+ public void setVnfService(VnfService vnfService) {
+ this.vnfService = vnfService;
+ }
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/VnfStatusRoa.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/VnfStatusRoa.java
new file mode 100644
index 0000000..1e7d9f4
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/VnfStatusRoa.java
@@ -0,0 +1,129 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.rest;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+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.Context;
+import javax.ws.rs.core.MediaType;
+
+import org.openo.baseservice.remoteservice.exception.ServiceException;
+import org.openo.nfvo.resmanagement.common.ResourceUtil;
+import org.openo.nfvo.resmanagement.common.constant.HttpConstant;
+import org.openo.nfvo.resmanagement.common.constant.ParamConstant;
+import org.openo.nfvo.resmanagement.common.constant.UrlConstant;
+import org.openo.nfvo.resmanagement.common.util.request.RequestUtil;
+import org.openo.nfvo.resmanagement.common.util.response.ResponseUtil;
+import org.openo.nfvo.resmanagement.common.util.response.RoaResponseUtil;
+import org.openo.nfvo.resmanagement.service.entity.VnfStatusEntity;
+import org.openo.nfvo.resmanagement.service.group.inf.VnfStatusService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import net.sf.json.JSONObject;
+
+/**
+ * <br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version NFVO 0.5 Oct 29, 2016
+ */
+@Path(UrlConstant.VNFSTATUS_URL)
+@Produces(MediaType.APPLICATION_JSON)
+@Consumes(MediaType.APPLICATION_JSON)
+public class VnfStatusRoa {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(VnfStatusRoa.class);
+
+ private VnfStatusService vnfStatusService;
+
+ @GET
+ public JSONObject getVnfStatuss(@Context HttpServletRequest context) throws ServiceException {
+ Map<String, Object> map = new HashMap<>(10);
+ List<VnfStatusEntity> vnfStatus = vnfStatusService.getList(map);
+ LOGGER.info("VnfStatusRoa::getVnfStatuss:{}", vnfStatus.toString());
+ JSONObject result = new JSONObject();
+ result.put("vnfStatus", vnfStatus);
+ return result;
+ }
+
+ @GET
+ @Path("/{id}")
+ public JSONObject getVnfStatus(@Context HttpServletRequest context, @PathParam("id") String id)
+ throws ServiceException {
+ LOGGER.info("VnfStatusRoa::getVnfStatus id:{}", id);
+ Map<String, Object> map = new HashMap<>(10);
+ map.put(ParamConstant.PARAM_ID, id);
+ List<VnfStatusEntity> vnfStatus = vnfStatusService.getList(map);
+ LOGGER.info("VnfStatusRoa::getVnfStatus:{}", vnfStatus.toString());
+ JSONObject result = new JSONObject();
+ result.put("vnfStatus", vnfStatus);
+ return result;
+ }
+
+ @POST
+ public JSONObject addVnfStatus(@Context HttpServletRequest context) throws ServiceException {
+ JSONObject object = RequestUtil.getJsonRequestBody(context);
+ if(null == object) {
+ LOGGER.error("function=addVnfInfo; msg=add error, because vnfStatus is null.");
+ throw new ServiceException(ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.vnfStatus.add.null"));
+ }
+
+ LOGGER.info("VnfStatusRoa::addVnfStatus:{}", object.toString());
+ try {
+ return vnfStatusService.addVnfStatus(object);
+ } catch(ServiceException se) {
+ LOGGER.error("VnfStatusRoa::addVnfStatus error:{}" + se);
+ return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage());
+ }
+ }
+
+ @DELETE
+ @Path("/{id}")
+ public JSONObject deleteVnfStatus(@Context HttpServletRequest context, @PathParam(ParamConstant.PARAM_ID) String id)
+ throws ServiceException {
+ if(id == null) {
+ LOGGER.error("function=deleteVnfStatus; msg=delete error, because id is null.");
+ throw new ServiceException(
+ ResourceUtil.getMessage("org.openo.nfvo.resmanage.service.vnfStatus.delete.id.null"));
+ }
+ LOGGER.info("VnfStatusRoa::deleteVnfStatus id:{}", id);
+ try {
+ int result = vnfStatusService.delete(id);
+ return RoaResponseUtil.delete(result);
+ } catch(ServiceException se) {
+ LOGGER.error("VnfStatusRoa::deleteVnfStatys error:{}" + se);
+ return ResponseUtil.genHttpResponse(HttpConstant.ERROR_CODE, se.getMessage());
+ }
+ }
+
+ public void setVnfStatusService(VnfStatusService vnfStatusService) {
+ this.vnfStatusService = vnfStatusService;
+ }
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/exceptionmapper/ExceptionMessage.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/exceptionmapper/ExceptionMessage.java
new file mode 100644
index 0000000..8f57345
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/exceptionmapper/ExceptionMessage.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.rest.exceptionmapper;
+
+import org.apache.http.HttpStatus;
+
+/**
+ * Exception response model.<br>
+ *
+ * @author
+ * @version NFVO 0.5 Sep 27, 2016
+ */
+public class ExceptionMessage {
+
+ private String errorCode = "unknown.error";
+
+ private int httpCode = HttpStatus.SC_INTERNAL_SERVER_ERROR;
+
+ private String message;
+
+ @Override
+ public String toString() {
+ return "Error {errorCode=" + this.errorCode + ", httpCode=" + this.httpCode + ", message="
+ + this.message + "}";
+ }
+
+ public String getErrorCode() {
+ return this.errorCode;
+ }
+
+ public void setErrorCode(String errorCode) {
+ this.errorCode = errorCode;
+ }
+
+ public String getMessage() {
+ return this.message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public int getHttpCode() {
+ return this.httpCode;
+ }
+
+ public void setHttpCode(int httpCode) {
+ this.httpCode = httpCode;
+ }
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/exceptionmapper/GenericExceptionMapper.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/exceptionmapper/GenericExceptionMapper.java
new file mode 100644
index 0000000..d557e0c
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/exceptionmapper/GenericExceptionMapper.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.rest.exceptionmapper;
+
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.ext.ExceptionMapper;
+import javax.ws.rs.ext.Provider;
+
+/**
+ * Generic exception response provider.<br>
+ *
+ *
+ * @author
+ * @version NFVO 0.5 Sep 27, 2016
+ */
+@Provider
+public class GenericExceptionMapper implements ExceptionMapper<Exception>{
+
+ @Override
+ public Response toResponse(Exception exception) {
+ ExceptionMessage message = new ExceptionMessage();
+ message.setMessage(exception.getMessage());
+ return Response.status(message.getHttpCode()).type(
+ MediaType.APPLICATION_JSON).entity(message).build();
+ }
+}
diff --git a/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/exceptionmapper/ServiceExceptionMapper.java b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/exceptionmapper/ServiceExceptionMapper.java
new file mode 100644
index 0000000..a45852a
--- /dev/null
+++ b/ResmanagementService/service/src/main/java/org/openo/nfvo/resmanagement/service/rest/exceptionmapper/ServiceExceptionMapper.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2016 Huawei Technologies Co., Ltd.
+ *
+ * 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.openo.nfvo.resmanagement.service.rest.exceptionmapper;
+
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.ext.ExceptionMapper;
+import javax.ws.rs.ext.Provider;
+
+import org.openo.baseservice.remoteservice.exception.ServiceException;
+
+/**
+ * ServiceException response provider.<br>
+ *
+ * @author
+ * @version NFVO 0.5 Sep 27, 2016
+ */
+@Provider
+public class ServiceExceptionMapper implements ExceptionMapper<ServiceException>{
+
+ @Override
+ public Response toResponse(ServiceException exception) {
+ ExceptionMessage message = new ExceptionMessage();
+ message.setErrorCode(exception.getId());
+ message.setHttpCode(exception.getHttpCode());
+ message.setMessage(exception.getMessage());
+ return Response.status(message.getHttpCode()).
+ type(MediaType.APPLICATION_JSON).entity(message).build();
+ }
+
+}