FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
ceph-devstack/ceph_devstack/__init__.py at main · kamoltat/ceph-devstack · GitHub
kamoltat
ceph-devstack
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
ceph-devstack
/
ceph_devstack
/
__init__.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
140 lines (122 loc) · 3.97 KB
Breadcrumbs
ceph-devstack
/
ceph_devstack
/
__init__.py
Copy path
File metadata and controls
140 lines (122 loc) · 3.97 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
import
argparse
import
logging
.
config
import
yaml
from
pathlib
import
Path
,
PosixPath
from
typing
import
List
,
Optional
VERBOSE
=
15
logging
.
addLevelName
(
15
,
"VERBOSE"
)
logging
.
config
.
fileConfig
(
Path
(
__file__
).
parent
/
"logging.conf"
)
logger
=
logging
.
getLogger
(
"ceph-devstack"
)
PROJECT_ROOT
=
Path
(
__file__
).
parent
DEFAULT_CONFIG_PATH
=
Path
(
"~/.config/ceph-devstack/config.yml"
)
def
represent_path
(
dumper
:
yaml
.
dumper
.
SafeDumper
,
data
:
PosixPath
)
->
yaml
.
Node
:
return
dumper
.
represent_scalar
(
"tag:yaml.org,2002:str"
,
str
(
data
))
yaml
.
SafeDumper
.
add_representer
(
PosixPath
,
represent_path
,
)
def
parse_args
(
args
:
List
[
str
])
->
argparse
.
Namespace
:
parser
=
argparse
.
ArgumentParser
(
formatter_class
=
argparse
.
ArgumentDefaultsHelpFormatter
)
parser
.
add_argument
(
"--dry-run"
,
action
=
"store_true"
,
default
=
False
,
help
=
"Instead of running commands, print them"
,
)
parser
.
add_argument
(
"-v"
,
"--verbose"
,
action
=
"store_true"
,
default
=
False
,
help
=
"Be more verbose"
,
)
parser
.
add_argument
(
"-c"
,
"--config-file"
,
type
=
Path
,
default
=
DEFAULT_CONFIG_PATH
,
help
=
"Path to the ceph-devstack config file"
,
)
subparsers
=
parser
.
add_subparsers
(
dest
=
"command"
)
parser_doc
=
subparsers
.
add_parser
(
"doctor"
,
help
=
"Check that the system meets requirements"
)
parser_doc
.
add_argument
(
"--fix"
,
action
=
"store_true"
,
default
=
False
,
help
=
"Apply suggested fixes for issues found"
,
)
parser_pull
=
subparsers
.
add_parser
(
"pull"
,
help
=
"Pull container images"
)
parser_pull
.
add_argument
(
"image"
,
nargs
=
"*"
,
help
=
"Specific image(s) to pull"
,
)
parser_build
=
subparsers
.
add_parser
(
"build"
,
help
=
"Build container images"
)
parser_build
.
add_argument
(
"image"
,
nargs
=
"*"
,
help
=
"Specific image(s) to build"
,
)
parser_create
=
subparsers
.
add_parser
(
"create"
,
help
=
"Create the cluster"
,
formatter_class
=
argparse
.
ArgumentDefaultsHelpFormatter
,
)
parser_create
.
add_argument
(
"-b"
,
"--build"
,
action
=
"store_true"
,
default
=
False
,
help
=
"Build images before creating"
,
)
parser_create
.
add_argument
(
"-w"
,
"--wait"
,
action
=
"store_true"
,
default
=
False
,
help
=
"Leave the cluster running - and don't auto-schedule anything"
,
)
subparsers
.
add_parser
(
"remove"
,
help
=
"Destroy the cluster"
)
subparsers
.
add_parser
(
"start"
,
help
=
"Start the cluster"
)
subparsers
.
add_parser
(
"stop"
,
help
=
"Stop the cluster"
)
subparsers
.
add_parser
(
"watch"
,
help
=
"Monitor the cluster, recreating containers as necessary"
)
parser_wait
=
subparsers
.
add_parser
(
"wait"
,
help
=
"Wait for the specified container to exit. Exit with its exit code."
,
)
parser_wait
.
add_argument
(
"container"
,
help
=
"The container to wait for"
,
)
subparsers
.
add_parser
(
"show-conf"
,
help
=
"show the configuration"
)
return
parser
.
parse_args
(
args
)
def
deep_merge
(
*
maps
):
result
=
{}
for
map
in
maps
:
for
k
,
v
in
map
.
items
():
if
isinstance
(
v
,
dict
):
v
=
deep_merge
(
result
.
get
(
k
, {}),
v
)
result
[
k
]
=
v
return
result
class
Config
(
dict
):
def
load
(
self
,
config_path
:
Optional
[
Path
]
=
None
):
self
.
update
(
yaml
.
safe_load
((
Path
(
__file__
).
parent
/
"config.yml"
).
read_text
()))
if
config_path
:
user_path
=
config_path
.
expanduser
()
if
user_path
.
exists
():
user_obj
=
yaml
.
safe_load
(
user_path
.
read_text
())
or
{}
self
.
update
(
deep_merge
(
config
,
user_obj
))
elif
user_path
!=
DEFAULT_CONFIG_PATH
.
expanduser
():
raise
OSError
(
f"Config file at
{
user_path
}
not found!"
)
yaml
.
SafeDumper
.
add_representer
(
Config
,
yaml
.
representer
.
SafeRepresenter
.
represent_dict
,
)
config
=
Config
()
config
.
load
()
Back
|
FazBrowse Home
|
New Git URL