Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
18
Merge Requests
18
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
slapos.core
Commits
e42bce91
Commit
e42bce91
authored
Mar 07, 2022
by
Cédric Le Ninivin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cli: register updated to work with json-api
parent
13bacd18
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
6 deletions
+23
-6
slapos/cli/register.py
slapos/cli/register.py
+23
-6
No files found.
slapos/cli/register.py
View file @
e42bce91
...
...
@@ -59,6 +59,8 @@ class RegisterCommand(Command):
ap
=
super
(
RegisterCommand
,
self
).
get_parser
(
prog_name
)
ap
.
add_argument
(
'node_name'
,
default
=
''
,
nargs
=
'?'
,
help
=
'Chosen title for the node'
)
ap
.
add_argument
(
'--interface-name'
,
...
...
@@ -148,10 +150,23 @@ def get_certificate_key_pair(logger, master_url_web, node_name, token=None, logi
"""Download certificates from SlapOS Master"""
if
token
:
req
=
requests
.
post
(
'/'
.
join
([
master_url_web
,
'Person_requestComputer'
]),
data
=
{
'title'
:
node_name
},
headers
=
{
'X-Access-Token'
:
token
},
verify
=
False
)
if
token
.
startswith
(
"V2/"
):
_
,
compute_node_id
,
token
=
token
.
split
(
"/"
)
data
=
{}
if
node_name
:
data
=
{
'title'
:
node_name
}
req
=
requests
.
post
(
'/'
.
join
([
master_url_web
.
strip
(
"/"
),
'compute_node_module/%s/ComputeNode_approveComputer'
%
compute_node_id
]),
data
=
data
,
headers
=
{
'X-Access-Token'
:
token
},
verify
=
False
)
else
:
req
=
requests
.
post
(
'/'
.
join
([
master_url_web
,
'Person_requestComputer'
]),
data
=
{
'title'
:
node_name
},
headers
=
{
'X-Access-Token'
:
token
},
verify
=
False
)
else
:
register_server_url
=
'/'
.
join
([
master_url_web
,
(
"Person_requestComputer?title={}"
.
format
(
node_name
))])
req
=
requests
.
get
(
register_server_url
,
auth
=
(
login
,
password
),
verify
=
False
)
...
...
@@ -334,7 +349,7 @@ def gen_auth(conf):
def
do_register
(
conf
):
"""Register new computer on SlapOS Master and generate slapos.cfg"""
if
conf
.
login
or
conf
.
login_auth
:
if
conf
.
login
or
conf
.
login_auth
and
conf
.
node_name
:
for
login
,
password
in
gen_auth
(
conf
):
if
check_credentials
(
conf
.
master_url_web
,
login
,
password
):
break
...
...
@@ -350,7 +365,9 @@ def do_register(conf):
else
:
while
not
conf
.
token
:
conf
.
token
=
input
(
'Computer security token: '
).
strip
()
if
not
conf
.
token
.
startswith
(
"V2/"
)
and
not
conf
.
node_name
:
while
not
conf
.
node_name
:
conf
.
node_name
=
input
(
'Computer Name: '
).
strip
()
certificate
,
key
=
get_certificate_key_pair
(
conf
.
logger
,
conf
.
master_url_web
,
conf
.
node_name
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment