xpk 0.6.0__py3-none-any.whl → 0.7.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- xpk/api/__init__.py +15 -0
- xpk/api/storage_crd.yaml +52 -0
- xpk/commands/batch.py +27 -5
- xpk/commands/cluster.py +104 -80
- xpk/commands/cluster_gcluster.py +94 -10
- xpk/commands/common.py +44 -0
- xpk/commands/config.py +29 -0
- xpk/commands/info.py +8 -10
- xpk/commands/inspector.py +5 -11
- xpk/commands/job.py +9 -7
- xpk/commands/kind.py +34 -4
- xpk/commands/kjob_common.py +44 -0
- xpk/commands/run.py +128 -0
- xpk/commands/shell.py +27 -7
- xpk/commands/storage.py +280 -0
- xpk/commands/version.py +6 -18
- xpk/commands/workload.py +381 -184
- xpk/core/blueprint/blueprint_definitions.py +1 -0
- xpk/core/blueprint/blueprint_generator.py +132 -76
- xpk/core/capacity.py +185 -0
- xpk/core/cluster.py +564 -0
- xpk/core/cluster_private.py +6 -3
- xpk/core/commands.py +18 -14
- xpk/core/config.py +179 -0
- xpk/core/docker_container.py +225 -0
- xpk/core/docker_image.py +210 -0
- xpk/core/docker_resources.py +350 -0
- xpk/core/filestore.py +251 -0
- xpk/core/gcloud_context.py +196 -0
- xpk/core/gcluster_manager.py +20 -2
- xpk/core/gcsfuse.py +50 -0
- xpk/core/kjob.py +257 -18
- xpk/core/kueue.py +12 -6
- xpk/core/monitoring.py +134 -0
- xpk/core/nap.py +32 -20
- xpk/core/network.py +377 -0
- xpk/core/nodepool.py +581 -0
- xpk/core/pathways.py +124 -45
- xpk/core/remote_state/__init__.py +15 -0
- xpk/core/remote_state/fuse_remote_state.py +99 -0
- xpk/core/remote_state/remote_state_client.py +38 -0
- xpk/core/resources.py +238 -0
- xpk/core/scheduling.py +253 -0
- xpk/core/storage.py +581 -0
- xpk/core/system_characteristics.py +38 -1
- xpk/core/vertex.py +105 -0
- xpk/core/workload.py +209 -1
- xpk/core/workload_decorators/rdma_decorator.py +25 -5
- xpk/core/workload_decorators/storage_decorator.py +52 -0
- xpk/core/workload_decorators/tcpxo_decorator.py +70 -37
- xpk/main.py +3 -1
- xpk/parser/batch.py +10 -151
- xpk/parser/cluster.py +49 -8
- xpk/parser/common.py +189 -1
- xpk/parser/config.py +49 -0
- xpk/parser/core.py +27 -1
- xpk/parser/info.py +2 -1
- xpk/parser/inspector.py +3 -3
- xpk/parser/job.py +25 -4
- xpk/parser/kind.py +3 -2
- xpk/parser/run.py +47 -0
- xpk/parser/shell.py +10 -1
- xpk/parser/storage.py +326 -0
- xpk/parser/validators.py +3 -3
- xpk/parser/workload.py +118 -76
- xpk/templates/__init__.py +15 -0
- xpk/templates/storage.yaml +13 -0
- xpk/utils/gcs_utils.py +125 -0
- xpk/utils/kubectl.py +57 -0
- xpk/utils/objects.py +8 -5
- xpk/utils/templates.py +28 -0
- xpk/utils/validation.py +80 -0
- {xpk-0.6.0.dist-info → xpk-0.7.1.dist-info}/METADATA +169 -15
- xpk-0.7.1.dist-info/RECORD +92 -0
- {xpk-0.6.0.dist-info → xpk-0.7.1.dist-info}/WHEEL +1 -1
- xpk/core/core.py +0 -2824
- xpk-0.6.0.dist-info/RECORD +0 -57
- {xpk-0.6.0.dist-info → xpk-0.7.1.dist-info}/entry_points.txt +0 -0
- {xpk-0.6.0.dist-info → xpk-0.7.1.dist-info/licenses}/LICENSE +0 -0
- {xpk-0.6.0.dist-info → xpk-0.7.1.dist-info}/top_level.txt +0 -0
xpk/parser/job.py
CHANGED
|
@@ -18,6 +18,7 @@ import argparse
|
|
|
18
18
|
from ..commands.job import job_info, job_list, job_cancel
|
|
19
19
|
|
|
20
20
|
from .common import add_shared_arguments
|
|
21
|
+
from .validators import name_type
|
|
21
22
|
|
|
22
23
|
|
|
23
24
|
def set_job_parser(job_parser: argparse.ArgumentParser):
|
|
@@ -45,11 +46,31 @@ def set_job_parser(job_parser: argparse.ArgumentParser):
|
|
|
45
46
|
|
|
46
47
|
|
|
47
48
|
def set_job_info_parser(job_info_parser: argparse.ArgumentParser):
|
|
48
|
-
|
|
49
|
+
job_info_required_arguments = job_info_parser.add_argument_group(
|
|
49
50
|
'Required arguments',
|
|
50
51
|
'The basic information required to identify the job.',
|
|
51
52
|
)
|
|
52
|
-
|
|
53
|
+
job_info_optional_arguments = job_info_parser.add_argument_group(
|
|
54
|
+
'Optional Arguments', 'Arguments optional for job info.'
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
### Required arguments
|
|
58
|
+
job_info_required_arguments.add_argument(
|
|
59
|
+
'--cluster',
|
|
60
|
+
type=name_type,
|
|
61
|
+
default=None,
|
|
62
|
+
help='The name of the cluster to info jobs on.',
|
|
63
|
+
required=True,
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
job_info_optional_arguments.add_argument(
|
|
67
|
+
'--kind-cluster',
|
|
68
|
+
type=bool,
|
|
69
|
+
action=argparse.BooleanOptionalAction,
|
|
70
|
+
default=False,
|
|
71
|
+
help='Apply command to a local test cluster.',
|
|
72
|
+
)
|
|
73
|
+
job_info_required_arguments.add_argument(
|
|
53
74
|
'name',
|
|
54
75
|
type=str,
|
|
55
76
|
default=None,
|
|
@@ -71,7 +92,7 @@ def set_job_list_parser(job_list_parser: argparse.ArgumentParser):
|
|
|
71
92
|
### Required arguments
|
|
72
93
|
job_list_required_arguments.add_argument(
|
|
73
94
|
'--cluster',
|
|
74
|
-
type=
|
|
95
|
+
type=name_type,
|
|
75
96
|
default=None,
|
|
76
97
|
help='The name of the cluster to list jobs on.',
|
|
77
98
|
required=True,
|
|
@@ -108,7 +129,7 @@ def set_job_cancel_parser(job_cancel_parser: argparse.ArgumentParser):
|
|
|
108
129
|
|
|
109
130
|
job_cancel_required_arguments.add_argument(
|
|
110
131
|
'--cluster',
|
|
111
|
-
type=
|
|
132
|
+
type=name_type,
|
|
112
133
|
default=None,
|
|
113
134
|
help='The name of the cluster to delete the job on.',
|
|
114
135
|
required=True,
|
xpk/parser/kind.py
CHANGED
|
@@ -20,6 +20,7 @@ from ..commands.kind import (
|
|
|
20
20
|
cluster_list,
|
|
21
21
|
)
|
|
22
22
|
from .common import add_global_arguments
|
|
23
|
+
from .validators import name_type
|
|
23
24
|
|
|
24
25
|
|
|
25
26
|
def set_kind_parser(kind_parser):
|
|
@@ -40,7 +41,7 @@ def set_kind_parser(kind_parser):
|
|
|
40
41
|
### Optional Arguments
|
|
41
42
|
cluster_create_parser.add_argument(
|
|
42
43
|
'--cluster',
|
|
43
|
-
type=
|
|
44
|
+
type=name_type,
|
|
44
45
|
default='kind',
|
|
45
46
|
help=(
|
|
46
47
|
'The name of the cluster. Will be used as the prefix for internal'
|
|
@@ -74,7 +75,7 @@ def set_kind_parser(kind_parser):
|
|
|
74
75
|
### Required arguments
|
|
75
76
|
cluster_delete_required_arguments.add_argument(
|
|
76
77
|
'--cluster',
|
|
77
|
-
type=
|
|
78
|
+
type=name_type,
|
|
78
79
|
default=None,
|
|
79
80
|
help='The name of the cluster to be deleted.',
|
|
80
81
|
required=True,
|
xpk/parser/run.py
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Copyright 2025 Google LLC
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
https://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
from ..commands.run import run
|
|
18
|
+
from .common import (
|
|
19
|
+
add_shared_arguments,
|
|
20
|
+
add_slurm_arguments,
|
|
21
|
+
add_cluster_arguments,
|
|
22
|
+
add_kind_cluster_arguments,
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def set_run_parser(run_parser):
|
|
27
|
+
run_required_arguments = run_parser.add_argument_group(
|
|
28
|
+
'Required Arguments', 'Arguments required for `run`.'
|
|
29
|
+
)
|
|
30
|
+
run_optional_arguments = run_parser.add_argument_group(
|
|
31
|
+
'Optional Arguments', 'Arguments optional for `run`.'
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
run_required_arguments.add_argument('script', help='script with task to run')
|
|
35
|
+
run_optional_arguments.add_argument(
|
|
36
|
+
'--timeout',
|
|
37
|
+
type=int,
|
|
38
|
+
default=None,
|
|
39
|
+
help='Amount of time to wait for job in seconds',
|
|
40
|
+
required=False,
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
add_cluster_arguments(run_optional_arguments)
|
|
44
|
+
add_kind_cluster_arguments(run_optional_arguments)
|
|
45
|
+
add_slurm_arguments(run_optional_arguments)
|
|
46
|
+
add_shared_arguments(run_parser)
|
|
47
|
+
run_parser.set_defaults(func=run)
|
xpk/parser/shell.py
CHANGED
|
@@ -15,7 +15,11 @@ limitations under the License.
|
|
|
15
15
|
"""
|
|
16
16
|
|
|
17
17
|
from ..commands.shell import shell, shell_stop
|
|
18
|
-
from .common import
|
|
18
|
+
from .common import (
|
|
19
|
+
add_shared_arguments,
|
|
20
|
+
add_cluster_arguments,
|
|
21
|
+
add_kind_cluster_arguments,
|
|
22
|
+
)
|
|
19
23
|
import argparse
|
|
20
24
|
|
|
21
25
|
|
|
@@ -26,6 +30,9 @@ def set_shell_parser(shell_parser: argparse.ArgumentParser) -> None:
|
|
|
26
30
|
add_shared_arguments(shell_optional_arguments)
|
|
27
31
|
shell_parser.set_defaults(func=shell)
|
|
28
32
|
|
|
33
|
+
add_cluster_arguments(shell_optional_arguments)
|
|
34
|
+
add_kind_cluster_arguments(shell_optional_arguments)
|
|
35
|
+
|
|
29
36
|
shell_subcommands = shell_parser.add_subparsers(
|
|
30
37
|
title='shell subcommands',
|
|
31
38
|
dest='xpk_shell_subcommands',
|
|
@@ -48,3 +55,5 @@ def set_shell_stop_parser(shell_stop_parser: argparse.ArgumentParser):
|
|
|
48
55
|
)
|
|
49
56
|
add_shared_arguments(shell_stop_optional_arguments)
|
|
50
57
|
shell_stop_parser.set_defaults(func=shell_stop)
|
|
58
|
+
add_cluster_arguments(shell_stop_parser)
|
|
59
|
+
add_kind_cluster_arguments(shell_stop_optional_arguments)
|
xpk/parser/storage.py
ADDED
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Copyright 2024 Google LLC
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
https://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
import argparse
|
|
18
|
+
|
|
19
|
+
from ..commands.storage import (
|
|
20
|
+
storage_attach,
|
|
21
|
+
storage_create,
|
|
22
|
+
storage_delete,
|
|
23
|
+
storage_detach,
|
|
24
|
+
storage_list,
|
|
25
|
+
)
|
|
26
|
+
from .common import (
|
|
27
|
+
add_cluster_arguments,
|
|
28
|
+
add_kind_cluster_arguments,
|
|
29
|
+
add_shared_arguments,
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def set_storage_parser(storage_parser: argparse.ArgumentParser) -> None:
|
|
34
|
+
storage_subcommands = storage_parser.add_subparsers(
|
|
35
|
+
title='storage subcommands',
|
|
36
|
+
dest='xpk_storage_subcommands',
|
|
37
|
+
help=(
|
|
38
|
+
'These are commands related to storage management. Look at help for'
|
|
39
|
+
' specific subcommands for more details.'
|
|
40
|
+
),
|
|
41
|
+
)
|
|
42
|
+
add_storage_attach_parser(storage_subcommands)
|
|
43
|
+
add_storage_list_parser(storage_subcommands)
|
|
44
|
+
add_storage_detach_parser(storage_subcommands)
|
|
45
|
+
add_storage_create_parser(storage_subcommands)
|
|
46
|
+
add_storage_delete_parser(storage_subcommands)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def add_storage_attach_parser(
|
|
50
|
+
storage_subcommands_parser: argparse.ArgumentParser,
|
|
51
|
+
) -> None:
|
|
52
|
+
|
|
53
|
+
storage_attach_parser: argparse.ArgumentParser = (
|
|
54
|
+
storage_subcommands_parser.add_parser(
|
|
55
|
+
'attach', help='attach XPK Storage.'
|
|
56
|
+
)
|
|
57
|
+
)
|
|
58
|
+
storage_attach_parser.set_defaults(func=storage_attach)
|
|
59
|
+
req_args = storage_attach_parser.add_argument_group(
|
|
60
|
+
'Required Arguments',
|
|
61
|
+
'Arguments required for storage attach.',
|
|
62
|
+
)
|
|
63
|
+
add_shared_arguments(req_args)
|
|
64
|
+
req_args.add_argument(
|
|
65
|
+
'name',
|
|
66
|
+
type=str,
|
|
67
|
+
help='The name of storage',
|
|
68
|
+
)
|
|
69
|
+
req_args.add_argument(
|
|
70
|
+
'--type',
|
|
71
|
+
type=str,
|
|
72
|
+
help=(
|
|
73
|
+
'The type of storage. Currently supported types: ["gcsfuse",'
|
|
74
|
+
' "gcpfilestore"]'
|
|
75
|
+
),
|
|
76
|
+
choices=['gcsfuse', 'gcpfilestore'],
|
|
77
|
+
required=True,
|
|
78
|
+
)
|
|
79
|
+
add_cluster_arguments(req_args, required=True)
|
|
80
|
+
req_args.add_argument(
|
|
81
|
+
'--auto-mount',
|
|
82
|
+
type=lambda v: v.lower() == 'true',
|
|
83
|
+
default=True,
|
|
84
|
+
required=True,
|
|
85
|
+
help='If true all workloads will have this storage mounted by default',
|
|
86
|
+
)
|
|
87
|
+
req_args.add_argument(
|
|
88
|
+
'--mount-point',
|
|
89
|
+
type=str,
|
|
90
|
+
required=True,
|
|
91
|
+
help='Path on which a given storage should be mounted for a workload',
|
|
92
|
+
)
|
|
93
|
+
req_args.add_argument(
|
|
94
|
+
'--readonly',
|
|
95
|
+
type=lambda v: v.lower() == 'true',
|
|
96
|
+
required=True,
|
|
97
|
+
help='If true workloads can only read from storage',
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
gcsfuse_args = storage_attach_parser.add_argument_group(
|
|
101
|
+
'FUSE arguments',
|
|
102
|
+
'Arguments used when --type=gcsfuse',
|
|
103
|
+
)
|
|
104
|
+
gcsfuse_args.add_argument(
|
|
105
|
+
'--size',
|
|
106
|
+
type=int,
|
|
107
|
+
help='The size of the volume to attach in gigabytes.',
|
|
108
|
+
)
|
|
109
|
+
gcsfuse_args.add_argument(
|
|
110
|
+
'--bucket',
|
|
111
|
+
type=str,
|
|
112
|
+
help=(
|
|
113
|
+
'(optional) Name of the bucket. If not set, then the "name" parameter'
|
|
114
|
+
' is infered as a bucket name.'
|
|
115
|
+
),
|
|
116
|
+
)
|
|
117
|
+
|
|
118
|
+
gcpfilestore_args = storage_attach_parser.add_argument_group(
|
|
119
|
+
'Filestore arguments',
|
|
120
|
+
'Arguments used when --type=gcpfilestore',
|
|
121
|
+
)
|
|
122
|
+
gcpfilestore_args.add_argument(
|
|
123
|
+
'--vol',
|
|
124
|
+
type=str,
|
|
125
|
+
help='(optional) The name of the volume to create. Default: "default"',
|
|
126
|
+
default='default',
|
|
127
|
+
)
|
|
128
|
+
gcpfilestore_args.add_argument(
|
|
129
|
+
'--access-mode',
|
|
130
|
+
type=str,
|
|
131
|
+
choices=['ReadWriteOnce', 'ReadOnlyMany', 'ReadWriteMany'],
|
|
132
|
+
help=(
|
|
133
|
+
'(optional) Access mode of created filestore instance. Default:'
|
|
134
|
+
' "ReadWriteMany"'
|
|
135
|
+
),
|
|
136
|
+
default='ReadWriteMany',
|
|
137
|
+
)
|
|
138
|
+
gcpfilestore_args.add_argument(
|
|
139
|
+
'--instance',
|
|
140
|
+
type=str,
|
|
141
|
+
help=(
|
|
142
|
+
'(optional) Name of the filestore instance. If not set, then the'
|
|
143
|
+
' "name" parameter is infered as an instance name.'
|
|
144
|
+
),
|
|
145
|
+
)
|
|
146
|
+
|
|
147
|
+
opt_args = storage_attach_parser.add_argument_group(
|
|
148
|
+
'Optional Arguments',
|
|
149
|
+
'Optional arguments for storage create.',
|
|
150
|
+
)
|
|
151
|
+
opt_args.add_argument(
|
|
152
|
+
'--manifest',
|
|
153
|
+
type=str,
|
|
154
|
+
help='Path to manifest file containing volume definitions',
|
|
155
|
+
)
|
|
156
|
+
add_kind_cluster_arguments(opt_args)
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
def add_storage_create_parser(
|
|
160
|
+
storage_subcommands_parser: argparse.ArgumentParser,
|
|
161
|
+
) -> None:
|
|
162
|
+
storage_create_parser: argparse.ArgumentParser = (
|
|
163
|
+
storage_subcommands_parser.add_parser(
|
|
164
|
+
'create', help='create XPK Storage.'
|
|
165
|
+
)
|
|
166
|
+
)
|
|
167
|
+
storage_create_parser.set_defaults(func=storage_create)
|
|
168
|
+
req_args = storage_create_parser.add_argument_group(
|
|
169
|
+
'Required Arguments',
|
|
170
|
+
'Arguments required for storage create.',
|
|
171
|
+
)
|
|
172
|
+
add_shared_arguments(req_args)
|
|
173
|
+
req_args.add_argument(
|
|
174
|
+
'name',
|
|
175
|
+
type=str,
|
|
176
|
+
help='The name of storage',
|
|
177
|
+
)
|
|
178
|
+
req_args.add_argument(
|
|
179
|
+
'--size',
|
|
180
|
+
type=str,
|
|
181
|
+
help=(
|
|
182
|
+
'The size of the volume to create in gigabytes or terabytes. If no'
|
|
183
|
+
' unit is specified, gigabytes are assumed.'
|
|
184
|
+
),
|
|
185
|
+
required=True,
|
|
186
|
+
)
|
|
187
|
+
|
|
188
|
+
req_args.add_argument(
|
|
189
|
+
'--type',
|
|
190
|
+
type=str,
|
|
191
|
+
help='The type of storage. Currently supported types: ["gcpfilestore"]',
|
|
192
|
+
choices=['gcpfilestore'],
|
|
193
|
+
required=True,
|
|
194
|
+
)
|
|
195
|
+
add_cluster_arguments(req_args, required=True)
|
|
196
|
+
req_args.add_argument(
|
|
197
|
+
'--mount-point',
|
|
198
|
+
type=str,
|
|
199
|
+
required=True,
|
|
200
|
+
)
|
|
201
|
+
req_args.add_argument(
|
|
202
|
+
'--readonly', type=lambda v: v.lower() == 'true', required=True
|
|
203
|
+
)
|
|
204
|
+
|
|
205
|
+
opt_args = storage_create_parser.add_argument_group(
|
|
206
|
+
'Optional Arguments',
|
|
207
|
+
'Optional arguments for storage create.',
|
|
208
|
+
)
|
|
209
|
+
opt_args.add_argument(
|
|
210
|
+
'--instance',
|
|
211
|
+
type=str,
|
|
212
|
+
help=(
|
|
213
|
+
'(optional) Name of the filestore instance. If not set, then the'
|
|
214
|
+
' "name" parameter is infered as an instance name.'
|
|
215
|
+
),
|
|
216
|
+
)
|
|
217
|
+
opt_args.add_argument(
|
|
218
|
+
'--vol',
|
|
219
|
+
type=str,
|
|
220
|
+
help='The name of the volume to create',
|
|
221
|
+
required=True,
|
|
222
|
+
default='default',
|
|
223
|
+
)
|
|
224
|
+
opt_args.add_argument(
|
|
225
|
+
'--tier',
|
|
226
|
+
type=str,
|
|
227
|
+
help=(
|
|
228
|
+
'The tier of the filestore to create. Possible values are:'
|
|
229
|
+
' [BASIC_HDD, BASIC_SSD, ZONAL, REGIONAL, ENTERPRISE]'
|
|
230
|
+
),
|
|
231
|
+
choices=['BASIC_HDD', 'BASIC_SSD', 'ZONAL', 'REGIONAL', 'ENTERPRISE'],
|
|
232
|
+
default='REGIONAL',
|
|
233
|
+
)
|
|
234
|
+
opt_args.add_argument(
|
|
235
|
+
'--auto-mount',
|
|
236
|
+
type=lambda v: v.lower() == 'true',
|
|
237
|
+
default=True,
|
|
238
|
+
)
|
|
239
|
+
opt_args.add_argument(
|
|
240
|
+
'--access-mode',
|
|
241
|
+
type=str,
|
|
242
|
+
choices=['ReadWriteOnce', 'ReadOnlyMany', 'ReadWriteMany'],
|
|
243
|
+
help='Access mode of created filestore instance',
|
|
244
|
+
default='ReadWriteMany',
|
|
245
|
+
)
|
|
246
|
+
opt_args.add_argument(
|
|
247
|
+
'--manifest',
|
|
248
|
+
type=str,
|
|
249
|
+
help='Path to manifest file containing volume definitions',
|
|
250
|
+
)
|
|
251
|
+
|
|
252
|
+
add_kind_cluster_arguments(opt_args)
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
def add_storage_list_parser(
|
|
256
|
+
storage_subcommands_parser: argparse.ArgumentParser,
|
|
257
|
+
):
|
|
258
|
+
storage_list_parser: argparse.ArgumentParser = (
|
|
259
|
+
storage_subcommands_parser.add_parser('list', help='List XPK Storages.')
|
|
260
|
+
)
|
|
261
|
+
storage_list_parser.set_defaults(func=storage_list)
|
|
262
|
+
add_shared_arguments(storage_list_parser)
|
|
263
|
+
req_args = storage_list_parser.add_argument_group(
|
|
264
|
+
'Required Arguments',
|
|
265
|
+
'Arguments required for storage list.',
|
|
266
|
+
)
|
|
267
|
+
req_args.add_argument(
|
|
268
|
+
'--cluster',
|
|
269
|
+
type=str,
|
|
270
|
+
)
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
def add_storage_detach_parser(
|
|
274
|
+
storage_subcommands_parser: argparse.ArgumentParser,
|
|
275
|
+
):
|
|
276
|
+
storage_detach_parser: argparse.ArgumentParser = (
|
|
277
|
+
storage_subcommands_parser.add_parser(
|
|
278
|
+
'detach', help='Detach XPK Storage.'
|
|
279
|
+
)
|
|
280
|
+
)
|
|
281
|
+
storage_detach_parser.set_defaults(func=storage_detach)
|
|
282
|
+
add_shared_arguments(storage_detach_parser)
|
|
283
|
+
|
|
284
|
+
req_args = storage_detach_parser.add_argument_group(
|
|
285
|
+
'Required Arguments',
|
|
286
|
+
'Arguments required for storage detach.',
|
|
287
|
+
)
|
|
288
|
+
req_args.add_argument('name', type=str)
|
|
289
|
+
add_cluster_arguments(req_args, required=True)
|
|
290
|
+
|
|
291
|
+
opt_args = storage_detach_parser.add_argument_group(
|
|
292
|
+
'Optional Arguments',
|
|
293
|
+
'Optional arguments for storage delete.',
|
|
294
|
+
)
|
|
295
|
+
add_kind_cluster_arguments(opt_args)
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
def add_storage_delete_parser(
|
|
299
|
+
storage_subcommands_parser: argparse.ArgumentParser,
|
|
300
|
+
):
|
|
301
|
+
storage_delete_parser: argparse.ArgumentParser = (
|
|
302
|
+
storage_subcommands_parser.add_parser(
|
|
303
|
+
'delete', help='Delete XPK Storage.'
|
|
304
|
+
)
|
|
305
|
+
)
|
|
306
|
+
storage_delete_parser.set_defaults(func=storage_delete)
|
|
307
|
+
add_shared_arguments(storage_delete_parser)
|
|
308
|
+
|
|
309
|
+
req_args = storage_delete_parser.add_argument_group(
|
|
310
|
+
'Required Arguments',
|
|
311
|
+
'Arguments required for storage delete.',
|
|
312
|
+
)
|
|
313
|
+
req_args.add_argument('name', type=str)
|
|
314
|
+
add_cluster_arguments(req_args, required=True)
|
|
315
|
+
|
|
316
|
+
opt_args = storage_delete_parser.add_argument_group(
|
|
317
|
+
'Optional Arguments',
|
|
318
|
+
'Optional arguments for storage delete.',
|
|
319
|
+
)
|
|
320
|
+
opt_args.add_argument(
|
|
321
|
+
'--force',
|
|
322
|
+
'-f',
|
|
323
|
+
action='store_true',
|
|
324
|
+
help='Force filestore instance deletion even if it has attached storages',
|
|
325
|
+
)
|
|
326
|
+
add_kind_cluster_arguments(opt_args)
|
xpk/parser/validators.py
CHANGED
|
@@ -19,12 +19,12 @@ import os
|
|
|
19
19
|
import re
|
|
20
20
|
|
|
21
21
|
|
|
22
|
-
def
|
|
23
|
-
"""Validate that the
|
|
22
|
+
def name_type(value, pat=re.compile(r'[a-z]([-a-z0-9]*[a-z0-9])?')):
|
|
23
|
+
"""Validate that the name matches the expected pattern."""
|
|
24
24
|
match = pat.fullmatch(value)
|
|
25
25
|
if not match or len(match.group(0)) > 40:
|
|
26
26
|
raise argparse.ArgumentTypeError(
|
|
27
|
-
'
|
|
27
|
+
'Name must be less than 40 characters and match the pattern'
|
|
28
28
|
f' `{pat.pattern}`'
|
|
29
29
|
f' Name is currently {value}'
|
|
30
30
|
)
|