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
Guillaume Hervier
slapos.core
Commits
db7982db
Commit
db7982db
authored
Nov 02, 2012
by
Cédric de Saint Martin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Unify client code
- No need for nargs - No need for separate Config.setConfig command
parent
0a321884
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
35 deletions
+15
-35
slapos/client.py
slapos/client.py
+15
-35
No files found.
slapos/client.py
View file @
db7982db
...
...
@@ -85,7 +85,6 @@ def check_request_args():
"""
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
"configuration_file"
,
nargs
=
1
,
help
=
"SlapOS configuration file."
)
parser
.
add_argument
(
"reference"
,
help
=
"Your instance reference"
)
...
...
@@ -115,7 +114,7 @@ def check_request_args():
class
Config
:
def
setConfig
(
self
,
option_dict
,
configuration_file_path
=
None
):
def
__init__
(
self
,
option_dict
,
configuration_file_path
=
None
):
"""
Set options given by parameters.
"""
...
...
@@ -189,15 +188,11 @@ def init(config):
return
local
def
request
():
"""R
a
n when invoking slapos request. Request an instance."""
"""R
u
n when invoking slapos request. Request an instance."""
# Parse arguments and inititate needed parameters
# XXX-Cedric: usage is different from what is specified in slapos doc.
usage
=
"""usage: %s [options] CONFIGURATION_FILE INSTANCE_REFERENCE SOFTWARE_INSTANCE
slapos-request allows you to request slapos instances."""
%
sys
.
argv
[
0
]
config
=
Config
()
# XXX-Cedric: move argument parsing to main entry point
options
=
check_request_args
()
config
.
set
Config
(
options
,
options
.
configuration_file
)
config
=
Config
(
options
,
options
.
configuration_file
)
local
=
init
(
config
)
# Request instance
print
(
"Requesting %s..."
%
config
.
reference
)
...
...
@@ -239,60 +234,46 @@ def _supply(software_url, computer_id, local, remove=False):
if
software_url
in
local
:
software_url
=
local
[
software_url
]
local
[
'slap'
].
slap
.
registerSupply
().
supply
(
software_release
=
software_url
,
computer_guid
=
computer_id
,
local
[
'slap'
].
registerSupply
().
supply
(
software_release
=
software_url
,
computer_guid
=
computer_id
,
state
=
state
,
)
print
'Done.'
def
supply
():
"""
R
an when invoking slapos supply
.
R
un when invoking slapos supply. Mostly argument parsing
.
"""
# XXX-Cedric: move argument parsing to main entry point
config
=
Config
()
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
"configuration_file"
,
nargs
=
1
,
help
=
"SlapOS configuration file"
)
parser
.
add_argument
(
"software_url"
,
help
=
"Your software url"
)
parser
.
add_argument
(
"node"
,
help
=
"Target node"
)
help
=
"Target node"
)
args
=
parser
.
parse_args
()
# Convert to dict
if
args
.
configuration
is
not
None
:
args
.
configuration
=
argToDict
(
args
.
configuration
)
if
args
.
node
is
not
None
:
args
.
node
=
argToDict
(
args
.
node
)
config
.
set
Config
(
args
,
args
.
configuration_file
)
_supply
(
args
.
software_url
,
args
.
node
,
init
(
args
))
config
=
Config
(
args
,
args
.
configuration_file
)
_supply
(
args
.
software_url
,
args
.
node
,
init
(
config
))
def
remove
():
"""
R
an when invoking slapos remove
.
R
un when invoking slapos remove. Mostly argument parsing
.
"""
# XXX-Cedric: move argument parsing to main entry point
config
=
Config
()
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
"configuration_file"
,
nargs
=
1
,
help
=
"SlapOS configuration file."
)
parser
.
add_argument
(
"software_url"
,
help
=
"Your software url"
)
parser
.
add_argument
(
"node"
,
help
=
"Target node"
)
help
=
"Target node"
)
args
=
parser
.
parse_args
()
# Convert to dict
if
args
.
configuration
is
not
None
:
args
.
configuration
=
argToDict
(
args
.
configuration
)
if
args
.
node
is
not
None
:
args
.
node
=
argToDict
(
args
.
node
)
config
.
set
Config
(
args
,
args
.
configuration_file
)
_supply
(
args
.
software_url
,
args
.
node
,
init
(
args
),
remove
=
True
)
config
=
Config
(
args
,
args
.
configuration_file
)
_supply
(
args
.
software_url
,
args
.
node
,
init
(
config
),
remove
=
True
)
def
slapconsole
():
...
...
@@ -309,8 +290,7 @@ examples :
>>> supply(kvm, "mycomputer")
>>> # Fetch instance informations on already launched instance
>>> request(kvm, "myuniquekvm").getConnectionParameter("url")"""
%
sys
.
argv
[
0
]
config
=
Config
()
config
.
setConfig
(
*
Parser
(
usage
=
usage
).
check_args
())
config
=
Config
(
*
Parser
(
usage
=
usage
).
check_args
())
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