LSST Applications g063fba187b+cac8b7c890,g0f08755f38+6aee506743,g1653933729+a8ce1bb630,g168dd56ebc+a8ce1bb630,g1a2382251a+b4475c5878,g1dcb35cd9c+8f9bc1652e,g20f6ffc8e0+6aee506743,g217e2c1bcf+73dee94bd0,g28da252d5a+1f19c529b9,g2bbee38e9b+3f2625acfc,g2bc492864f+3f2625acfc,g3156d2b45e+6e55a43351,g32e5bea42b+1bb94961c2,g347aa1857d+3f2625acfc,g35bb328faa+a8ce1bb630,g3a166c0a6a+3f2625acfc,g3e281a1b8c+c5dd892a6c,g3e8969e208+a8ce1bb630,g414038480c+5927e1bc1e,g41af890bb2+8a9e676b2a,g7af13505b9+809c143d88,g80478fca09+6ef8b1810f,g82479be7b0+f568feb641,g858d7b2824+6aee506743,g89c8672015+f4add4ffd5,g9125e01d80+a8ce1bb630,ga5288a1d22+2903d499ea,gb58c049af0+d64f4d3760,gc28159a63d+3f2625acfc,gcab2d0539d+b12535109e,gcf0d15dbbd+46a3f46ba9,gda6a2b7d83+46a3f46ba9,gdaeeff99f8+1711a396fd,ge79ae78c31+3f2625acfc,gef2f8181fd+0a71e47438,gf0baf85859+c1f95f4921,gfa517265be+6aee506743,gfa999e8aa5+17cd334064,w.2024.51
LSST Data Management Base Package
Loading...
Searching...
No Matches
Functions
apdb_cli Namespace Reference

Functions

None main (Sequence[str]|None args=None)
 
None _create_sql_subcommand (argparse._SubParsersAction subparsers)
 
None _create_cassandra_subcommand (argparse._SubParsersAction subparsers)
 
None _list_cassandra_subcommand (argparse._SubParsersAction subparsers)
 
None _delete_cassandra_subcommand (argparse._SubParsersAction subparsers)
 
None _list_index_subcommand (argparse._SubParsersAction subparsers)
 
None _metadata_subcommand (argparse._SubParsersAction subparsers)
 
None _metadata_show_subcommand (argparse._SubParsersAction subparsers)
 
None _metadata_get_subcommand (argparse._SubParsersAction subparsers)
 
None _metadata_set_subcommand (argparse._SubParsersAction subparsers)
 
None _metadata_delete_subcommand (argparse._SubParsersAction subparsers)
 

Function Documentation

◆ _create_cassandra_subcommand()

None apdb_cli._create_cassandra_subcommand ( argparse._SubParsersAction subparsers)
protected

Definition at line 68 of file apdb_cli.py.

68def _create_cassandra_subcommand(subparsers: argparse._SubParsersAction) -> None:
69 parser = subparsers.add_parser("create-cassandra", help="Create new APDB instance in Cassandra cluster.")
70 parser.add_argument("host", help="One or more host names for Cassandra cluster.", nargs="+")
71 parser.add_argument(
72 "keyspace", help="Cassandra keyspace name for APDB tables, will be created if does not exist."
73 )
74 parser.add_argument("output_config", help="Name of the new configuration file for created APDB instance.")
77 parser.add_argument(
78 "--drop", help="If True then drop existing tables.", default=False, action="store_true"
79 )
80 parser.set_defaults(method=scripts.create_cassandra)
81
82
None common_apdb_options(argparse.ArgumentParser parser)
Definition options.py:54
None cassandra_config_options(argparse.ArgumentParser parser)
Definition options.py:87

◆ _create_sql_subcommand()

None apdb_cli._create_sql_subcommand ( argparse._SubParsersAction subparsers)
protected

Definition at line 56 of file apdb_cli.py.

56def _create_sql_subcommand(subparsers: argparse._SubParsersAction) -> None:
57 parser = subparsers.add_parser("create-sql", help="Create new APDB instance in SQL database.")
58 parser.add_argument("db_url", help="Database URL in SQLAlchemy format for APDB instance.")
59 parser.add_argument("output_config", help="Name of the new configuration file for created APDB instance.")
62 parser.add_argument(
63 "--drop", help="If True then drop existing tables.", default=False, action="store_true"
64 )
65 parser.set_defaults(method=scripts.create_sql)
66
67
None sql_config_options(argparse.ArgumentParser parser)
Definition options.py:67

◆ _delete_cassandra_subcommand()

None apdb_cli._delete_cassandra_subcommand ( argparse._SubParsersAction subparsers)
protected

Definition at line 96 of file apdb_cli.py.

96def _delete_cassandra_subcommand(subparsers: argparse._SubParsersAction) -> None:
97 parser = subparsers.add_parser("delete-cassandra", help="Delete APDB instance from Cassandra cluster.")
98 parser.add_argument("host", help="One of the host names for Cassandra cluster.")
99 parser.add_argument("keyspace", help="Cassandra keyspace name for APDB tables.")
100 parser.add_argument(
101 "-y",
102 "--confirm",
103 help="Assume 'yes' answer for confirmation.",
104 default=False,
105 action="store_true",
106 )
107 parser.set_defaults(method=scripts.delete_cassandra)
108
109

◆ _list_cassandra_subcommand()

None apdb_cli._list_cassandra_subcommand ( argparse._SubParsersAction subparsers)
protected

Definition at line 83 of file apdb_cli.py.

83def _list_cassandra_subcommand(subparsers: argparse._SubParsersAction) -> None:
84 parser = subparsers.add_parser("list-cassandra", help="List APDB instances in Cassandra cluster.")
85 parser.add_argument("host", help="One of the host names for Cassandra cluster.")
86 parser.add_argument(
87 "-v",
88 "--verbose",
89 help="Provide full list of roles and associated permissions.",
90 default=False,
91 action="store_true",
92 )
93 parser.set_defaults(method=scripts.list_cassandra)
94
95

◆ _list_index_subcommand()

None apdb_cli._list_index_subcommand ( argparse._SubParsersAction subparsers)
protected

Definition at line 110 of file apdb_cli.py.

110def _list_index_subcommand(subparsers: argparse._SubParsersAction) -> None:
111 parser = subparsers.add_parser("list-index", help="List contents of APDB index file.")
112 parser.add_argument(
113 "index_path", help="Location of index file, if missing then $DAX_APDB_INDEX_URI is used.", nargs="?"
114 )
115 parser.set_defaults(method=scripts.list_index)
116
117

◆ _metadata_delete_subcommand()

None apdb_cli._metadata_delete_subcommand ( argparse._SubParsersAction subparsers)
protected

Definition at line 163 of file apdb_cli.py.

163def _metadata_delete_subcommand(subparsers: argparse._SubParsersAction) -> None:
164 parser = subparsers.add_parser("delete", help="Delete metadata item.")
165 parser.add_argument("config", help="Path or URI of APDB configuration file.")
166 parser.add_argument("key", help="Metadata key, arbitrary string.")
167 parser.set_defaults(method=scripts.metadata_delete)

◆ _metadata_get_subcommand()

None apdb_cli._metadata_get_subcommand ( argparse._SubParsersAction subparsers)
protected

Definition at line 141 of file apdb_cli.py.

141def _metadata_get_subcommand(subparsers: argparse._SubParsersAction) -> None:
142 parser = subparsers.add_parser("get", help="Print value of the metadata item.")
143 parser.add_argument("config", help="Path or URI of APDB configuration file.")
144 parser.add_argument("key", help="Metadata key, arbitrary string.")
145 parser.set_defaults(method=scripts.metadata_get)
146
147

◆ _metadata_set_subcommand()

None apdb_cli._metadata_set_subcommand ( argparse._SubParsersAction subparsers)
protected

Definition at line 148 of file apdb_cli.py.

148def _metadata_set_subcommand(subparsers: argparse._SubParsersAction) -> None:
149 parser = subparsers.add_parser("set", help="Add or update metadata item.")
150 parser.add_argument(
151 "-f",
152 "--force",
153 help="Force update of the existing key.",
154 default=False,
155 action="store_true",
156 )
157 parser.add_argument("config", help="Path or URI of APDB configuration file.")
158 parser.add_argument("key", help="Metadata key, arbitrary string.")
159 parser.add_argument("value", help="Corresponding metadata value.")
160 parser.set_defaults(method=scripts.metadata_set)
161
162

◆ _metadata_show_subcommand()

None apdb_cli._metadata_show_subcommand ( argparse._SubParsersAction subparsers)
protected

Definition at line 127 of file apdb_cli.py.

127def _metadata_show_subcommand(subparsers: argparse._SubParsersAction) -> None:
128 parser = subparsers.add_parser("show", help="Show contents of APDB metadata table.")
129 parser.add_argument(
130 "-j",
131 "--json",
132 dest="use_json",
133 help="Dump metadata in JSON format.",
134 default=False,
135 action="store_true",
136 )
137 parser.add_argument("config", help="Path or URI of APDB configuration file.")
138 parser.set_defaults(method=scripts.metadata_show)
139
140

◆ _metadata_subcommand()

None apdb_cli._metadata_subcommand ( argparse._SubParsersAction subparsers)
protected

Definition at line 118 of file apdb_cli.py.

118def _metadata_subcommand(subparsers: argparse._SubParsersAction) -> None:
119 parser = subparsers.add_parser("metadata", help="Operations with APDB metadata table.")
120 subparsers = parser.add_subparsers(title="available subcommands", required=True)
121 _metadata_set_subcommand(subparsers)
122 _metadata_get_subcommand(subparsers)
123 _metadata_show_subcommand(subparsers)
124 _metadata_delete_subcommand(subparsers)
125
126

◆ main()

None apdb_cli.main ( Sequence[str] | None args = None)
APDB command line tools.

Definition at line 34 of file apdb_cli.py.

34def main(args: Sequence[str] | None = None) -> None:
35 """APDB command line tools."""
36 parser = argparse.ArgumentParser(description="APDB command line tools")
37 log_cli = LoggingCli(parser)
38
39 subparsers = parser.add_subparsers(title="available subcommands", required=True)
40 _create_sql_subcommand(subparsers)
41 _create_cassandra_subcommand(subparsers)
42 _list_cassandra_subcommand(subparsers)
43 _delete_cassandra_subcommand(subparsers)
44 _list_index_subcommand(subparsers)
45 _metadata_subcommand(subparsers)
46
47 parsed_args = parser.parse_args(args)
48 log_cli.process_args(parsed_args)
49
50 kwargs = vars(parsed_args)
51 # Strip keywords not understood by scripts.
52 method = kwargs.pop("method")
53 method(**kwargs)
54
55
int main(void)