Ejemplo n.º 1
0
def bind_epg_to_physdom(epg_url, cookies, physdom):

    physdom_template=Template('{"fvRsDomAtt":{"attributes":{"resImedcy":"immediate","tDn":"uni/phys-${name}","status":"created"},"children":[]}}')

    physdom = physdom_template.substitute(name=physdom)
    response = make_post_api_call(epg_url, payload=physdom, cookies=cookies)
    return response
Ejemplo n.º 2
0
def bind_epg_to_interface(epg_url, cookies, vlan_id, leaf, port):

    bind_to_interface_template = Template('{"fvRsPathAtt":{"attributes":{"encap":"vlan-${vlan_id}","instrImedcy":"immediate","tDn":"topology/pod-1/paths-${leaf}/pathep-[${port}]","status":"created"},"children":[]}})')
    bind_to_interface=bind_to_interface_template.substitute(vlan_id=vlan_id,leaf=leaf,port=port)

    response = make_post_api_call(epg_url, payload=bind_to_interface, cookies=cookies)
    return response
def create_tenant(base_url, cookies, tenant_name):
    tenant_url_full = '{}node/mo/uni/tn-{}.json'.format(base_url, tenant_name)
    print(tenant_url_full)
    tenant_create_template = Template('{"fvTenant":{"attributes":{"dn":"uni/tn-${tenant_name}","name":"${tenant_name}","rn":"tn-${tenant_name}","status":"created"},"children":[{"fvCtx":{"attributes":{"dn":"uni/tn-${tenant_name}/ctx-${tenant_name}","name":"${tenant_name}","rn":"ctx-${tenant_name}","status":"created"},"children":[]}}]}}')
    tenant_create_payload_data = tenant_create_template.substitute(tenant_name=tenant_name)

    new_tenant_reponse = make_post_api_call(tenant_url_full, payload=tenant_create_payload_data, cookies=cookies)
    return new_tenant_reponse
def create_snapshot(base_url, cookies, description):
    snapshot_url = '{}node/mo/uni/fabric/configexp-defaultOneTime.json'.format(base_url)
    snapshot_payload_template = Template(
        '{\"configExportP\":{\"attributes\":{\"dn\":\"uni/fabric/configexp-defaultOneTime\",\"name\":\"defaultOneTime\",\"snapshot\":\"true\",\"targetDn\":\"\",\"adminSt\":\"triggered\",\"rn\":\"configexp-defaultOneTime\",\"status\":\"created,modified\",\"descr\":\"${descr}\"},\"children\":[]}}')
    snapshot_payload = snapshot_payload_template.substitute(descr=description)

    create_snapshot = make_post_api_call(snapshot_url, payload=snapshot_payload, cookies=cookies)
    return create_snapshot
Ejemplo n.º 5
0
def create_epg(base_url, cookies, tenant_name, ap, epg, bd):
    # epg_url_template = Template('node/mo/uni/tn-${tenant_name}/ap-${ap_name}/epg-${epg}.json')
    # epg_url = epg_url_template.substitute(tenant_name=tenant_name, ap_name=ap, epg=epg)
    # new_url = url + epg_url
    epg_url_template_full = '{}node/mo/uni/tn-{}/ap-{}/epg-{}.json'.format(base_url, tenant_name,ap,epg)
    epg_create_template = Template('{"fvAEPg":{"attributes":{"dn":"uni/tn-${tenant_name}/ap-${ap}/epg-${epg}","name":"${epg}","rn":"epg-${epg}","status":"created"},"children":[{"fvRsBd":{"attributes":{"tnFvBDName":"${bd_name}","status":"created,modified"},"children":[]}}]}}')
    epg_create = epg_create_template.substitute(tenant_name=tenant_name, ap=ap, epg=epg, bd_name=bd)

    new_epg = make_post_api_call(epg_url_template_full, payload=epg_create, cookies=cookies)
    return epg_url_template_full
Ejemplo n.º 6
0
def create_bd_w_subnet(base_url, cookies, tenant_name, bd, subnet):
    bd_url_full = '{}node/mo/uni/tn-{}/BD-{}.json'.format(base_url, tenant_name, bd)

    bd_create_template = Template(
        '{"fvBD":{"attributes":{"dn":"uni/tn-${tenant_name}/BD-${bd_name}","name":"${bd_name}","rn":"BD-${bd_name}","status":"created"},"children":[{"fvSubnet":{"attributes":{"dn":"uni/tn-${tenant_name}/BD-${bd_name}/subnet-[${subnet}]","ctrl":"unspecified","ip":"${subnet}","rn":"subnet-[${subnet}]","status":"created"},"children":[]}},{"fvRsCtx":{"attributes":{"tnFvCtxName":"${tenant_name}","status":"created,modified"},"children":[]}}]}}')
    bd_create = bd_create_template.substitute(tenant_name=tenant_name, bd_name=bd, subnet=subnet)

    new_bd = make_post_api_call(bd_url_full, payload=bd_create, cookies=cookies)

    return new_bd
def create_ap(base_url, cookies, tenant_name, ap_name):
    # ap_url_template = Template('node/mo/uni/tn-${tenant_name}/ap-${ap_name}.json')
    # ap_url = ap_url_template.substitute(tenant_name=tenant_name, ap_name=ap)
    # new_url = url + ap_url
    # new_ap = requests.post(url=new_url, data=ap_create, cookies=cookies, verify=False)

    ap_url_full = '{}node/mo/uni/tn-{}/ap-{}.json'.format(base_url,tenant_name,ap_name)
    print(ap_url_full)

    ap_create_template = Template('{"fvAp":{"attributes":{"dn":"uni/tn-${tenant_name}/ap-${ap_name}","name":"${ap_name}","rn":"ap-${ap_name}","status":"created"},"children":[]}}')
    ap_create_data_payload = ap_create_template.substitute(tenant_name=tenant_name, ap_name=ap_name)

    ap_response =  make_post_api_call(ap_url_full,payload=ap_create_data_payload,cookies=cookies)
    return ap_response