diff options
author | 2017-10-11 09:17:55 +0800 | |
---|---|---|
committer | 2017-10-11 09:17:55 +0800 | |
commit | 14349787812c074d1732eafd4e3c022a5b30cb50 (patch) | |
tree | 6c2040cbccfbf210afb2a7dc317d0e0050401837 | |
parent | 83e82ed990cadbe3cfa32fb6250f733db035d089 (diff) |
Add vfc-lcm operate subnet from AAI
Change-Id: I55869add6cfb3eac11ba26f921351b71159bb5bd
Issue-ID: VFC-516
Signed-off-by: ying.yunlong <ying.yunlong@zte.com.cn>
-rw-r--r-- | lcm/pub/msapi/aai.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/lcm/pub/msapi/aai.py b/lcm/pub/msapi/aai.py index ec0bee93..5ceb4159 100644 --- a/lcm/pub/msapi/aai.py +++ b/lcm/pub/msapi/aai.py @@ -293,3 +293,32 @@ def delete_network_relationship(network_id): logger.error("Status code is %s, detail is %s.", ret[2], ret[1]) raise NSLCMException("Delete network relationship exception in AAI") return json.JSONDecoder().decode(ret[1]), ret[2] + + +def create_subnet_aai(network_id, subnet_id, data): + resource = "/network/l3-networks/l3-network/%s/subnets/subnet/%s" % (network_id, subnet_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("Subnetwork creation exception in AAI") + return json.JSONDecoder().decode(ret[1]), ret[2] + + +def query_subnet_aai(network_id, subnet_id): + resource = "/network/l3-networks/l3-network/%s/subnets/subnet/%s" % (network_id, subnet_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("Subnetwork query exception in AAI") + return json.JSONDecoder().decode(ret[1]) + + +def delete_subnet_aai(network_id, subnet_id, resource_version=""): + resource = "/network/l3-networks/l3-network/%s/subnets/subnet/%s" % (network_id, subnet_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("Subnetwork delete exception in AAI") + return json.JSONDecoder().decode(ret[1]), ret[2] |