예제 #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
예제 #2
0
def proj_add(lp_addr, header, proj_name, proj_desc):
    try:
        api = rapi.proj_add()
        url = util.create_url_running(lp_addr, api)
        payload = pl.proj_add(proj_name, proj_desc)

        util.log_info(f"Adding project with name- {proj_name}.")
        status = util.add_config(url, header, payload)
        state = util.get_rpc_state(status).upper()
        if state != "OK":
            assert state == "OK", f"RPC response: Expected- OK, Received- {state}."
        time.sleep(15)
    except BaseException as e:
        util.log_info(e)
        raise
예제 #3
0
def proj_config(lp_addr, header, proj_name, user_name, user_domain, role,
                event_publish):
    try:
        api = rapi.proj_config(proj_name)
        url = util.create_url_running(lp_addr, api)
        payload = pl.proj_config(user_name, user_domain, role, event_publish)

        util.log_info(f"Configuring project- {proj_name}.")
        status = util.add_config(url, header, payload)
        state = util.get_rpc_state(status).upper()
        if state != "OK":
            assert state == "OK", f"RPC response: Expected- OK, Received- {state}."
        time.sleep(20)
    except BaseException as e:
        util.log_info(e)
        raise
예제 #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
예제 #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
예제 #6
0
def cloud_acct_add(lp_addr, header, proj_name, acct_name, acct_type, timeout):
    try:
        api = rapi.cloud_acct_add(proj_name)
        url = util.create_url_running(lp_addr, api)
        payload = pl.cloud_acct_add(acct_name, acct_type, timeout)

        util.log_info(
            f"Adding cloud account- {acct_type} with name- {acct_name} to project- {proj_name}."
        )
        status = util.add_config(url, header, payload)
        time.sleep(10)
        state = util.get_rpc_state(status).upper()
        if state != "OK":
            assert state == "OK", f"RPC response: Expected- OK, Received- {state}."
    except BaseException as e:
        util.log_info(e)
        raise
예제 #7
0
def add_input_param_xpath_nsr(lp_addr, header, proj_name, nsr_id, xpath,
                              value):
    try:
        api = rapi.input_parameter_xpath_nsr(proj_name, nsr_id)
        url = util.create_url_running(lp_addr, api)
        payload = pl.input_parameter_xpath_nsd(xpath, value)

        util.log_info(
            f"Adding xPath- \"{xpath}\" with value- \"{value}\" to NSR ID- \"{nsr_id}\"."
        )
        status = util.add_config(url, header, payload)
        time.sleep(10)
        state = util.get_rpc_state(status).upper()
        if state != "OK":
            assert state == "OK", f"RPC response: Expected- OK, Received- {state}."
    except BaseException as e:
        util.log_info(e)
        raise
예제 #8
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
예제 #9
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