mirror of https://git.48k.eu/ogcli/
change 'ogcli send' command into 'ogcli request'
By using the word 'request' the command becomes more semantic and represents the 'best effort' nature of the communication with ogserver.master
parent
9f78cc5ace
commit
b242ee9f6e
28
cli/cli.py
28
cli/cli.py
|
@ -124,27 +124,27 @@ class OgCLI():
|
||||||
elif parsed_args.item == 'server':
|
elif parsed_args.item == 'server':
|
||||||
OgServer.set_server(self.rest, args[1:])
|
OgServer.set_server(self.rest, args[1:])
|
||||||
|
|
||||||
def send(self, args):
|
def request(self, args):
|
||||||
choices = ['reboot', 'refresh', 'poweroff', 'wol', 'session']
|
choices = ['reboot', 'refresh', 'poweroff', 'wol', 'session']
|
||||||
parser = argparse.ArgumentParser(prog='ogcli send')
|
parser = argparse.ArgumentParser(prog='ogcli request')
|
||||||
parser.add_argument('send_obj', choices=choices)
|
parser.add_argument('request_obj', choices=choices)
|
||||||
|
|
||||||
if not args:
|
if not args:
|
||||||
print('Missing send subcommand', file=sys.stderr)
|
print('Missing request subcommand', file=sys.stderr)
|
||||||
parser.print_help(file=sys.stderr)
|
parser.print_help(file=sys.stderr)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
parsed_args = parser.parse_args([args[0]])
|
parsed_args = parser.parse_args([args[0]])
|
||||||
if parsed_args.send_obj == 'wol':
|
if parsed_args.request_obj == 'wol':
|
||||||
OgWol.send_wol(self.rest, args[1:])
|
OgWol.request_wol(self.rest, args[1:])
|
||||||
elif parsed_args.send_obj == 'poweroff':
|
elif parsed_args.request_obj == 'poweroff':
|
||||||
OgPoweroff.send_poweroff(self.rest, args[1:])
|
OgPoweroff.request_poweroff(self.rest, args[1:])
|
||||||
elif parsed_args.send_obj == 'refresh':
|
elif parsed_args.request_obj == 'refresh':
|
||||||
OgClient.send_refresh(self.rest, args[1:])
|
OgClient.request_refresh(self.rest, args[1:])
|
||||||
elif parsed_args.send_obj == 'reboot':
|
elif parsed_args.request_obj == 'reboot':
|
||||||
OgReboot.send_reboot(self.rest, args[1:])
|
OgReboot.request_reboot(self.rest, args[1:])
|
||||||
elif parsed_args.send_obj == 'session':
|
elif parsed_args.request_obj == 'session':
|
||||||
OgSession.send_session(self.rest, args[1:])
|
OgSession.request_session(self.rest, args[1:])
|
||||||
|
|
||||||
def restore(self, args):
|
def restore(self, args):
|
||||||
choices = ['image']
|
choices = ['image']
|
||||||
|
|
|
@ -45,8 +45,8 @@ class OgClient():
|
||||||
print_json(r.text)
|
print_json(r.text)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def send_refresh(rest, args):
|
def request_refresh(rest, args):
|
||||||
parser = argparse.ArgumentParser(prog='ogcli send refresh')
|
parser = argparse.ArgumentParser(prog='ogcli request refresh')
|
||||||
parser.add_argument('--client-ip',
|
parser.add_argument('--client-ip',
|
||||||
action='append',
|
action='append',
|
||||||
default=[],
|
default=[],
|
||||||
|
|
|
@ -13,8 +13,8 @@ import argparse
|
||||||
class OgPoweroff():
|
class OgPoweroff():
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def send_poweroff(rest, args):
|
def request_poweroff(rest, args):
|
||||||
parser = argparse.ArgumentParser(prog='ogcli send poweroff')
|
parser = argparse.ArgumentParser(prog='ogcli request poweroff')
|
||||||
group = parser.add_argument_group(
|
group = parser.add_argument_group(
|
||||||
'clients', 'Client selection options')
|
'clients', 'Client selection options')
|
||||||
group.add_argument('--center-id',
|
group.add_argument('--center-id',
|
||||||
|
|
|
@ -13,8 +13,8 @@ import argparse
|
||||||
class OgReboot():
|
class OgReboot():
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def send_reboot(rest, args):
|
def request_reboot(rest, args):
|
||||||
parser = argparse.ArgumentParser(prog='ogcli send reboot')
|
parser = argparse.ArgumentParser(prog='ogcli request reboot')
|
||||||
group = parser.add_argument_group(
|
group = parser.add_argument_group(
|
||||||
'clients', 'Client selection options')
|
'clients', 'Client selection options')
|
||||||
group.add_argument('--center-id',
|
group.add_argument('--center-id',
|
||||||
|
|
|
@ -13,8 +13,8 @@ import argparse
|
||||||
class OgSession():
|
class OgSession():
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def send_session(rest, args):
|
def request_session(rest, args):
|
||||||
parser = argparse.ArgumentParser(prog='ogcli send session')
|
parser = argparse.ArgumentParser(prog='ogcli request session')
|
||||||
parser.add_argument('--disk',
|
parser.add_argument('--disk',
|
||||||
nargs='?',
|
nargs='?',
|
||||||
required=True,
|
required=True,
|
||||||
|
|
|
@ -13,7 +13,7 @@ import argparse
|
||||||
class OgWol():
|
class OgWol():
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def send_wol(rest, args):
|
def request_wol(rest, args):
|
||||||
def scope_lookup(scope_id, scope_type, d):
|
def scope_lookup(scope_id, scope_type, d):
|
||||||
if scope_id == d.get('id') and \
|
if scope_id == d.get('id') and \
|
||||||
scope_type == d.get('type'):
|
scope_type == d.get('type'):
|
||||||
|
@ -26,7 +26,7 @@ class OgWol():
|
||||||
return lookup
|
return lookup
|
||||||
return None
|
return None
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(prog='ogcli send wol')
|
parser = argparse.ArgumentParser(prog='ogcli request wol')
|
||||||
parser.add_argument('--type',
|
parser.add_argument('--type',
|
||||||
nargs='?',
|
nargs='?',
|
||||||
choices=['broadcast', 'unicast'],
|
choices=['broadcast', 'unicast'],
|
||||||
|
|
|
@ -21,13 +21,13 @@ function check_client_status {
|
||||||
|
|
||||||
IP="192.168.56.11"
|
IP="192.168.56.11"
|
||||||
|
|
||||||
echo "Sending WoL to client $IP"
|
echo "Requesting WoL to client $IP"
|
||||||
./ogcli send wol --client-ip "$IP"
|
./ogcli request wol --client-ip "$IP"
|
||||||
|
|
||||||
check_client_status $IP "WOL_SENT"
|
check_client_status $IP "WOL_SENT"
|
||||||
echo "Client is ready... partitioning client"
|
echo "Client is ready... partitioning client"
|
||||||
./ogcli setup disk --type dos --num 1 --part 1,LINUX,EXT4,40G --part 4,CACHE,CACHE,10G --format 1,4 --client-ip "$IP"
|
./ogcli setup disk --type dos --num 1 --part 1,LINUX,EXT4,40G --part 4,CACHE,CACHE,10G --format 1,4 --client-ip "$IP"
|
||||||
# ./ogcli send refresh --client-ip "$IP"
|
# ./ogcli request refresh --client-ip "$IP"
|
||||||
|
|
||||||
check_client_status $IP "BSY"
|
check_client_status $IP "BSY"
|
||||||
echo "Client is ready... restoring image"
|
echo "Client is ready... restoring image"
|
||||||
|
@ -39,4 +39,4 @@ echo "Client is ready... setting boot mode to first disk first partition"
|
||||||
|
|
||||||
check_client_status $IP "BSY"
|
check_client_status $IP "BSY"
|
||||||
echo "Client is ready... shutting down client"
|
echo "Client is ready... shutting down client"
|
||||||
./ogcli send poweroff --client-ip "$IP"
|
./ogcli request poweroff --client-ip "$IP"
|
||||||
|
|
|
@ -8,4 +8,4 @@
|
||||||
# Usually on debian based distros one can insert cron tasks
|
# Usually on debian based distros one can insert cron tasks
|
||||||
# using "crontab -e".
|
# using "crontab -e".
|
||||||
|
|
||||||
0 22 * * 1-5 ogcli send poweroff --client-ip 192.168.56.11
|
0 22 * * 1-5 ogcli request poweroff --client-ip 192.168.56.11
|
||||||
|
|
Loading…
Reference in New Issue