def epg_add_contract(ip, tenant_name, app_profile_name, epg_name, contract_name, type): request_url = 'https://' + ip + '/api/node/mo/uni/tn-' + tenant_name + '/ap-' + app_profile_name + '/epg-' + epg_name + '.json' print(request_url) if type == 'Consumed': json_data = { "fvRsCons": { "attributes": { "tnVzBrCPName": contract_name, "status": "created,modified" }, "children": [] } } elif type == 'Provided': json_data = { "fvRsProv": { "attributes": { "tnVzBrCPName": contract_name, "status": "created,modified" }, "children": [] } } else: print("contract type error!!!") print(json_data) session = get_session(ip) result = session.post(request_url, headers=my_headers, json=json_data) return result.json()
def create_epg(ip, tenant_name, app_profile_name, epg_name, bd_name): request_url = 'https://' + ip + '/api/node/mo/uni/tn-' + tenant_name + '/ap-' + app_profile_name + '/epg-' + epg_name + '.json' json_data = { "fvAEPg": { "attributes": { "dn": "uni/tn-" + tenant_name + "/ap-" + app_profile_name + "/epg-" + epg_name, "name": epg_name, "rn": "epg-" + epg_name, "status": "created" }, "children": [{ "fvRsBd": { "attributes": { "tnFvBDName": bd_name, "status": "created,modified" }, "children": [] } }] } } session = get_session(ip) result = session.post(request_url, headers=my_headers, json=json_data) return result.json()
def create_application_profiles(ip, tenant_name, app_profile_name): request_url = 'https://' + ip + '/api/node/mo/uni/tn-' + tenant_name + '/ap-' + app_profile_name + '.json' json_data = { "fvAp": { "attributes": { "dn": "uni/tn-" + tenant_name + "/ap-" + app_profile_name, "name": app_profile_name, "rn": "ap-" + app_profile_name, "status": "created" }, "children": [] } } session = get_session(ip) result = session.post(request_url, headers=my_headers, json=json_data) return result.json()
def create_tenant(ip, name): request_url = 'https://' + ip + '/api/node/mo/uni/tn-' + name + '.json' json_data = { "fvTenant": { "attributes": { "dn": "uni/tn-" + name, "name": name, "rn": "tn-" + name, "status": "created" }, "children": [] } } session = get_session(ip) result = session.post(request_url, headers=my_headers, json=json_data) return result.json()
def epg_domain_association(ip, tenant_name, ap_name, epg_name, dvs_name): request_url = f'https://{ip}/api/node/mo/uni/tn-{tenant_name}/ap-{ap_name}/epg-{epg_name}.json' session = get_session(ip) json_data = { "fvRsDomAtt": { "attributes": { "resImedcy": "immediate", "tDn": f"uni/vmmp-VMware/dom-{dvs_name}", "status": "created" }, "children": [{ "vmmSecP": { "attributes": { "status": "created" }, "children": [] } }] } } result = session.post(request_url, headers=my_headers, json=json_data) return result.json()
def tenant_children_show(ip, tenant_name): request_url = 'https://' + ip + '/api/node/mo/uni/tn-' + tenant_name + '.json?query-target=children' print(request_url) session = get_session(ip) result = session.get(request_url, headers=my_headers) return result.json()
def search_by_dn_filter(ip, dn, filter): request_url = 'https://' + ip + '/api/node/mo/' + dn + '.json' + filter session = get_session(ip) result = session.get(request_url, headers=my_headers) return result.json()
def tenant_show(ip, tenant_name): request_url = 'https://' + ip + '/api/node/class/fvTenant.json?query-target-filter=and(eq(fvTenant.name,"' + tenant_name + '"))' session = get_session(ip) result = session.get(request_url, headers=my_headers) return result.json()
def query_tenants(ip): request_url = 'https://' + ip + '/api/node/class/fvTenant.json?' session = get_session(ip) result = session.get(request_url, headers=my_headers) # print(result.text) return result.json()