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
f1a4fd39
Commit
f1a4fd39
authored
Jun 18, 2013
by
Marco Mariani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slightly clearer function names
parent
67b2d483
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
12 deletions
+24
-12
slapos/register/register.py
slapos/register/register.py
+24
-12
No files found.
slapos/register/register.py
View file @
f1a4fd39
...
@@ -49,7 +49,7 @@ def check_credentials(url, login, password):
...
@@ -49,7 +49,7 @@ def check_credentials(url, login, password):
return
'Logout'
in
req
.
text
return
'Logout'
in
req
.
text
def
get_certificate
s
(
logger
,
master_url_web
,
node_name
,
token
=
None
,
login
=
None
,
password
=
None
):
def
get_certificate
_key_pair
(
logger
,
master_url_web
,
node_name
,
token
=
None
,
login
=
None
,
password
=
None
):
"""Download certificates from SlapOS Master"""
"""Download certificates from SlapOS Master"""
if
token
:
if
token
:
...
@@ -78,16 +78,20 @@ def get_certificates(logger, master_url_web, node_name, token=None, login=None,
...
@@ -78,16 +78,20 @@ def get_certificates(logger, master_url_web, node_name, token=None, login=None,
else
:
else
:
req
.
raise_for_status
()
req
.
raise_for_status
()
return
req
.
text
return
parse_certificate_key_pair
(
req
.
text
)
def
parse_certificate
s
(
source
):
def
parse_certificate
_key_pair
(
html
):
"""Parse html gotten from SlapOS Master to make certificate and key files"""
"""Parse html gotten from SlapOS Master to make certificate and key files"""
c_start
=
source
.
find
(
"Certificate:"
)
c_start
=
html
.
find
(
"Certificate:"
)
c_end
=
source
.
find
(
"</textarea>"
,
c_start
)
c_end
=
html
.
find
(
"</textarea>"
,
c_start
)
k_start
=
source
.
find
(
"-----BEGIN PRIVATE KEY-----"
)
certificate
=
html
[
c_start
:
c_end
]
k_end
=
source
.
find
(
"</textarea>"
,
k_start
)
return
source
[
c_start
:
c_end
],
source
[
k_start
:
k_end
]
k_start
=
html
.
find
(
"-----BEGIN PRIVATE KEY-----"
)
k_end
=
html
.
find
(
"</textarea>"
,
k_start
)
key
=
html
[
k_start
:
k_end
]
return
certificate
,
key
def
get_computer_name
(
certificate
):
def
get_computer_name
(
certificate
):
...
@@ -262,7 +266,10 @@ def do_register(conf):
...
@@ -262,7 +266,10 @@ def do_register(conf):
break
break
if
conf
.
token
:
if
conf
.
token
:
certificate_key
=
get_certificates
(
conf
.
logger
,
conf
.
master_url_web
,
conf
.
node_name
,
token
=
conf
.
token
)
certificate
,
key
=
get_certificate_key_pair
(
conf
.
logger
,
conf
.
master_url_web
,
conf
.
node_name
,
token
=
conf
.
token
)
else
:
else
:
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
):
...
@@ -271,16 +278,21 @@ def do_register(conf):
...
@@ -271,16 +278,21 @@ def do_register(conf):
else
:
else
:
return
1
return
1
certificate_key
=
get_certificates
(
conf
.
logger
,
conf
.
master_url_web
,
conf
.
node_name
,
login
=
login
,
password
=
password
)
certificate
,
key
=
get_certificate_key_pair
(
conf
.
logger
,
conf
.
master_url_web
,
conf
.
node_name
,
login
=
login
,
password
=
password
)
# Parse certificate and key and get computer id
# get computer id
certificate
,
key
=
parse_certificates
(
certificate_key
)
COMP
=
get_computer_name
(
certificate
)
COMP
=
get_computer_name
(
certificate
)
# Getting configuration parameters
# Getting configuration parameters
conf
.
COMPConfig
(
slapos_configuration
=
'/etc/opt/slapos/'
,
conf
.
COMPConfig
(
slapos_configuration
=
'/etc/opt/slapos/'
,
computer_id
=
COMP
,
computer_id
=
COMP
,
certificate
=
certificate
,
certificate
=
certificate
,
key
=
key
)
key
=
key
)
# Save former configuration
# Save former configuration
if
not
conf
.
dry_run
:
if
not
conf
.
dry_run
:
save_former_config
(
conf
)
save_former_config
(
conf
)
...
...
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