Skip to content
This repository was archived by the owner on Jan 8, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion run.py
Original file line number Diff line number Diff line change
Expand Up @@ -905,6 +905,7 @@ def __init__(self, vc_conn):
},
}
self.vc_tag = format_tag(vc_conn["HOST"])
self.vrf_id = vc_conn.get("VRF_ID")
self.vc = vCenterHandler(
format_vcenter_conn(vc_conn), nb_api_version=self.nb_api_version
)
Expand Down Expand Up @@ -1100,6 +1101,8 @@ def obj_exists(self, nb_obj_type, vc_data):
quote_plus(vc_data["virtual_machine"]["name"]), query_key,
vc_data[query_key]
)
elif self.vrf_id is not None and nb_obj_type in ("ip_addresses", "prefixes"):
query = "?{}={}&vrf_id={}".format(query_key, vc_data[query_key], self.vrf_id)
else:
query = "?{}={}".format(
query_key, vc_data[query_key]
Expand Down Expand Up @@ -1516,7 +1519,9 @@ def search_prefix(self, ip_addr):
:rtype: dict
"""
result = {"tenant": None, "vrf": None}
query = "?contains={}".format(ip_addr)
query = ("?contains={}".format(ip_addr)
if self.vrf_id is None
else "?contains={}&vrf_id={}".format(ip_addr, self.vrf_id))
try:
prefix_obj = self.request(
req_type="get", nb_obj_type="prefixes", query=query
Expand Down
2 changes: 1 addition & 1 deletion settings.example.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
# The USER argument supports SSO with @domain.tld suffix
VC_HOSTS = [
# You can add more vCenter instances by duplicating the line below
{"HOST": "vcenter1.example.com", "PORT": 443, "USER": "", "PASS": ""},
{"HOST": "vcenter1.example.com", "PORT": 443, "USER": "", "PASS": "", "VRF_ID": None},
]


Expand Down