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
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Thomas Leymonerie
slapos.core
Commits
1673c4c2
Commit
1673c4c2
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
e855eec0
Changes
1
Show 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 @
1673c4c2
...
@@ -59,6 +59,8 @@ class RegisterCommand(Command):
...
@@ -59,6 +59,8 @@ class RegisterCommand(Command):
ap
=
super
(
RegisterCommand
,
self
).
get_parser
(
prog_name
)
ap
=
super
(
RegisterCommand
,
self
).
get_parser
(
prog_name
)
ap
.
add_argument
(
'node_name'
,
ap
.
add_argument
(
'node_name'
,
default
=
''
,
nargs
=
'?'
,
help
=
'Chosen title for the node'
)
help
=
'Chosen title for the node'
)
ap
.
add_argument
(
'--interface-name'
,
ap
.
add_argument
(
'--interface-name'
,
...
@@ -148,6 +150,19 @@ def get_certificate_key_pair(logger, master_url_web, node_name, token=None, logi
...
@@ -148,6 +150,19 @@ def get_certificate_key_pair(logger, master_url_web, node_name, token=None, logi
"""Download certificates from SlapOS Master"""
"""Download certificates from SlapOS Master"""
if
token
:
if
token
:
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'
]),
req
=
requests
.
post
(
'/'
.
join
([
master_url_web
,
'Person_requestComputer'
]),
data
=
{
'title'
:
node_name
},
data
=
{
'title'
:
node_name
},
headers
=
{
'X-Access-Token'
:
token
},
headers
=
{
'X-Access-Token'
:
token
},
...
@@ -334,7 +349,7 @@ def gen_auth(conf):
...
@@ -334,7 +349,7 @@ def gen_auth(conf):
def
do_register
(
conf
):
def
do_register
(
conf
):
"""Register new computer on SlapOS Master and generate slapos.cfg"""
"""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
):
for
login
,
password
in
gen_auth
(
conf
):
if
check_credentials
(
conf
.
master_url_web
,
login
,
password
):
if
check_credentials
(
conf
.
master_url_web
,
login
,
password
):
break
break
...
@@ -350,7 +365,9 @@ def do_register(conf):
...
@@ -350,7 +365,9 @@ def do_register(conf):
else
:
else
:
while
not
conf
.
token
:
while
not
conf
.
token
:
conf
.
token
=
input
(
'Computer security token: '
).
strip
()
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
,
certificate
,
key
=
get_certificate_key_pair
(
conf
.
logger
,
conf
.
master_url_web
,
conf
.
master_url_web
,
conf
.
node_name
,
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