Exemplo n.º 1
0
def cloud_acct_config_openstack(lp_addr,
                                header,
                                proj_name,
                                cloud_acct_name,
                                key,
                                secret,
                                auth_url,
                                tenant,
                                user_domain="eng",
                                proj_domain="eng",
                                region="RegionOne",
                                mgmt_net="private",
                                float_ip_pool_net="public"):
    try:
        api = rapi.cloud_acct_config_openstack(proj_name, cloud_acct_name)
        url = util.create_url_running(lp_addr, api)
        payload = pl.cloud_acct_config_openstack(key, secret, auth_url,
                                                 user_domain, proj_domain,
                                                 tenant, region, mgmt_net,
                                                 float_ip_pool_net)

        util.log_info(
            f"Adding configuration to cloud-account- {cloud_acct_name}.")
        status = util.edit_config(url, header, payload)
        time.sleep(20)
        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
Exemplo n.º 2
0
def pkg_delete(lp_addr, header, proj_name, pkg_type, pkg_name):
    try:
        vnfd = {}
        nsd = {}
        pkg = {}
        util.log_info("Collecting VNFD ID.")
        vnfd_id = get_vnfd_id(lp_addr, header, proj_name)
        util.log_info("Collecting VNFD Name.")
        vnfd_name = get_vnfd_name(lp_addr, header, proj_name)
        util.log_info("Collecting NSD ID.")
        nsd_id = get_nsd_id(lp_addr, header, proj_name)
        util.log_info("Collecting NSD Name.")
        nsd_name = get_nsd_name(lp_addr, header, proj_name)

        if vnfd_id and vnfd_name:
            vnfd = dict(zip(vnfd_name, vnfd_id))
        if nsd_id and nsd_name:
            nsd = dict(zip(nsd_name, nsd_id))
        if bool(vnfd) or bool(nsd):
            pkg = {**vnfd, **nsd}
            util.log_info(f"Available packages: {pkg}.")

        if pkg_type.upper() == "VNFD":
            api = rapi.vnfd_delete(proj_name, pkg[pkg_name])
            url = util.create_url_running(lp_addr, api)
            payload = ""
            util.log_info(
                f"Deleting package: {pkg_name} with ID: {pkg[pkg_name]}")
            status = util.delete_config(url, header, payload)
            time.sleep(20)
            state = util.get_rpc_state(status).upper()
            if state != "OK":
                assert state == "OK", f"RPC response: Expected- OK, Received- {state}."
        elif pkg_type.upper() == "NSD":
            api = rapi.nsd_delete(proj_name, pkg[pkg_name])
            url = util.create_url_running(lp_addr, api)
            payload = ""
            util.log_info(
                f"Deleting package: {pkg_name} with ID: {pkg[pkg_name]}")
            status = util.delete_config(url, header, payload)
            time.sleep(20)
            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
Exemplo n.º 3
0
def cloud_acct_delete(lp_addr, header, proj_name, cloud_acct_name):
    try:
        api = rapi.cloud_acct_detail(proj_name, cloud_acct_name)
        url = util.create_url_running(lp_addr, api)
        payload = ""

        status = util.delete_config(url, header, payload)
        time.sleep(15)
        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
Exemplo n.º 4
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
Exemplo n.º 5
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
Exemplo n.º 6
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
Exemplo n.º 7
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
Exemplo n.º 8
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
Exemplo n.º 9
0
def delete_input_param_xpath_nsd(lp_addr, header, proj_name, nsd_id, xpath):
    try:
        api = rapi.input_parameter_xpath_nsd(proj_name, nsd_id)
        url = util.create_url_running(lp_addr, api)
        payload = ""

        util.log_info(f"Deleting xPath- {xpath} from NSD- {nsd_id}.")
        encoded_uri = util.get_encoded_url(xpath)
        url = f"{url}/{encoded_uri}"
        print(url)
        status = util.delete_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
Exemplo n.º 10
0
def cloud_acct_config_vcd(lp_addr, header, proj_name, cloud_acct_name, user,
                          passwd, auth_url, tenant, mgmt_net, org, admin_user,
                          admin_passwd, nsx_auth_url, nsx_user, nsx_passwd,
                          vc_host, vc_port, vc_user, vc_passwd):
    try:
        api = rapi.cloud_acct_config_vcd(proj_name, cloud_acct_name)
        url = util.create_url_running(lp_addr, api)
        payload = pl.cloud_acct_config_vcd(user, passwd, auth_url, tenant,
                                           mgmt_net, org, admin_user,
                                           admin_passwd, nsx_auth_url,
                                           nsx_user, nsx_passwd, vc_host,
                                           vc_port, vc_user, vc_passwd)
        util.log_info(
            f"Adding configuration to cloud-account- {cloud_acct_name}.")
        status = util.edit_config(url, header, payload)
        time.sleep(20)
        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