target/
logs/*.log
*.pyc
+.tox
+.coverage
+htmlcov/
+
[gerrit]
-host=gerrit.open-o.org
+host=gerrit.onap.org
port=29418
-project=multivimdriver-openstack.git
+project=multicloud/openstack.git
+.project
+.classpath
+.settings/
+.checkstyle
+target/
logs/*.log
-*.pyc
\ No newline at end of file
+*.pyc
+.tox
+.coverage
+htmlcov/
+
"alias": "epa-caps",
"description": "Multiple network support",
"name": "EPACapsQuery",
- 'links': [ \
- {
- "url": "http://%s:%s/api/multicloud-newton/v0/%s/extensions/epa-caps" \
- % (config.MSB_SERVICE_IP, config.MSB_SERVICE_PORT, vimid), \
- }
- ]
+ "url": "http://%s:%s/api/multicloud-newton/v0/%s/extensions/epa-caps" \
+ % (config.MSB_SERVICE_IP, config.MSB_SERVICE_PORT, vimid),
+ "spec": ""
}
]
MSB_SERVICE_IP = '127.0.0.1'
MSB_SERVICE_PORT = '80'
+# [A&AI]
+AAI_ADDR = "aai.api.simpledemo.openecomp.org"
+AAI_PORT = "8443"
+AAI_SERVICE_URL = 'https://%s:%s/aai' % (AAI_ADDR, AAI_PORT)
+AAI_SCHEMA_VERSION = "v11"
+AAI_USERNAME = 'AAI'
+AAI_PASSWORD = 'AAI'
+
+AAI_APP_ID = 'MultiCloud-Newton'
+
# [IMAGE LOCAL PATH]
ROOT_PATH = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from rest_framework import status
from newton.pub.exceptions import VimDriverNewtonException
-from newton.pub.utils.restcall import req_by_msb
+from newton.pub.utils.restcall import req_by_msb,req_to_aai
+
logger = logging.getLogger(__name__)
if cloud_owner and cloud_region_id:
retcode, content, status_code = \
- req_by_msb("/api/aai-cloudInfrastructure/v1/cloud-infrastructure/cloud-regions/cloud-region/%s/%s"
- % (cloud_owner,cloud_region_id), "GET")
+ req_to_aai("/cloud-infrastructure/cloud-regions/cloud-region/%s/%s"
+ % (cloud_owner,cloud_region_id),"GET")
if retcode != 0:
logger.error("Status code is %s, detail is %s.", status_code, content)
raise VimDriverNewtonException(
- "Failed to query VIM with id (%s:%s,%s) from extsys." % (vim_id,cloud_owner,cloud_region_id),
+ "Failed to query VIM with id (%s:%s,%s)." % (vim_id,cloud_owner,cloud_region_id),
status_code, content)
tmp_viminfo = json.JSONDecoder().decode(content)
+
+ #assume esr-system-info-id is composed by {cloud-owner} _ {cloud-region-id}
+ retcode2,content2,status_code2 = \
+ req_to_aai("/cloud-infrastructure/esr-system-info/%s/%s/%s_%s" \
+ % (cloud_owner,cloud_region_id,cloud_owner,cloud_region_id),
+ "GET")
+ if retcode2 != 0:
+ logger.error("Status code is %s, detail is %s.", status_code, content)
+ raise VimDriverNewtonException(
+ "Failed to query ESR system with id (%s:%s,%s)." % (vim_id,cloud_owner,cloud_region_id),
+ status_code, content)
+ tmp_authinfo = json.JSONDecoder().decode(content2)
+
#convert vim information
- #tbd
if tmp_viminfo:
viminfo = {}
viminfo['cloud_extra_info'] = tmp_viminfo['cloud-extra-info']
viminfo['cloud_epa_caps'] = tmp_viminfo['cloud-epa-caps']
- tmp_authinfo = tmp_viminfo['auth-info-items'][0]
if tmp_authinfo:
- viminfo['userName'] = tmp_authinfo['username']
+ viminfo['userName'] = tmp_authinfo['user-name']
viminfo['password'] = tmp_authinfo['password']
viminfo['domain'] = tmp_authinfo['cloud-domain']
- viminfo['url'] = tmp_authinfo['auth-url']
- viminfo['tenant'] = tmp_authinfo['defaultTenant']['name'] if not tmp_authinfo['defaultTenant'] else None
+ viminfo['url'] = tmp_authinfo['url']
+ viminfo['tenant'] = tmp_authinfo['default-tenant']
viminfo['cacert'] = tmp_authinfo['ssl-cacert']
viminfo['insecure'] = tmp_authinfo['ssl-insecure']
+ else:
+ return None
return viminfo
else:
cloud_owner, cloud_region_id = decode_vim_id(vim_id)
if cloud_owner and cloud_region_id:
retcode, content, status_code = \
- req_by_msb("/api/aai-cloudInfrastructure/v1/cloud-infrastructure/cloud-regions/cloud-region/%s/%s"
+ req_to_aai("/cloud-infrastructure/cloud-regions/cloud-region/%s/%s"
% ( cloud_owner, cloud_region_id), "DELETE")
if retcode != 0:
logger.error("Status code is %s, detail is %s.", status_code, content)
raise VimDriverNewtonException(
- "Failed to delete VIM in AAI with id (%s:%s,%s) from extsys." % (vim_id,cloud_owner,cloud_region_id),
+ "Failed to delete VIM in AAI with id (%s:%s,%s)." % (vim_id,cloud_owner,cloud_region_id),
status_code, content)
return 0
# return non zero if failed to decode cloud owner and region id
is_download_ok = False
try:
make_dirs(local_dir)
- r = urllib2.Request(url)
- req = urllib2.urlopen(r)
+ req = urllib.request.urlopen(url)
save_file = open(local_file_name, 'wb')
save_file.write(req.read())
save_file.close()
import uuid
from six.moves import http_client
import httplib2
+import uuid
from rest_framework import status
-
+from newton.pub.config.config import AAI_SCHEMA_VERSION
+from newton.pub.config.config import AAI_SERVICE_URL
+from newton.pub.config.config import AAI_USERNAME
+from newton.pub.config.config import AAI_PASSWORD
from newton.pub.config.config import MSB_SERVICE_IP, MSB_SERVICE_PORT
+from newton.pub.config.config import AAI_APP_ID
rest_no_auth, rest_oneway_auth, rest_bothway_auth = 0, 1, 2
HTTP_200_OK, HTTP_201_CREATED, HTTP_204_NO_CONTENT, HTTP_202_ACCEPTED \
else:
ret = [1, resp_body, resp_status]
break
- except httplib.ResponseNotReady:
+ except http.client.ResponseNotReady:
# logger.debug("retry_times=%d", retry_times)
ret = [1, "Unable to connect to %s" % full_url, resp_status]
continue
- except urllib2.URLError as err:
+ except urllib.error.URLError as err:
ret = [2, str(err), resp_status]
except Exception:
logger.error(traceback.format_exc())
return call_req(base_url, "", "", rest_no_auth,
resource, method, extra_headers, content)
+def req_to_aai(resource, method, content='', appid=AAI_APP_ID):
+ tmp_trasaction_id = uuid.uuid1()
+ headers = {
+ 'X-FromAppId': appid,
+ 'X-TransactionId': tmp_trasaction_id,
+ 'content-type': 'application/json',
+ 'accept': 'application/json'
+ }
+ base_url = "%s/%s" % (AAI_SERVICE_URL, AAI_SCHEMA_VERSION)
+ logger.debug("req_to_aai--%s::> %s, %s" % (tmp_trasaction_id, method, resource))
+ return call_req(base_url, AAI_USERNAME, AAI_PASSWORD, rest_no_auth,
+ resource, method, content, headers)
+
def combine_url(base_url, resource):
full_url = None
return Response(data={'error': 'imagePath is not specified'}, status=500)
#valid image url
- imagefd = urllib2.urlopen(imageurl)
+ imagefd = urllib.request.urlopen(imageurl)
if not imagefd:
logger.debug("image is not available at %s" % imageurl)
return Response(data={'error': 'cannot access to specified imagePath'}, status=500)
return Response(data=resp_body, status=resp.status_code)
except VimDriverNewtonException as e:
return Response(data={'error': e.content}, status=e.status_code)
- except urllib2.URLError as e:
+ except urllib.error.URLError as e:
return Response(data={'error': 'image is not accessible:%s' % str(e)},
status=status.HTTP_500_INTERNAL_SERVER_ERROR)
except HttpError as e: