mirror of
https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
synced 2025-11-01 19:28:00 +00:00
@@ -32,15 +32,16 @@ class TestGroup(LFCliBase):
|
|||||||
self.local_realm = realm.Realm(lfclient_host=host, lfclient_port=port)
|
self.local_realm = realm.Realm(lfclient_host=host, lfclient_port=port)
|
||||||
self.tg_profile = self.local_realm.new_test_group_profile()
|
self.tg_profile = self.local_realm.new_test_group_profile()
|
||||||
if group_name is None and list_groups is None and (tg_action is not None or cx_action is not None or
|
if group_name is None and list_groups is None and (tg_action is not None or cx_action is not None or
|
||||||
add_cx_list is not None or rm_cx_list is not None or show_group is not None):
|
add_cx_list is not None or rm_cx_list is not None or show_group is not None):
|
||||||
raise ValueError("Group name must be set if manipulating test groups")
|
raise ValueError(
|
||||||
|
"Group name must be set if manipulating test groups")
|
||||||
else:
|
else:
|
||||||
self.tg_profile.group_name = group_name
|
self.tg_profile.group_name = group_name
|
||||||
|
|
||||||
self.tg_action = tg_action
|
self.tg_action = tg_action
|
||||||
self.cx_action = cx_action
|
self.cx_action = cx_action
|
||||||
self.list_groups = list_groups
|
self.list_groups = list_groups
|
||||||
self.show_group = show_group
|
self.show_group = show_group
|
||||||
if add_cx_list is not None and len(add_cx_list) == 1 and ',' in add_cx_list[0]:
|
if add_cx_list is not None and len(add_cx_list) == 1 and ',' in add_cx_list[0]:
|
||||||
self.add_cx_list = add_cx_list[0].split(',')
|
self.add_cx_list = add_cx_list[0].split(',')
|
||||||
else:
|
else:
|
||||||
@@ -71,7 +72,8 @@ class TestGroup(LFCliBase):
|
|||||||
if self.tg_profile.check_group_exists():
|
if self.tg_profile.check_group_exists():
|
||||||
self.tg_profile.rm_group()
|
self.tg_profile.rm_group()
|
||||||
else:
|
else:
|
||||||
print("%s not found, no action taken" % self.tg_profile.group_name)
|
print("%s not found, no action taken" %
|
||||||
|
self.tg_profile.group_name)
|
||||||
|
|
||||||
def show_info(self):
|
def show_info(self):
|
||||||
time.sleep(.5)
|
time.sleep(.5)
|
||||||
@@ -94,12 +96,14 @@ class TestGroup(LFCliBase):
|
|||||||
|
|
||||||
def update_cxs(self):
|
def update_cxs(self):
|
||||||
if len(self.add_cx_list) > 0:
|
if len(self.add_cx_list) > 0:
|
||||||
print("Adding cxs %s to %s" % (', '.join(self.add_cx_list), self.tg_profile.group_name))
|
print("Adding cxs %s to %s" %
|
||||||
|
(', '.join(self.add_cx_list), self.tg_profile.group_name))
|
||||||
for cx in self.add_cx_list:
|
for cx in self.add_cx_list:
|
||||||
self.tg_profile.add_cx(cx)
|
self.tg_profile.add_cx(cx)
|
||||||
self.tg_profile.cx_list.append(cx)
|
self.tg_profile.cx_list.append(cx)
|
||||||
if len(self.rm_cx_list) > 0:
|
if len(self.rm_cx_list) > 0:
|
||||||
print("Removing cxs %s from %s" % (', '.join(self.rm_cx_list), self.tg_profile.group_name))
|
print("Removing cxs %s from %s" %
|
||||||
|
(', '.join(self.rm_cx_list), self.tg_profile.group_name))
|
||||||
for cx in self.rm_cx_list:
|
for cx in self.rm_cx_list:
|
||||||
self.tg_profile.rm_cx(cx)
|
self.tg_profile.rm_cx(cx)
|
||||||
if cx in self.tg_profile.cx_list:
|
if cx in self.tg_profile.cx_list:
|
||||||
@@ -118,21 +122,31 @@ def main():
|
|||||||
./testgroup.py --group_name group1 --add_group --list_groups
|
./testgroup.py --group_name group1 --add_group --list_groups
|
||||||
''')
|
''')
|
||||||
|
|
||||||
parser.add_argument('--group_name', help='specify the name of the test group to use', default=None)
|
parser.add_argument(
|
||||||
parser.add_argument('--list_groups', help='list all existing test groups', action='store_true', default=False)
|
'--group_name', help='specify the name of the test group to use', default=None)
|
||||||
|
parser.add_argument('--list_groups', help='list all existing test groups',
|
||||||
|
action='store_true', default=False)
|
||||||
|
|
||||||
tg_group = parser.add_mutually_exclusive_group()
|
tg_group = parser.add_mutually_exclusive_group()
|
||||||
tg_group.add_argument('--add_group', help='add new test group', action='store_true', default=False)
|
tg_group.add_argument(
|
||||||
tg_group.add_argument('--del_group', help='delete test group', action='store_true', default=False)
|
'--add_group', help='add new test group', action='store_true', default=False)
|
||||||
parser.add_argument('--show_group', help='show connections in current test group', action='store_true', default=False)
|
tg_group.add_argument(
|
||||||
|
'--del_group', help='delete test group', action='store_true', default=False)
|
||||||
|
parser.add_argument('--show_group', help='show connections in current test group',
|
||||||
|
action='store_true', default=False)
|
||||||
|
|
||||||
cx_group = parser.add_mutually_exclusive_group()
|
cx_group = parser.add_mutually_exclusive_group()
|
||||||
cx_group.add_argument('--start_group', help='start all cxs in chosen test group', default=None)
|
cx_group.add_argument(
|
||||||
cx_group.add_argument('--stop_group', help='stop all cxs in chosen test group', default=None)
|
'--start_group', help='start all cxs in chosen test group', default=None)
|
||||||
cx_group.add_argument('--quiesce_group', help='quiesce all cxs in chosen test groups', default=None)
|
cx_group.add_argument(
|
||||||
|
'--stop_group', help='stop all cxs in chosen test group', default=None)
|
||||||
|
cx_group.add_argument(
|
||||||
|
'--quiesce_group', help='quiesce all cxs in chosen test groups', default=None)
|
||||||
|
|
||||||
parser.add_argument('--add_cx', help='add cx to chosen test group', nargs='*', default=[])
|
parser.add_argument(
|
||||||
parser.add_argument('--remove_cx', help='remove cx from chosen test group', nargs='*', default=[])
|
'--add_cx', help='add cx to chosen test group', nargs='*', default=[])
|
||||||
|
parser.add_argument(
|
||||||
|
'--remove_cx', help='remove cx from chosen test group', nargs='*', default=[])
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
@@ -152,9 +166,9 @@ def main():
|
|||||||
cx_action = 'quiesce'
|
cx_action = 'quiesce'
|
||||||
|
|
||||||
tg = TestGroup(host=args.mgr, port=args.mgr_port,
|
tg = TestGroup(host=args.mgr, port=args.mgr_port,
|
||||||
group_name=args.group_name,
|
group_name=args.group_name,
|
||||||
add_cx_list=args.add_cx, rm_cx_list=args.remove_cx, cx_action=cx_action,
|
add_cx_list=args.add_cx, rm_cx_list=args.remove_cx, cx_action=cx_action,
|
||||||
tg_action=tg_action, list_groups=args.list_groups, show_group=args.show_group)
|
tg_action=tg_action, list_groups=args.list_groups, show_group=args.show_group)
|
||||||
|
|
||||||
tg.do_tg_action()
|
tg.do_tg_action()
|
||||||
tg.update_cxs()
|
tg.update_cxs()
|
||||||
|
Reference in New Issue
Block a user