summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorying.yunlong <ying.yunlong@zte.com.cn>2017-09-13 17:04:25 +0800
committerying.yunlong <ying.yunlong@zte.com.cn>2017-09-13 17:04:25 +0800
commit9adcfb57b0eda21da23b0270c07c59dd11b95238 (patch)
tree9f89158c3a350c11d2b3ba07a2f5d3b7a032f96d
parentab274dc0dfe83950f311aeabe0b5293fe732c411 (diff)
Implement lcm customer operation to aai
Change-Id: I013274647c1121ecf11f26c62c28ee03985674c9 Issue-ID: VFC-352 Signed-off-by: ying.yunlong <ying.yunlong@zte.com.cn>
-rw-r--r--lcm/pub/msapi/aai.py50
1 files changed, 42 insertions, 8 deletions
diff --git a/lcm/pub/msapi/aai.py b/lcm/pub/msapi/aai.py
index 64cb8965..c22b0380 100644
--- a/lcm/pub/msapi/aai.py
+++ b/lcm/pub/msapi/aai.py
@@ -12,14 +12,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+
import json
import logging
import uuid
+from lcm.pub.config.config import AAI_BASE_URL, AAI_USER, AAI_PASSWD
from lcm.pub.exceptions import NSLCMException
from lcm.pub.utils import restcall
-from lcm.pub.config.config import AAI_BASE_URL, AAI_USER, AAI_PASSWD
-from lcm.pub.utils.values import ignore_case_get
logger = logging.getLogger(__name__)
@@ -39,6 +39,34 @@ def call_aai(resource, method, content=''):
content,
additional_headers)
+def create_customer_aai(global_customer_id, data):
+ resource = "/business/customers/customer/%s" % global_customer_id
+ ret = call_aai(resource, "PUT", data)
+ if ret[0] != 0:
+ logger.error("Status code is %s, detail is %s.", ret[2], ret[1])
+ raise NSLCMException("Customer creation exception in AAI")
+ return json.JSONDecoder().decode(ret[1])
+
+
+def get_customer_aai(global_customer_id):
+ resource = "/business/customers/customer/%s" % global_customer_id
+ ret = call_aai(resource, "GET")
+ if ret[0] != 0:
+ logger.error("Status code is %s, detail is %s.", ret[2], ret[1])
+ raise NSLCMException("Get customer info exception in AAI")
+ return json.JSONDecoder().decode(ret[1])
+
+
+def delete_customer_aai(global_customer_id, resource_version=""):
+ resource = "/business/customers/customer/%s" % global_customer_id
+ if resource_version:
+ resource = resource + "?resource-version=%s" % resource_version
+ ret = call_aai(resource, "DELETE")
+ if ret[0] != 0:
+ logger.error("Status code is %s, detail is %s.", ret[2], ret[1])
+ raise NSLCMException("Customer delete exception in AAI")
+ return json.JSONDecoder().decode(ret[1])
+
def create_ns_aai(global_customer_id, service_type, service_instance_id, data):
resource = "/business/customers/customer/%s/service-subscriptions/service-subscription/" \
@@ -50,11 +78,13 @@ def create_ns_aai(global_customer_id, service_type, service_instance_id, data):
raise NSLCMException("Ns instance creation exception in AAI")
return json.JSONDecoder().decode(ret[1])
-def delete_ns_aai(global_customer_id, service_type, service_instance_id, data=''):
+def delete_ns_aai(global_customer_id, service_type, service_instance_id, resource_version=""):
resource = "/business/customers/customer/%s/service-subscriptions/service-subscription/" \
"%s/service-instances/service-instance/%s" % \
(global_customer_id, service_type, service_instance_id)
- ret = call_aai(resource, "DELETE", data)
+ if resource_version:
+ resource = resource + "?resource-version=%s" % resource_version
+ ret = call_aai(resource, "DELETE")
if ret[0] != 0:
logger.error("Status code is %s, detail is %s.", ret[2], ret[1])
raise NSLCMException("Ns instance delete exception in AAI")
@@ -78,9 +108,11 @@ def create_vnf_aai(vnf_id, data):
raise NSLCMException("Vnf instance creation exception in AAI")
return json.JSONDecoder().decode(ret[1])
-def delete_vnf_aai(vnf_id, data=''):
+def delete_vnf_aai(vnf_id, resource_version=""):
resource = "/network/generic-vnfs/generic-vnf/%s" % vnf_id
- ret = call_aai(resource, "DELETE", data)
+ if resource_version:
+ resource = resource + "?resource-version=%s" % resource_version
+ ret = call_aai(resource, "DELETE")
if ret[0] != 0:
logger.error("Status code is %s, detail is %s.", ret[2], ret[1])
raise NSLCMException("Vnf instance delete exception in AAI")
@@ -104,11 +136,13 @@ def create_vserver_aai(cloud_owner, cloud_region_id, tenant_id, vserver_id, data
raise NSLCMException("Vserver creation exception in AAI")
return json.JSONDecoder().decode(ret[1])
-def delete_vserver_aai(cloud_owner, cloud_region_id, tenant_id, vserver_id, data=''):
+def delete_vserver_aai(cloud_owner, cloud_region_id, tenant_id, vserver_id, resource_version=""):
resource = "/cloud-infrastructure/cloud-regions/cloud-region/%s/" \
"%s/tenants/tenant/%s/vservers/vserver/%s" % \
(cloud_owner, cloud_region_id, tenant_id, vserver_id)
- ret = call_aai(resource, "DELETE", data)
+ if resource_version:
+ resource = resource + "?resource-version=%s" % resource_version
+ ret = call_aai(resource, "DELETE")
if ret[0] != 0:
logger.error("Status code is %s, detail is %s.", ret[2], ret[1])
raise NSLCMException("Vserver delete exception in AAI")