Skip to content

Commit b3c2975

Browse files
mmolsmoizpgedge
andauthored
cleanup inputs / version / display in json-create (#285)
* display default pg_ver in json-create input * fix spock version parsing when revision is 2 digits * remove codename * align display of defaults across options * align display with quotes * cleanup pgBackRest question * add better summary for json-create * fix indenting on json-create summary * second pass at summary * Update cluster.py ha REMOVED * fix wording in helptext --------- Co-authored-by: Moiz Ibrar <moiz@pgedge.com>
1 parent 907fbcf commit b3c2975

File tree

3 files changed

+31
-31
lines changed

3 files changed

+31
-31
lines changed

cli/scripts/cluster.py

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -719,7 +719,7 @@ def json_create(
719719
cluster_name, num_nodes, db, usr, passwd, pg_ver=None, port=None, force=False
720720
):
721721
"""
722-
Create a Cluster Configuration JSON file with options for HA, BackRest, and Spock.
722+
Create a Cluster Configuration JSON file with options for pgBackRest and Spock.
723723
724724
Usage:
725725
./pgedge cluster json-create CLUSTER_NAME NUM_NODES DB USR PASSWD [pg_ver=PG_VERSION] [--port PORT]
@@ -845,7 +845,7 @@ def get_cluster_info(cluster_name):
845845
pg_input = str(pg_version_int)
846846
else:
847847
pg_input = (
848-
input(f"PostgreSQL version {pgs} [default: {pg_ver}]: ").strip()
848+
input(f"PostgreSQL version {pgs} (default: '{pg_default}'): ").strip()
849849
or pg_default
850850
)
851851

@@ -864,7 +864,7 @@ def get_cluster_info(cluster_name):
864864
while True:
865865
spock_version = (
866866
input(
867-
f"Spock version (e.g., {spocks}) or press Enter for default: "
867+
f"Spock version {spocks} (default: '{spock_default}'): "
868868
).strip()
869869
or spock_default
870870
)
@@ -896,7 +896,7 @@ def get_cluster_info(cluster_name):
896896
backrest_enabled = False
897897
else:
898898
backrest_enabled_input = (
899-
input("Do you want to enable BackRest for this cluster? (Y/N): ")
899+
input("Enable pgBackRest? (Y/N) (default: 'N'): ")
900900
.strip()
901901
.lower()
902902
)
@@ -905,11 +905,11 @@ def get_cluster_info(cluster_name):
905905
# Initialize backrest_json based on user input
906906
if backrest_enabled:
907907
backrest_storage_path = (
908-
input(" pgBackRest storage path (default: /var/lib/pgbackrest): ").strip()
908+
input(" pgBackRest storage path (default: '/var/lib/pgbackrest'): ").strip()
909909
or "/var/lib/pgbackrest"
910910
)
911911
backrest_archive_mode = (
912-
input(" pgBackRest archive mode (on/off) (default: on): ").strip().lower()
912+
input(" pgBackRest archive mode (on/off) (default: 'on'): ").strip().lower()
913913
or "on"
914914
)
915915
if backrest_archive_mode not in ["on", "off"]:
@@ -918,14 +918,14 @@ def get_cluster_info(cluster_name):
918918
)
919919
# Optionally, ask for repo1_type or default to posix
920920
repo1_type = (
921-
input(" pgBackRest repository type (posix/s3) (default: posix): ")
921+
input(" pgBackRest repository type (posix/s3) (default: 'posix'): ")
922922
.strip()
923923
.lower()
924924
or "posix"
925925
)
926926
if repo1_type not in ["posix", "s3"]:
927927
util.exit_message(
928-
"Invalid BackRest repository type. Allowed values are 'posix' or 's3'."
928+
"Invalid pgBackRest repository type. Allowed values are 'posix' or 's3'."
929929
)
930930
backrest_json = {
931931
"stanza": "demo_stanza",
@@ -959,13 +959,13 @@ def get_cluster_info(cluster_name):
959959
else:
960960
public_ip = (
961961
input(
962-
f" Public IP address for Node {n} (leave blank for default '{default_ip}'): "
962+
f" Public IP address for Node {n} (default: '{default_ip}'): "
963963
).strip()
964964
or default_ip
965965
)
966966
private_ip = (
967967
input(
968-
f" Private IP address for Node {n} (leave blank to use public IP '{public_ip}'): "
968+
f" Private IP address for Node {n} (default: '{public_ip}'): "
969969
).strip()
970970
or public_ip
971971
)
@@ -984,7 +984,7 @@ def get_cluster_info(cluster_name):
984984
node_default_port = default_port
985985
while True:
986986
node_port_input = input(
987-
f" PostgreSQL port for Node {n} (leave blank for default '{node_default_port}'): "
987+
f" PostgreSQL port for Node {n} (default: '{node_default_port}'): "
988988
).strip()
989989
if not node_port_input:
990990
node_port = node_default_port
@@ -1040,13 +1040,13 @@ def get_cluster_info(cluster_name):
10401040

10411041
public_ip = (
10421042
input(
1043-
f" Public IP address of replica Node {i} (leave blank for default '{default_ip}'): "
1043+
f" Public IP address of replica Node {i} (default: '{default_ip}'): "
10441044
).strip()
10451045
or default_ip
10461046
)
10471047
private_ip = (
10481048
input(
1049-
f" Private IP address of replica Node {i} (leave blank to use public IP '{public_ip}'): "
1049+
f" Private IP address of replica Node {i} (default: '{public_ip}'): "
10501050
).strip()
10511051
or public_ip
10521052
)
@@ -1055,7 +1055,7 @@ def get_cluster_info(cluster_name):
10551055

10561056
while True:
10571057
replica_port_input = input(
1058-
f" PostgreSQL port of replica Node {i} (leave blank for default '{current_replica_port}'): "
1058+
f" PostgreSQL port of replica Node {i} (default: '{current_replica_port}'): "
10591059
).strip()
10601060
if not replica_port_input:
10611061
replica_port = current_replica_port
@@ -1171,27 +1171,27 @@ def get_cluster_info(cluster_name):
11711171
bold_end = "\033[0m"
11721172

11731173
print("\n" + "#" * 80)
1174-
print(
1175-
f"# {bold_start}Version{bold_end} : pgEdge 24.10-5 (Constellation)"
1176-
)
1177-
print(f"# {bold_start}User & Host{bold_end} : {os_user} {os.getcwd()}")
1178-
print(
1179-
f"# {bold_start}OS{bold_end} : Linux, Python {sys.version.split()[0]}"
1180-
)
1181-
print(f"# {bold_start}Machine{bold_end} : N/A")
1182-
print(f"# {bold_start}Repo URL{bold_end} : N/A")
1183-
print(f"# {bold_start}Last Update{bold_end} : None")
11841174
print(f"# {bold_start}Cluster Name{bold_end} : {cluster_name}")
11851175
print(f"# {bold_start}PostgreSQL Version{bold_end} : {pg_version_int}")
11861176
print(
11871177
f"# {bold_start}Spock Version{bold_end} : {spock_version if spock_version else 'Not specified'}"
11881178
)
1179+
print(f"# {bold_start}Number of Nodes{bold_end} : {num_nodes}")
1180+
print(f"# {bold_start}Database Name{bold_end} : {db}")
1181+
print(f"# {bold_start}User{bold_end} : {usr}")
11891182
print(
1190-
f"# {bold_start}HA Cluster{bold_end} : {'Yes' if is_ha_cluster else 'No'}"
1191-
)
1192-
print(
1193-
f"# {bold_start}BackRest Enabled{bold_end} : {'Yes' if backrest_enabled else 'No'}"
1183+
f"# {bold_start}pgBackRest Enabled{bold_end} : {'Yes' if backrest_enabled else 'No'}"
11941184
)
1185+
if backrest_enabled:
1186+
print(f"# {bold_start}Storage Path{bold_end} : {backrest_storage_path}")
1187+
print(f"# {bold_start}Archive Mode{bold_end} : {backrest_archive_mode}")
1188+
print(f"# {bold_start}Repository Type{bold_end} : {repo1_type}")
1189+
for idx, node in enumerate(node_groups, start=1):
1190+
print(f"# {bold_start}Node {idx}{bold_end}")
1191+
print(f"# {bold_start}Public IP{bold_end} : {node['public_ip']}")
1192+
print(f"# {bold_start}Private IP{bold_end} : {node['private_ip']}")
1193+
print(f"# {bold_start}Port{bold_end} : {node['port']}")
1194+
11951195
print("#" * 80)
11961196

11971197
if not force:

cli/scripts/meta.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ def get_default_spock(pgv):
313313
c.execute(sql)
314314
data = c.fetchall()
315315
for comp in data:
316-
spock_ver_minor = comp[0][0:5]
316+
spock_ver_minor = comp[0].split('-')[0]
317317
avail_spock.append(spock_ver_minor)
318318
if f"{default_spock[0]}.{default_spock[1]}" in spock_ver_minor:
319319
default_spock = spock_ver_minor

cli/scripts/util.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import time
66

77
MY_VERSION = "25.0.0"
8-
MY_CODENAME = "Constellation"
8+
MY_CODENAME = ""
99

1010
DEFAULT_PG = "16"
1111
DEFAULT_SPOCK = "40"
@@ -254,7 +254,7 @@ def format_ver(p_ver):
254254
message(f"'{p_ver}' is not a valid three part version string", "warning")
255255
return(p_ver)
256256

257-
return(f"{v[0]}.{str(v[1]).rjust(2,'0')}-{v[2]}")
257+
return(f"{v[0]}.{v[1]}-{v[2]}")
258258

259259

260260
def autostart_verify_prereqs():

0 commit comments

Comments
 (0)