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
Nicolas Wavrant
slapos.core
Commits
a99e2e16
Commit
a99e2e16
authored
Jun 25, 2013
by
Marco Mariani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
moved supply, request, remove under cli/
parent
46bf6586
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
71 additions
and
65 deletions
+71
-65
slapos/cache.py
slapos/cache.py
+1
-1
slapos/cli/cache.py
slapos/cli/cache.py
+1
-1
slapos/cli/remove.py
slapos/cli/remove.py
+19
-2
slapos/cli/request.py
slapos/cli/request.py
+28
-2
slapos/cli/supply.py
slapos/cli/supply.py
+21
-2
slapos/client.py
slapos/client.py
+1
-57
No files found.
slapos/cache.py
View file @
a99e2e16
...
@@ -20,7 +20,7 @@ def looks_like_md5(s):
...
@@ -20,7 +20,7 @@ def looks_like_md5(s):
return
re
.
match
(
'[0-9a-f]{32}'
,
s
)
return
re
.
match
(
'[0-9a-f]{32}'
,
s
)
def
do_lookup
(
configp
,
software_url
,
logger
):
def
do_lookup
(
logger
,
configp
,
software_url
):
cache_dir
=
configp
.
get
(
'networkcache'
,
'download-binary-dir-url'
)
cache_dir
=
configp
.
get
(
'networkcache'
,
'download-binary-dir-url'
)
if
looks_like_md5
(
software_url
):
if
looks_like_md5
(
software_url
):
...
...
slapos/cli/cache.py
View file @
a99e2e16
...
@@ -27,4 +27,4 @@ class CacheLookupCommand(ConfigCommand):
...
@@ -27,4 +27,4 @@ class CacheLookupCommand(ConfigCommand):
def
take_action
(
self
,
args
):
def
take_action
(
self
,
args
):
configp
=
self
.
fetch_config
(
args
)
configp
=
self
.
fetch_config
(
args
)
do_lookup
(
configp
,
args
.
software_url
,
logger
=
self
.
app
.
log
)
do_lookup
(
self
.
app
.
log
,
configp
,
args
.
software_url
)
slapos/cli/remove.py
View file @
a99e2e16
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
import
logging
import
logging
from
slapos.cli.config
import
ClientConfigCommand
from
slapos.cli.config
import
ClientConfigCommand
from
slapos.client
import
init
,
do_remove
,
ClientConfig
from
slapos.client
import
init
,
ClientConfig
class
RemoveCommand
(
ClientConfigCommand
):
class
RemoveCommand
(
ClientConfigCommand
):
...
@@ -28,4 +28,21 @@ class RemoveCommand(ClientConfigCommand):
...
@@ -28,4 +28,21 @@ class RemoveCommand(ClientConfigCommand):
configp
=
self
.
fetch_config
(
args
)
configp
=
self
.
fetch_config
(
args
)
conf
=
ClientConfig
(
args
,
configp
)
conf
=
ClientConfig
(
args
,
configp
)
local
=
init
(
conf
)
local
=
init
(
conf
)
do_remove
(
args
.
software_url
,
args
.
node
,
local
)
do_remove
(
self
.
app
.
log
,
args
.
software_url
,
args
.
node
,
local
)
def
do_remove
(
logger
,
software_url
,
computer_id
,
local
):
"""
Request deletion of Software Release
'software_url' from computer 'computer_id'.
"""
logger
.
info
(
'Requesting deletion of %s Software Release...'
,
software_url
)
if
software_url
in
local
:
software_url
=
local
[
software_url
]
local
[
'slap'
].
registerSupply
().
supply
(
software_release
=
software_url
,
computer_guid
=
computer_id
,
state
=
'destroyed'
)
logger
.
info
(
'Done.'
)
slapos/cli/request.py
View file @
a99e2e16
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
import
logging
import
logging
import
pprint
from
slapos.cli.config
import
ClientConfigCommand
from
slapos.cli.config
import
ClientConfigCommand
from
slapos.client
import
init
,
do_request
,
ClientConfig
from
slapos.client
import
init
,
ClientConfig
from
slapos.slap
import
ResourceNotReady
def
parse_option_dict
(
options
):
def
parse_option_dict
(
options
):
...
@@ -65,4 +67,28 @@ class RequestCommand(ClientConfigCommand):
...
@@ -65,4 +67,28 @@ class RequestCommand(ClientConfigCommand):
conf
=
ClientConfig
(
args
,
configp
)
conf
=
ClientConfig
(
args
,
configp
)
local
=
init
(
conf
)
local
=
init
(
conf
)
do_request
(
conf
,
local
)
do_request
(
self
.
app
.
log
,
conf
,
local
)
def
do_request
(
logger
,
conf
,
local
):
logger
.
info
(
'Requesting %s...'
,
conf
.
reference
)
if
conf
.
software_url
in
local
:
conf
.
software_url
=
local
[
conf
.
software_url
]
try
:
partition
=
local
[
'slap'
].
registerOpenOrder
().
request
(
software_release
=
conf
.
software_url
,
partition_reference
=
conf
.
reference
,
partition_parameter_kw
=
conf
.
parameters
,
software_type
=
conf
.
type
,
filter_kw
=
conf
.
node
,
state
=
conf
.
state
,
shared
=
conf
.
slave
)
logger
.
info
(
'Instance requested.
\
n
State is : %s.'
,
partition
.
getState
())
logger
.
info
(
'Connection parameters of instance are:'
)
logger
.
info
(
pprint
.
pformat
(
partition
.
getConnectionParameterDict
()))
logger
.
info
(
'You can rerun command to get up-to-date informations.'
)
except
ResourceNotReady
:
logger
.
warning
(
'Instance requested. Master is provisioning it. Please rerun in a '
'couple of minutes to get connection informations.'
)
exit
(
2
)
slapos/cli/supply.py
View file @
a99e2e16
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
import
logging
import
logging
from
slapos.cli.config
import
ClientConfigCommand
from
slapos.cli.config
import
ClientConfigCommand
from
slapos.client
import
init
,
do_supply
,
ClientConfig
from
slapos.client
import
init
,
ClientConfig
class
SupplyCommand
(
ClientConfigCommand
):
class
SupplyCommand
(
ClientConfigCommand
):
...
@@ -28,4 +28,23 @@ class SupplyCommand(ClientConfigCommand):
...
@@ -28,4 +28,23 @@ class SupplyCommand(ClientConfigCommand):
configp
=
self
.
fetch_config
(
args
)
configp
=
self
.
fetch_config
(
args
)
conf
=
ClientConfig
(
args
,
configp
)
conf
=
ClientConfig
(
args
,
configp
)
local
=
init
(
conf
)
local
=
init
(
conf
)
do_supply
(
args
.
software_url
,
args
.
node
,
local
)
do_supply
(
self
.
app
.
log
,
args
.
software_url
,
args
.
node
,
local
)
def
do_supply
(
logger
,
software_url
,
computer_id
,
local
):
"""
Request installation of Software Release
'software_url' on computer 'computer_id'.
"""
# XXX-Cedric Implement software_group support
# XXX-Cedric Implement computer_group support
logger
.
info
(
'Requesting installation of %s Software Release...'
,
software_url
)
if
software_url
in
local
:
software_url
=
local
[
software_url
]
local
[
'slap'
].
registerSupply
().
supply
(
software_release
=
software_url
,
computer_guid
=
computer_id
,
state
=
'available'
)
logger
.
info
(
'Done.'
)
slapos/client.py
View file @
a99e2e16
...
@@ -30,10 +30,8 @@
...
@@ -30,10 +30,8 @@
import
atexit
import
atexit
import
ConfigParser
import
ConfigParser
import
os
import
os
import
pprint
import
slapos.slap.slap
import
slapos.slap.slap
from
slapos.slap
import
ResourceNotReady
class
ClientConfig
(
object
):
class
ClientConfig
(
object
):
...
@@ -72,7 +70,7 @@ class ClientConfig(object):
...
@@ -72,7 +70,7 @@ class ClientConfig(object):
self
.
cert_file
is
None
:
self
.
cert_file
is
None
:
raise
ValueError
(
"No option 'key_file' and/or 'cert_file'"
)
raise
ValueError
(
"No option 'key_file' and/or 'cert_file'"
)
else
:
else
:
se
tattr
(
self
,
'master_url'
,
master_url
)
se
lf
.
master_url
=
master_url
if
self
.
key_file
:
if
self
.
key_file
:
self
.
key_file
=
os
.
path
.
expanduser
(
self
.
key_file
)
self
.
key_file
=
os
.
path
.
expanduser
(
self
.
key_file
)
...
@@ -117,60 +115,6 @@ def init(conf):
...
@@ -117,60 +115,6 @@ def init(conf):
return
local
return
local
def
do_request
(
conf
,
local
):
print
(
"Requesting %s..."
%
conf
.
reference
)
if
conf
.
software_url
in
local
:
conf
.
software_url
=
local
[
conf
.
software_url
]
try
:
partition
=
local
[
'slap'
].
registerOpenOrder
().
request
(
software_release
=
conf
.
software_url
,
partition_reference
=
conf
.
reference
,
partition_parameter_kw
=
conf
.
parameters
,
software_type
=
conf
.
type
,
filter_kw
=
conf
.
node
,
state
=
conf
.
state
,
shared
=
conf
.
slave
)
print
"Instance requested.
\
n
State is : %s."
%
partition
.
getState
()
print
"Connection parameters of instance are:"
pprint
.
pprint
(
partition
.
getConnectionParameterDict
())
print
"You can rerun command to get up-to-date informations."
except
ResourceNotReady
:
print
(
"Instance requested. Master is provisioning it. Please rerun in a "
"couple of minutes to get connection informations."
)
exit
(
2
)
def
do_supply
(
software_url
,
computer_id
,
local
,
remove
=
False
):
"""
Request installation of Software Release
'software_url' on computer 'computer_id'.
if destroy argument is True, request deletion of Software Release.
"""
# XXX-Cedric Implement software_group support
# XXX-Cedric Implement computer_group support
if
not
remove
:
state
=
'available'
print
'Requesting installation of %s Software Release...'
%
software_url
else
:
state
=
'destroyed'
print
'Requesting deletion of %s Software Release...'
%
software_url
if
software_url
in
local
:
software_url
=
local
[
software_url
]
local
[
'slap'
].
registerSupply
().
supply
(
software_release
=
software_url
,
computer_guid
=
computer_id
,
state
=
state
,
)
print
'Done.'
def
do_remove
(
software_url
,
node
,
local
):
do_supply
(
software_url
,
node
,
local
,
remove
=
True
)
def
do_console
(
local
):
def
do_console
(
local
):
# try to enable readline with completion and history
# try to enable readline with completion and history
try
:
try
:
...
...
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