feature:新增max_service_function_index和list_service_function_index输入配置项
This commit is contained in:
@@ -1254,7 +1254,8 @@ class TsgDiagnose:
|
|||||||
self.client = None
|
self.client = None
|
||||||
self.config_dict = {}
|
self.config_dict = {}
|
||||||
self.dign_duration = 0
|
self.dign_duration = 0
|
||||||
self.count_service_function = 1
|
self.max_service_function_index = 1
|
||||||
|
self.list_service_function_index = []
|
||||||
|
|
||||||
def _get_dign_option(self):
|
def _get_dign_option(self):
|
||||||
parser = argparse.ArgumentParser(description="Tsg Tools - tsg diagnose", epilog = "Example:help")
|
parser = argparse.ArgumentParser(description="Tsg Tools - tsg diagnose", epilog = "Example:help")
|
||||||
@@ -1262,13 +1263,15 @@ class TsgDiagnose:
|
|||||||
parser.add_argument('-c','--count', type = int, default = 1, help='Specifies the count of tsg diagnoses ,range:1-65535')
|
parser.add_argument('-c','--count', type = int, default = 1, help='Specifies the count of tsg diagnoses ,range:1-65535')
|
||||||
parser.add_argument('-p','--configpath', type = str, default = '/opt/dign_client/etc/client.conf',help='Specifies the config file, default /opt/dign_client/etc/client.conf')
|
parser.add_argument('-p','--configpath', type = str, default = '/opt/dign_client/etc/client.conf',help='Specifies the config file, default /opt/dign_client/etc/client.conf')
|
||||||
parser.add_argument('-l','--loop', action='store_true', default = False, help='Tsg diagnose loop, exit when recv a signal')
|
parser.add_argument('-l','--loop', action='store_true', default = False, help='Tsg diagnose loop, exit when recv a signal')
|
||||||
parser.add_argument('-C','--count_service_function', type = int, default = 1, help='Specifies the counts of service_function ,range:1-256')
|
parser.add_argument('-m','--max_service_function_index', type = int, default = 1, help='Specifies the max index of service_function,range:1-256')
|
||||||
|
parser.add_argument('-d','--list_service_function_index', nargs='+', type = int, help='Specifies the list of service function index')
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
self.interval = args.interval
|
self.interval = args.interval
|
||||||
self.loop = args.loop
|
self.loop = args.loop
|
||||||
self.count = args.count
|
self.count = args.count
|
||||||
self.config = args.configpath
|
self.config = args.configpath
|
||||||
self.count_service_function = args.count_service_function
|
self.max_service_function_index = args.max_service_function_index
|
||||||
|
self.list_service_function_index = args.list_service_function_index
|
||||||
if self.count == 0:
|
if self.count == 0:
|
||||||
print("Error: bad number of tsg diagnose and will exit")
|
print("Error: bad number of tsg diagnose and will exit")
|
||||||
parser.print_help()
|
parser.print_help()
|
||||||
@@ -1359,7 +1362,15 @@ class TsgDiagnose:
|
|||||||
print(format(("Service function id:" + str(id_service_function) + ",Test end time: " + time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())),'=^70s'))
|
print(format(("Service function id:" + str(id_service_function) + ",Test end time: " + time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())),'=^70s'))
|
||||||
|
|
||||||
def _dign_service_function_running(self):
|
def _dign_service_function_running(self):
|
||||||
for id_service_function in range(1,self.count_service_function + 1):
|
if self.list_service_function_index == None:
|
||||||
|
for id_service_function in range(1,self.max_service_function_index + 1):
|
||||||
|
set_http_request_resolve(id_service_function)
|
||||||
|
set_dns_server_ip(id_service_function)
|
||||||
|
#print(REQUEST_RESOLVE)
|
||||||
|
self._dign_running(id_service_function)
|
||||||
|
else:
|
||||||
|
self.list_service_function_index.sort()
|
||||||
|
for id_service_function in self.list_service_function_index:
|
||||||
set_http_request_resolve(id_service_function)
|
set_http_request_resolve(id_service_function)
|
||||||
set_dns_server_ip(id_service_function)
|
set_dns_server_ip(id_service_function)
|
||||||
#print(REQUEST_RESOLVE)
|
#print(REQUEST_RESOLVE)
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
#!/bin/bash -e
|
#!/bin/bash -e
|
||||||
K3S_BIN_PATH="/usr/bin/k3s"
|
K3S_BIN_PATH="/usr/bin/k3s"
|
||||||
count_service_function=1
|
max_service_function_index=1
|
||||||
|
service_function_index=""
|
||||||
|
|
||||||
ARGS=`getopt -a -o c:h -l count-service-function:,help -- "$@"`
|
ARGS=`getopt -a -o m:i:h -l max-service-function-index:,service-function-index:,help -- "$@"`
|
||||||
eval set -- "${ARGS}"
|
eval set -- "${ARGS}"
|
||||||
usage(){
|
usage(){
|
||||||
echo ""
|
echo ""
|
||||||
@@ -10,7 +11,10 @@ usage(){
|
|||||||
echo ""
|
echo ""
|
||||||
echo "Options:"
|
echo "Options:"
|
||||||
echo " -h --help Detailed usage syntax"
|
echo " -h --help Detailed usage syntax"
|
||||||
echo " -c --count-service-function Count of service-function,default:1"
|
echo " -m --max-service-function-index Count of service-function,default:1"
|
||||||
|
echo " -i --service-function-index List of service-function index"
|
||||||
|
echo "Example: tsg-diagnose-oneshot -m 5"
|
||||||
|
echo " or tsg-diagnose-oneshot -i 1 -i 2 -i 3"
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -18,8 +22,11 @@ function get_args(){
|
|||||||
while true
|
while true
|
||||||
do
|
do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
-c|--count-sf)
|
-m|--max-service-function-index)
|
||||||
export count_service_function=$2
|
export max_service_function_index=$2
|
||||||
|
;;
|
||||||
|
-i|--service-function-index)
|
||||||
|
export service_function_index="$2 $service_function_index"
|
||||||
;;
|
;;
|
||||||
-h|--help)
|
-h|--help)
|
||||||
usage
|
usage
|
||||||
@@ -36,7 +43,11 @@ function get_args(){
|
|||||||
get_args $@
|
get_args $@
|
||||||
|
|
||||||
if [ -f "$K3S_BIN_PATH" ]; then
|
if [ -f "$K3S_BIN_PATH" ]; then
|
||||||
kubectl exec -it daemonset/dign-client -- python bin/client.py -C $count_service_function
|
if [ -z "$service_function_index" ]; then
|
||||||
|
kubectl exec -it daemonset/dign-client -- python bin/client.py -m $max_service_function_index
|
||||||
|
else
|
||||||
|
kubectl exec -it daemonset/dign-client -- python bin/client.py -d $service_function_index
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
systemctl start tsg-diagnose
|
systemctl start tsg-diagnose
|
||||||
sleep 10
|
sleep 10
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
#!/bin/bash -e
|
#!/bin/bash -e
|
||||||
K3S_BIN_PATH="/usr/bin/k3s"
|
K3S_BIN_PATH="/usr/bin/k3s"
|
||||||
count_service_function=1
|
max_service_function_index=1
|
||||||
|
service_function_index=""
|
||||||
|
|
||||||
ARGS=`getopt -a -o c:h -l count-service-function:,help -- "$@"`
|
ARGS=`getopt -a -o m:i:h -l max-service-function-index:,service-function-index:,help -- "$@"`
|
||||||
eval set -- "${ARGS}"
|
eval set -- "${ARGS}"
|
||||||
usage(){
|
usage(){
|
||||||
echo ""
|
echo ""
|
||||||
@@ -10,7 +11,10 @@ usage(){
|
|||||||
echo ""
|
echo ""
|
||||||
echo "Options:"
|
echo "Options:"
|
||||||
echo " -h --help Detailed usage syntax"
|
echo " -h --help Detailed usage syntax"
|
||||||
echo " -c --count-service-function Count of service-function,default:1"
|
echo " -m --max-service-function-index Count of service-function,default:1"
|
||||||
|
echo " -i --service-function-index List of service-function index"
|
||||||
|
echo "Example: tsg-diagnose-oneshot -m 5"
|
||||||
|
echo " or tsg-diagnose-oneshot -i 1 -i 2 -i 3"
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -18,8 +22,11 @@ function get_args(){
|
|||||||
while true
|
while true
|
||||||
do
|
do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
-c|--count-sf)
|
-m|--max-service-function-index)
|
||||||
export count_service_function=$2
|
export max_service_function_index=$2
|
||||||
|
;;
|
||||||
|
-i|--service-function-index)
|
||||||
|
export service_function_index="$2 $service_function_index"
|
||||||
;;
|
;;
|
||||||
-h|--help)
|
-h|--help)
|
||||||
usage
|
usage
|
||||||
@@ -36,7 +43,11 @@ function get_args(){
|
|||||||
get_args $@
|
get_args $@
|
||||||
|
|
||||||
if [ -f "$K3S_BIN_PATH" ]; then
|
if [ -f "$K3S_BIN_PATH" ]; then
|
||||||
kubectl exec -it daemonset/dign-client -- python bin/client.py -C $count_service_function
|
if [ -z "$service_function_index" ]; then
|
||||||
|
kubectl exec -it daemonset/dign-client -- python bin/client.py -m $max_service_function_index -l
|
||||||
|
else
|
||||||
|
kubectl exec -it daemonset/dign-client -- python bin/client.py -d $service_function_index -l
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
systemctl start tsg-diagnose
|
systemctl start tsg-diagnose
|
||||||
sleep 10
|
sleep 10
|
||||||
|
|||||||
Reference in New Issue
Block a user