run autopep8 on create_vr

Signed-off-by: Matthew Stidham <stidmatt@gmail.com>
This commit is contained in:
Matthew Stidham
2021-11-10 12:16:19 -08:00
parent 087c77080f
commit 6cd4f883c7

View File

@@ -12,7 +12,7 @@ if sys.version_info[0] != 3:
print("This script requires Python 3")
exit(1)
sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../")))
lfcli_base = importlib.import_module("py-json.LANforge.lfcli_base")
@@ -50,7 +50,8 @@ class CreateVR(Realm):
self.vr_profile = self.new_vr_profile()
def clean(self):
if (self.vr_name is None) or (self.vr_profile.vr_eid is None) and (self.vr_profile.vr_eid) == "":
if (self.vr_name is None) or (self.vr_profile.vr_eid is None) and (
self.vr_profile.vr_eid) == "":
print("No vr_eid to clean")
return
self.rm_port("1.1.rd90a", debug_=self.debug)
@@ -59,13 +60,13 @@ class CreateVR(Realm):
debug_=self.debug)
if (self.vr_profile.vr_eid is not None) \
and (self.vr_profile.vr_eid[1] is not None) \
and (self.vr_profile.vr_eid[2] is not None):
and (self.vr_profile.vr_eid[1] is not None) \
and (self.vr_profile.vr_eid[2] is not None):
self.vr_profile.cleanup(debug=self.debug)
if (self.vr_name is not None) \
and (self.vr_name[1] is not None) \
and (self.vr_name[2] is not None):
and (self.vr_name[1] is not None) \
and (self.vr_name[2] is not None):
data = {
"shelf": 1,
"resource": self.vr_name[1],
@@ -84,9 +85,9 @@ class CreateVR(Realm):
"cx_name": "all"
}, debug_=self.debug)
def build(self):
self.vr_profile.apply_netsmith(self.vr_name[1], delay=5, debug=self.debug)
self.vr_profile.apply_netsmith(
self.vr_name[1], delay=5, debug=self.debug)
self.json_post("/cli-json/add_rdd", {
"shelf": 1,
"resource": self.vr_name[1],
@@ -101,10 +102,17 @@ class CreateVR(Realm):
"peer_ifname": "rd90a",
"report_timer": "3000"
})
self.wait_until_ports_appear(sta_list=["1.1.rd90a", "1.1.rd90b"], debug_=self.debug)
self.vr_profile.vrcx_list(resource=self.vr_name[1], do_sync=True) # do_sync
self.wait_until_ports_appear(
sta_list=[
"1.1.rd90a",
"1.1.rd90b"],
debug_=self.debug)
self.vr_profile.vrcx_list(
resource=self.vr_name[1],
do_sync=True) # do_sync
self.vr_profile.create(vr_name=self.vr_name, debug=self.debug)
self.vr_profile.sync_netsmith(resource=self.vr_name[1], debug=self.debug)
self.vr_profile.sync_netsmith(
resource=self.vr_name[1], debug=self.debug)
self._pass("created router")
def start(self):
@@ -113,25 +121,39 @@ class CreateVR(Realm):
:return: void
"""
# move rd90a into router
self.vr_profile.refresh_netsmith(resource=self.vr_name[1], debug=self.debug)
self.vr_profile.refresh_netsmith(
resource=self.vr_name[1], debug=self.debug)
if self.debug:
pprint(("vr_eid", self.vr_name))
self.vr_profile.wait_until_vrcx_appear(resource=self.vr_name[1], name_list=["rd90a", "rd90b"])
self.vr_profile.add_vrcx(vr_eid=self.vr_name, connection_name_list="rd90a", debug=True)
self.vr_profile.wait_until_vrcx_appear(
resource=self.vr_name[1], name_list=[
"rd90a", "rd90b"])
self.vr_profile.add_vrcx(
vr_eid=self.vr_name,
connection_name_list="rd90a",
debug=True)
self.vr_profile.refresh_netsmith(resource=self.vr_name[1], debug=self.debug)
self.vr_profile.refresh_netsmith(
resource=self.vr_name[1], debug=self.debug)
# test to make sure that vrcx is inside vr we expect
self.vr_profile.vrcx_list(resource=self.vr_name[1], do_sync=True)
vr_list = self.vr_profile.router_list(resource=self.vr_name[1], do_refresh=True)
router = self.vr_profile.find_cached_router(resource=self.vr_name[1], router_name=self.vr_name[2])
vr_list = self.vr_profile.router_list(
resource=self.vr_name[1], do_refresh=True)
router = self.vr_profile.find_cached_router(
resource=self.vr_name[1], router_name=self.vr_name[2])
pprint(("cached router 120: ", router))
router_eid = LFUtils.name_to_eid(router["eid"])
pprint(("router eid 122: ", router_eid))
full_router = self.json_get("/vr/1/%s/%s/%s" %(router_eid[0], router_eid[1], self.vr_name[2]), debug_=True)
full_router = self.json_get(
"/vr/1/%s/%s/%s" %
(router_eid[0],
router_eid[1],
self.vr_name[2]),
debug_=True)
pprint(("full router: ", full_router))
time.sleep(5)
if router is None:
self._fail("Unable to find router after vrcx move "+self.vr_name)
self._fail("Unable to find router after vrcx move " + self.vr_name)
self.exit_fail()
def stop(self):
@@ -146,8 +168,8 @@ def main():
--------------------
Command example:
{f} --vr_name 1.vr0 --ports 1.br0,1.rdd0a --services 1.br0=dhcp,nat --services 1.vr0=radvd
{f} --vr_name 2.vr0 --ports 2.br0,2.vap2 --services
{f} --vr_name 2.vr0 --ports 2.br0,2.vap2 --services
--debug
""".format(f=__file__))
required = parser.add_argument_group('required arguments')
@@ -156,8 +178,11 @@ Command example:
optional = parser.add_argument_group('optional arguments')
optional.add_argument('--ports', default=None, required=False,
help='Comma separated list of ports to add to virtual router')
optional.add_argument(
'--ports',
default=None,
required=False,
help='Comma separated list of ports to add to virtual router')
optional.add_argument('--services', default=None, required=False,
help='Add router services to a port, "br0=nat,dhcp"')
@@ -175,10 +200,11 @@ Command example:
create_vr.build()
create_vr.start()
create_vr.monitor()
#create_vr.stop()
#create_vr.clean()
# create_vr.stop()
# create_vr.clean()
print('Created Virtual Router')
if __name__ == "__main__":
main()