summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lcm/lcm/nf/vnfs/tests/test_vnf_cancel.py4
-rw-r--r--lcm/lcm/nf/vnfs/tests/test_vnf_create.py5
-rw-r--r--lcm/lcm/nf/vnfs/vnf_cancel/delete_vnf_identifier.py7
-rw-r--r--lcm/lcm/pub/aaiapi/aai.py16
-rw-r--r--lcm/lcm/pub/config/config.py7
-rw-r--r--lcm/lcm/pub/utils/restcall.py49
6 files changed, 73 insertions, 15 deletions
diff --git a/lcm/lcm/nf/vnfs/tests/test_vnf_cancel.py b/lcm/lcm/nf/vnfs/tests/test_vnf_cancel.py
index e4cf7d90..52dbbe34 100644
--- a/lcm/lcm/nf/vnfs/tests/test_vnf_cancel.py
+++ b/lcm/lcm/nf/vnfs/tests/test_vnf_cancel.py
@@ -97,7 +97,7 @@ class TestNFTerminate(TestCase):
TermVnf(data, nf_inst_id=self.nf_inst_id, job_id=self.job_id).run()
self.assert_job_result(self.job_id, 255, "VnfInst(%s) does not exist" % self.nf_inst_id)
"""
-"""
+ """
@mock.patch.object(restcall, 'call_req')
@mock.patch.object(api, 'call')
def test_terminate_vnf_success(self, mock_call, mock_call_req):
@@ -117,4 +117,4 @@ class TestNFTerminate(TestCase):
JobUtil.add_job_status(self.job_id, 0, "INST_VNF_READY")
TermVnf(data, nf_inst_id=self.nf_inst_id, job_id=self.job_id).run()
self.assert_job_result(self.job_id, 100, "Terminate Vnf success.")
-"""
+ """
diff --git a/lcm/lcm/nf/vnfs/tests/test_vnf_create.py b/lcm/lcm/nf/vnfs/tests/test_vnf_create.py
index 9edd6076..8b24ee49 100644
--- a/lcm/lcm/nf/vnfs/tests/test_vnf_create.py
+++ b/lcm/lcm/nf/vnfs/tests/test_vnf_create.py
@@ -68,7 +68,7 @@ class TestNFInstantiate(TestCase):
mock_run.re.return_value = None
response = self.client.post("/api/vnflcm/v1/vnf_instances/12/instantiate", data={}, format='json')
self.failUnlessEqual(status.HTTP_202_ACCEPTED, response.status_code)
-"""
+ """
def test_instantiate_vnf_when_inst_id_not_exist(self):
self.nf_inst_id = str(uuid.uuid4())
self.job_id = JobUtil.create_job('NF', 'CREATE', self.nf_inst_id)
@@ -179,5 +179,4 @@ class TestNFInstantiate(TestCase):
data = inst_req_data
InstVnf(data, nf_inst_id=self.nf_inst_id, job_id=self.job_id).run()
self.assert_job_result(self.job_id, 100, "Instantiate Vnf success.")
-
-""" \ No newline at end of file
+ """ \ No newline at end of file
diff --git a/lcm/lcm/nf/vnfs/vnf_cancel/delete_vnf_identifier.py b/lcm/lcm/nf/vnfs/vnf_cancel/delete_vnf_identifier.py
index 33eb7ded..1eedb543 100644
--- a/lcm/lcm/nf/vnfs/vnf_cancel/delete_vnf_identifier.py
+++ b/lcm/lcm/nf/vnfs/vnf_cancel/delete_vnf_identifier.py
@@ -13,8 +13,6 @@
# limitations under the License.
import logging
-from lcm.pub.aaiapi.aai import call_aai
-from lcm.pub.config.config import AAI_BASE_URL
from lcm.pub.database.models import NfInstModel, NfvoRegInfoModel
logger = logging.getLogger(__name__)
@@ -35,8 +33,3 @@ class DeleteVnf:
# raise NFLCMException("Don't allow to delete vnf(status:[%s])" % sel_vnf.status)
NfInstModel.objects.filter(nfinstid=self.nf_inst_id).delete()
NfvoRegInfoModel.objects.filter(nfvoid=self.nf_inst_id).delete()
-
- def delete_data_from_aai(self, req_data):
- full_url = AAI_BASE_URL + "api/aai-service-design-and-creation/v1/%s" % self.nf_inst_id
- del_result = call_aai(full_url, "DELETE", req_data)
- pass \ No newline at end of file
diff --git a/lcm/lcm/pub/aaiapi/aai.py b/lcm/lcm/pub/aaiapi/aai.py
index a512315e..d97f1594 100644
--- a/lcm/lcm/pub/aaiapi/aai.py
+++ b/lcm/lcm/pub/aaiapi/aai.py
@@ -11,6 +11,18 @@
# 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.
+import logging
-def call_aai(full_url, method, req_data):
- pass \ No newline at end of file
+logger = logging.getLogger(__name__)
+
+
+def create_ns(ns_id, data):
+ pass
+
+
+def create_vnf(vnf_id, data):
+ pass
+
+
+def create_vserver(cloud_owner, cloud_region_id, tenant_id, vserver_id, data):
+ pass
diff --git a/lcm/lcm/pub/config/config.py b/lcm/lcm/pub/config/config.py
index 142a4a60..492595df 100644
--- a/lcm/lcm/pub/config/config.py
+++ b/lcm/lcm/pub/config/config.py
@@ -20,7 +20,12 @@ MSB_SERVICE_PORT = '80'
# [AAI]
AAI_SERVICE_IP = '127.0.0.1'
AAI_SERVICE_PORT = '8443'
-AAI_BASE_URL = "https://%s:%s/" % (AAI_SERVICE_IP, AAI_SERVICE_PORT)
+AAI_BASE_URL = "https://%s:%s/aai/v8" % (AAI_SERVICE_IP, AAI_SERVICE_PORT)
+AAI_USER = "AAI"
+AAI_PASSWORD = "AAI"
+CLOUD_OWNER = "11"
+CLOUD_REGION_ID = ""
+TENANT_ID = ""
# [REDIS]
REDIS_HOST = '127.0.0.1'
diff --git a/lcm/lcm/pub/utils/restcall.py b/lcm/lcm/pub/utils/restcall.py
index 663f16cb..1fbe59f9 100644
--- a/lcm/lcm/pub/utils/restcall.py
+++ b/lcm/lcm/pub/utils/restcall.py
@@ -93,3 +93,52 @@ def combine_url(base_url, resource):
else:
full_url = base_url + '/' + resource
return full_url
+
+
+def call_req_aai(base_url, user, passwd, auth_type, resource, method, content=''):
+ callid = str(uuid.uuid1())
+ logger.debug("[%s]call_req('%s','%s','%s',%s,'%s','%s','%s')" % (
+ callid, base_url, user, passwd, auth_type, resource, method, content))
+ ret = None
+ resp_status = ''
+ try:
+ full_url = combine_url(base_url, resource)
+ headers = {'content-type': 'application/json', 'accept': 'application/json',
+ 'X-FromAppId': 'AAI', 'X-TransactionId': 'get_aai_subscr'}
+ if user:
+ headers['Authorization'] = 'Basic ' + ('%s:%s' % (user, passwd)).encode("base64")
+ ca_certs = None
+ for retry_times in range(3):
+ http = httplib2.Http(ca_certs=ca_certs, disable_ssl_certificate_validation=(auth_type == rest_no_auth))
+ http.follow_all_redirects = True
+ try:
+ resp, resp_content = http.request(full_url, method=method.upper(), body=content, headers=headers)
+ resp_status, resp_body = resp['status'], resp_content.decode('UTF-8')
+ logger.debug("[%s][%d]status=%s,resp_body=%s)" % (callid, retry_times, resp_status, resp_body))
+ if resp_status in status_ok_list:
+ ret = [0, resp_body, resp_status]
+ else:
+ ret = [1, resp_body, resp_status]
+ break
+ except Exception as ex:
+ if 'httplib.ResponseNotReady' in str(sys.exc_info()):
+ logger.debug("retry_times=%d", retry_times)
+ logger.error(traceback.format_exc())
+ ret = [1, "Unable to connect to %s" % full_url, resp_status]
+ continue
+ raise ex
+ except urllib2.URLError as err:
+ ret = [2, str(err), resp_status]
+ except Exception as ex:
+ logger.error(traceback.format_exc())
+ logger.error("[%s]ret=%s" % (callid, str(sys.exc_info())))
+ res_info = str(sys.exc_info())
+ if 'httplib.ResponseNotReady' in res_info:
+ res_info = "The URL[%s] request failed or is not responding." % full_url
+ ret = [3, res_info, resp_status]
+ except:
+ logger.error(traceback.format_exc())
+ ret = [4, str(sys.exc_info()), resp_status]
+
+ logger.debug("[%s]ret=%s" % (callid, str(ret)))
+ return ret \ No newline at end of file