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
Gabriel Monnerat
slapos.core
Commits
d61fb1cc
Commit
d61fb1cc
authored
Jun 23, 2011
by
Cédric de Saint Martin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add slapos-request entry point, implement it
parent
77d89dbb
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
14 deletions
+47
-14
setup.py
setup.py
+1
-0
slapos/console.py
slapos/console.py
+46
-14
No files found.
setup.py
View file @
d61fb1cc
...
...
@@ -46,6 +46,7 @@ setup(name=name,
entry_points
=
{
'console_scripts'
:
[
'slapconsole = slapos.console:run'
,
'slapos-request = slapos.console:request'
,
'slapformat = slapos.format:main'
,
'slapgrid = slapos.grid.slapgrid:run'
,
'slapgrid-sr = slapos.grid.slapgrid:runSoftwareRelease'
,
...
...
slapos/console.py
View file @
d61fb1cc
...
...
@@ -58,10 +58,10 @@ class Parser(OptionParser):
Check arguments
"""
(
options
,
args
)
=
self
.
parse_args
()
if
len
(
args
)
!=
1
:
self
.
error
(
"Incorrect number of arguments"
)
#
if len(args) != 1:
#
self.error("Incorrect number of arguments")
return
options
,
args
[
0
]
return
options
,
args
class
Config
:
def
setConfig
(
self
,
option_dict
,
configuration_file_path
):
...
...
@@ -85,25 +85,57 @@ class Config:
setattr
(
self
,
'master_url'
,
configuration_dict
[
'master_url'
])
if
not
self
.
master_url
:
raise
ValueError
(
'master-url is required.'
)
def
run
():
usage
=
"usage: %s [options] CONFIGURATION_FILE"
%
sys
.
argv
[
0
]
# Parse arguments
config
=
Config
()
config
.
setConfig
(
*
Parser
(
usage
=
usage
).
check_args
())
raise
ValueError
(
'master_url is required.'
)
def
init
(
config
):
"""Initialize Slap instance, connects to server and create
aliases to common software releases"""
slap
=
slapos
.
slap
.
slap
()
slap
.
initializeConnection
(
'https://slap.vifib.com'
,
slap
.
initializeConnection
(
config
.
master_url
,
key_file
=
config
.
key_file
,
cert_file
=
config
.
cert_file
)
local
=
globals
()
local
=
globals
()
.
copy
()
local
[
'slap'
]
=
slap
alias
=
config
.
alias
.
split
(
'
\
n
'
)
software_list
=
[]
for
software
in
alias
:
if
software
is
not
''
:
name
,
url
=
software
.
split
(
' '
)
software_list
.
append
(
name
)
local
[
name
]
=
url
local
[
'software_list'
]
=
software_list
# XXX-Cedric Maybe we should generate a new OpenOrder for each request?
local
[
'request'
]
=
slap
.
registerOpenOrder
().
request
return
local
def
request
():
"""Ran when invoking slapos-request"""
# Parse arguments
usage
=
"usage: %s [options] CONFIGURATION_FILE"
%
sys
.
argv
[
0
]
config
=
Config
()
arguments
=
Parser
(
usage
=
usage
).
check_args
()[
1
]
config
.
setConfig
(
*
Parser
(
usage
=
usage
).
check_args
())
local
=
init
(
config
)
# Request instance
# XXX-Cedric : support things like :
# --instance-type std --configuration-size 23 --computer-region europe/france
# XXX-Cedric : add support for xml_parameter
software_url
=
arguments
[
1
]
partition_reference
=
arguments
[
2
]
print
(
"Requesting %s..."
%
software_url
)
if
software_url
in
local
:
software_url
=
local
[
software_url
]
local
[
'slap'
].
registerOpenOrder
().
request
(
software_url
,
partition_reference
)
print
(
"done."
)
def
run
():
"""Ran when invoking slapconsole"""
# Parse arguments
usage
=
"usage: %s [options] CONFIGURATION_FILE"
%
sys
.
argv
[
0
]
config
=
Config
()
config
.
setConfig
(
*
Parser
(
usage
=
usage
).
check_args
())
__import__
(
"code"
).
interact
(
banner
=
""
,
local
=
globals
())
local
=
init
(
config
)
__import__
(
"code"
).
interact
(
banner
=
""
,
local
=
local
)
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