OSM API handling for the '--wait' option
"""
-from osmclient.common.exceptions import ClientException
+from osmclient.common.exceptions import ClientException, NotFound
import json
from time import sleep
import sys
TIMEOUT_NSI_OPERATION = TIMEOUT_GENERIC_OPERATION
TIMEOUT_SDNC_OPERATION = TIMEOUT_GENERIC_OPERATION
TIMEOUT_VIM_OPERATION = TIMEOUT_GENERIC_OPERATION
+TIMEOUT_K8S_OPERATION = TIMEOUT_GENERIC_OPERATION
TIMEOUT_WIM_OPERATION = TIMEOUT_GENERIC_OPERATION
TIMEOUT_NS_OPERATION = 3600
-POLLING_TIME_INTERVAL = 1
+POLLING_TIME_INTERVAL = 5
MAX_DELETE_ATTEMPTS = 3
def _show_detailed_status(old_detailed_status, new_detailed_status):
resp = ''
if resp_unicode:
resp = json.loads(resp_unicode)
- # print 'HTTP CODE: {}'.format(http_code)
- # print 'RESP: {}'.format(resp)
- # print 'URL: {}/{}'.format(apiUrlStatus, entity_id)
+ # print('HTTP CODE: {}'.format(http_code))
+ # print('RESP: {}'.format(resp))
+ # print('URL: {}/{}'.format(apiUrlStatus, entity_id))
if deleteFlag and http_code == 404:
# In case of deletion, '404 Not Found' means successfully deleted
# Display 'detailed-status: Deleted' and return
else:
time_to_return = True
new_detailed_status = _get_detailed_status(resp, entity_label, detailed_status_deleted)
- # print 'DETAILED-STATUS: {}'.format(new_detailed_status)
- # print 'DELETE-ATTEMPTS-LEFT: {}'.format(delete_attempts_left)
+ # print('DETAILED-STATUS: {}'.format(new_detailed_status))
+ # print('DELETE-ATTEMPTS-LEFT: {}'.format(delete_attempts_left))
if not new_detailed_status:
new_detailed_status = 'In progress'
# TODO: Change LCM to provide detailed-status more up to date
# There was a timeout, so raise an exception
raise ClientException('operation timeout, waited for {} seconds'.format(timeout))
except ClientException as exc:
- message="Operation failed for {}:\nerror:\n{}".format(
+ if deleteFlag and isinstance(exc, NotFound):
+ return
+ message = "Operation failed for {}:\nerror:\n{}".format(
entity_label,
- exc.message)
+ str(exc))
raise ClientException(message)