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
Roque
slapos.core
Commits
356aa6ba
Commit
356aa6ba
authored
Apr 23, 2013
by
Marco Mariani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
completed console argument parsing
parent
1c5fcb24
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
39 deletions
+40
-39
slapos/cli/console.py
slapos/cli/console.py
+14
-1
slapos/client.py
slapos/client.py
+26
-38
No files found.
slapos/cli/console.py
View file @
356aa6ba
...
@@ -23,9 +23,22 @@ class ConsoleCommand(ClientConfigCommand):
...
@@ -23,9 +23,22 @@ class ConsoleCommand(ClientConfigCommand):
log
=
logging
.
getLogger
(
__name__
)
log
=
logging
.
getLogger
(
__name__
)
def
get_parser
(
self
,
prog_name
):
ap
=
super
(
ConsoleCommand
,
self
).
get_parser
(
prog_name
)
ap
.
add_argument
(
'-u'
,
'--master_url'
,
help
=
'Url of SlapOS Master to use'
)
ap
.
add_argument
(
'-k'
,
'--key_file'
,
help
=
'SSL Authorisation key file'
)
ap
.
add_argument
(
'-c'
,
'--cert_file'
,
help
=
'SSL Authorisation certificate file'
)
return
ap
def
take_action
(
self
,
args
):
def
take_action
(
self
,
args
):
configuration_parser
=
self
.
fetch_config
(
args
)
configuration_parser
=
self
.
fetch_config
(
args
)
config
=
ClientConfig
(
args
,
configuration_parser
)
config
=
ClientConfig
(
args
,
configuration_parser
)
local
=
init
(
config
)
local
=
init
(
config
)
do_console
(
local
)
do_console
(
local
)
slapos/client.py
View file @
356aa6ba
...
@@ -30,48 +30,12 @@
...
@@ -30,48 +30,12 @@
import
argparse
import
argparse
import
ConfigParser
import
ConfigParser
import
pprint
import
pprint
from
optparse
import
OptionParser
,
Option
import
os
import
os
from
slapos.slap
import
ResourceNotReady
from
slapos.slap
import
ResourceNotReady
import
slapos.slap.slap
import
slapos.slap.slap
import
sys
import
sys
import
atexit
import
atexit
class
Parser
(
OptionParser
):
"""
Parse all arguments.
"""
def
__init__
(
self
,
usage
=
None
,
version
=
None
):
"""
Initialize all options possibles.
"""
OptionParser
.
__init__
(
self
,
usage
=
usage
,
version
=
version
,
option_list
=
[
Option
(
"-u"
,
"--master_url"
,
default
=
None
,
action
=
"store"
,
help
=
"Url of SlapOS Master to use."
),
Option
(
"-k"
,
"--key_file"
,
action
=
"store"
,
help
=
"SSL Authorisation key file."
),
Option
(
"-c"
,
"--cert_file"
,
action
=
"store"
,
help
=
"SSL Authorisation certificate file."
)
])
def
check_args
(
self
):
"""
Check arguments
"""
(
options
,
args
)
=
self
.
parse_args
()
if
len
(
args
)
==
0
:
self
.
error
(
"Incorrect number of arguments"
)
elif
not
os
.
path
.
isfile
(
args
[
0
]):
self
.
error
(
"%s: Not found or not a regular file."
%
args
[
0
])
# Return options and only first element of args since there is only one.
return
options
,
args
[
0
]
def
argToDict
(
element
):
def
argToDict
(
element
):
"""
"""
...
@@ -323,8 +287,32 @@ examples :
...
@@ -323,8 +287,32 @@ examples :
>>> supply(kvm, "mycomputer")
>>> supply(kvm, "mycomputer")
>>> # Fetch instance informations on already launched instance
>>> # Fetch instance informations on already launched instance
>>> request(kvm, "myuniquekvm").getConnectionParameter("url")"""
%
sys
.
argv
[
0
]
>>> request(kvm, "myuniquekvm").getConnectionParameter("url")"""
%
sys
.
argv
[
0
]
options
,
configuration_file_path
=
Parser
(
usage
=
usage
).
check_args
()
config
=
ClientConfig
(
options
,
get_config_parser
(
configuration_file_path
))
ap
=
argparse
.
ArgumentParser
(
usage
=
usage
)
ap
.
add_argument
(
'-u'
,
'--master_url'
,
default
=
None
,
action
=
"store"
,
help
=
'Url of SlapOS Master to use.'
)
ap
.
add_argument
(
'-k'
,
'--key_file'
,
action
=
"store"
,
help
=
"SSL Authorisation key file."
)
ap
.
add_argument
(
'-c'
,
'--cert_file'
,
action
=
"store"
,
help
=
"SSL Authorisation certificate file."
)
ap
.
add_argument
(
'configuration_file'
,
help
=
'path to slapos.cfg'
)
options
=
ap
.
parse_args
()
if
not
os
.
path
.
isfile
(
options
.
configuration_file
):
ap
.
error
(
"%s: Not found or not a regular file."
%
options
.
configuration_file
)
config
=
ClientConfig
(
options
,
get_config_parser
(
options
.
configuration_file
))
local
=
init
(
config
)
local
=
init
(
config
)
do_console
(
local
)
do_console
(
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