Esempio n. 1
0
def ns_delete(lp_addr, header, proj_name, nsr_id):
    try:
        api = rapi.ns_delete()
        url = util.create_url_operations(lp_addr, api)
        payload = pl.ns_delete(proj_name, nsr_id)

        util.log_info(f"Deleting NS with NSR ID- {nsr_id}.")
        status = util.add_config(url, header, payload)
        util.log_info(f"Please wait while deleting NS.")
        #state = util.get_transac_id(status)
        time.sleep(15)
        #return state
    except BaseException as e:
        util.log_info(e)
        raise
Esempio n. 2
0
def get_ns_oper_status(lp_addr, header, proj_name, nsr_id):
    try:
        api = rapi.ns_oper_status(proj_name, nsr_id)
        url = util.create_url_operations(lp_addr, api)
        payload = ""

        util.log_info(
            f"Fetching operational-status of NS with NSR ID: {nsr_id}.")
        status = util.get_config(url, header, payload)
        state = status["operational-status"]
        util.log_info(f"Current state of NS is- {state}.")
        time.sleep(5)
        return state
    except BaseException as e:
        util.log_info(e)
        raise
Esempio n. 3
0
def pkg_upload_status(lp_addr, header, proj_name, transac_id):
    try:
        api = rapi.pkg_upload_status(proj_name, transac_id)
        url = util.create_url_operations(lp_addr, api)
        payload = ""

        util.log_info(
            f"Checking status of uploaded package in project- {proj_name}.")
        status = util.get_config(url, header, payload)
        state = list(status.values())
        util.log_info(f"Package upload status- {state[0]}.")
        time.sleep(5)
        return state[0]
    except BaseException as e:
        util.log_info(e)
        raise
Esempio n. 4
0
def vim_resource_discover(lp_addr, header, proj_name, cloud_acct_name):
    try:
        api = rapi.vim_resource_discover()
        url = util.create_url_operations(lp_addr, api)
        payload = pl.vim_resource_discover(proj_name, cloud_acct_name)

        util.log_info(
            f"Discovering resources for VIM account- {cloud_acct_name}.")
        status = util.add_config(url, header, payload)
        util.log_info("Please wait while resource-discovery is in progress.")
        state = util.get_rpc_state(status).upper()
        if state != "OK":
            assert state == "OK", f"RPC response: Expected- OK, Received- {state}."
        time.sleep(120)
    except BaseException as e:
        util.log_info(e)
        raise
Esempio n. 5
0
def ns_instantiate(lp_addr, header, proj_name, nsr_id):
    try:
        api = rapi.ns_instantiate()
        url = util.create_url_operations(lp_addr, api)
        payload = pl.ns_instantiate(proj_name, nsr_id)

        util.log_info(f"Instantiating NS with NSR ID- {nsr_id}.")
        status = util.add_config(url, header, payload)
        util.log_info(
            "Please wait while for a few minutes while instantiation is in progress."
        )
        time.sleep(360)
        # state = util.get_transac_id(status)
        # return state
    except BaseException as e:
        util.log_info(e)
        raise
Esempio n. 6
0
def ns_create(lp_addr, header, proj_name, ns_name, nsd_id):
    try:
        api = rapi.ns_create()
        url = util.create_url_operations(lp_addr, api)
        payload = pl.ns_create(proj_name, ns_name, nsd_id)

        util.log_info(
            f"Creating NS with name- {ns_name} and NSD ID- {nsd_id}.")
        status = util.add_config(url, header, payload)
        nsr_id = util.get_nsr_id(status)
        util.log_info(f"Generated NSR ID- {nsr_id}.")
        time.sleep(20)
        return nsr_id
        #transac_state = util.get_transac_id(status)
        #return nsr_id, transac_state
    except BaseException as e:
        util.log_info(e)
        raise
Esempio n. 7
0
def pkg_onboard(lp_addr, header, proj_name, ext_url):
    try:
        api = rapi.pkg_upload()
        url = util.create_url_operations(lp_addr, api)
        payload = pl.pkg_upload(proj_name, ext_url)

        util.log_info(f"Adding package to project- {proj_name}.")
        status = util.add_config(url, header, payload)
        transac_id = util.get_transac_id(status)
        if transac_id:
            util.log_info(f"TransactionID for uploaded package- {transac_id}.")
            time.sleep(20)
            return transac_id
        else:
            assert transac_id, "Expecting transaction-ID when package is uploaded."
    except BaseException as e:
        util.log_info(e)
        raise