mirror of
https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
synced 2025-11-01 03:07:56 +00:00
@@ -9,7 +9,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")
|
||||
@@ -32,15 +32,16 @@ class TestGroup(LFCliBase):
|
||||
self.local_realm = realm.Realm(lfclient_host=host, lfclient_port=port)
|
||||
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
|
||||
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")
|
||||
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")
|
||||
else:
|
||||
self.tg_profile.group_name = group_name
|
||||
|
||||
self.tg_action = tg_action
|
||||
self.cx_action = cx_action
|
||||
self.tg_action = tg_action
|
||||
self.cx_action = cx_action
|
||||
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]:
|
||||
self.add_cx_list = add_cx_list[0].split(',')
|
||||
else:
|
||||
@@ -71,7 +72,8 @@ class TestGroup(LFCliBase):
|
||||
if self.tg_profile.check_group_exists():
|
||||
self.tg_profile.rm_group()
|
||||
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):
|
||||
time.sleep(.5)
|
||||
@@ -94,12 +96,14 @@ class TestGroup(LFCliBase):
|
||||
|
||||
def update_cxs(self):
|
||||
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:
|
||||
self.tg_profile.add_cx(cx)
|
||||
self.tg_profile.cx_list.append(cx)
|
||||
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:
|
||||
self.tg_profile.rm_cx(cx)
|
||||
if cx in self.tg_profile.cx_list:
|
||||
@@ -118,21 +122,31 @@ def main():
|
||||
./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('--list_groups', help='list all existing test groups', action='store_true', default=False)
|
||||
parser.add_argument(
|
||||
'--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.add_argument('--add_group', help='add new 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)
|
||||
tg_group.add_argument(
|
||||
'--add_group', help='add new 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.add_argument('--start_group', help='start all cxs in chosen test group', 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)
|
||||
cx_group.add_argument(
|
||||
'--start_group', help='start all cxs in chosen test group', 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('--remove_cx', help='remove cx from chosen test group', nargs='*', default=[])
|
||||
parser.add_argument(
|
||||
'--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()
|
||||
|
||||
@@ -152,9 +166,9 @@ def main():
|
||||
cx_action = 'quiesce'
|
||||
|
||||
tg = TestGroup(host=args.mgr, port=args.mgr_port,
|
||||
group_name=args.group_name,
|
||||
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)
|
||||
group_name=args.group_name,
|
||||
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.do_tg_action()
|
||||
tg.update_cxs()
|
||||
|
||||
Reference in New Issue
Block a user