Skip to content

Commit 78ff9ee

Browse files
authored
Merge pull request #20 from sacherjj/add-single-protocol-pull
Add single_protocol_pull
2 parents da273aa + 08f1cbb commit 78ff9ee

3 files changed

Lines changed: 44 additions & 3 deletions

File tree

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.0.8
1+
1.0.9

casper-node-util/DEBIAN/control

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Package: casper-node-util
2-
Version: 1.0.8
2+
Version: 1.0.9
33
Architecture: all
44
Maintainer: Joe Sacher <joe.sacher@casper.network>
55
Description: Utility for working with casper-node and casper-sidecar

casper-node-util/usr/bin/casper-node-util

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ NET_CONFIG_PATH = CONFIG_PATH / "network_configs"
3030
SCRIPT_NAME = "casper-node-util"
3131
NODE_IP = "127.0.0.1"
3232
# Below is automatically replaced. Modify set_version.py if changing
33-
VERSION = "1.0.8"
33+
VERSION = "1.0.9"
3434

3535
def get_value_in_section(lines, section_name, value_name):
3636
""" A bit of a hack due to toml not being in std lib """
@@ -516,6 +516,47 @@ class NodeUtil:
516516
ip = str(args.ip) if args.ip else None
517517
self._config_from_example(args.protocol_version, ip, args.replace)
518518

519+
def stage_single_protocol(self):
520+
"""Stage a single protocol without checking if available"""
521+
parser = argparse.ArgumentParser(description=self.stage_protocols.__doc__,
522+
usage=(f"{SCRIPT_NAME} stage_single_protocol [-h] config protocol_version "
523+
"[--ip IP] [--replace toml_file]"))
524+
parser.add_argument("config", type=str, help=f"name of config file to use from {NET_CONFIG_PATH}")
525+
parser.add_argument("protocol_version", type=str, help=f"protocol version to pull (x_y_z)")
526+
parser.add_argument("--ip",
527+
type=ip_address,
528+
help=f"optional ip to use for config.toml instead of detected ip.",
529+
required=False)
530+
parser.add_argument("--replace",
531+
type=str,
532+
help=("optional toml file that holds replacements to make to config.toml "
533+
"from config-example.toml"),
534+
required=False)
535+
args = parser.parse_args(sys.argv[2:])
536+
self._load_config_values(args.config)
537+
538+
verify_casper_user()
539+
exit_code = 0
540+
pv = args.protocol_version
541+
status = self._check_staged_version(pv)
542+
if status == StagedStatus.STAGED:
543+
print(f"{pv}: {status}")
544+
elif status in (StagedStatus.BIN_ONLY, StagedStatus.CONFIG_ONLY):
545+
print(f"{pv}: {status} - Not automatically recoverable.")
546+
exit_code = 1
547+
if status == StagedStatus.UNSTAGED:
548+
print(f"Pulling protocol for {pv}.")
549+
if not self._pull_protocol_version(pv):
550+
exit_code = 1
551+
if status in (StagedStatus.UNSTAGED, StagedStatus.NO_CONFIG):
552+
print(f"Creating config for {pv}.")
553+
ip = str(args.ip) if args.ip else None
554+
if not self._config_from_example(pv, ip, args.replace):
555+
exit_code = 1
556+
exit(exit_code)
557+
558+
559+
519560
def stage_protocols(self):
520561
"""Stage available protocols if needed (use 'sudo -u casper')"""
521562
parser = argparse.ArgumentParser(description=self.stage_protocols.__doc__,

0 commit comments

Comments
 (0)