Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cc-cli
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mirror
cc-cli
Commits
4b192844
Commit
4b192844
authored
14 years ago
by
Seblu
Browse files
Options
Downloads
Patches
Plain Diff
improve vm commands
parent
2d9d4da8
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cccli/command/vm.py
+12
-29
12 additions, 29 deletions
cccli/command/vm.py
with
12 additions
and
29 deletions
cccli/command/vm.py
+
12
−
29
View file @
4b192844
...
...
@@ -6,23 +6,24 @@ CloudControl VM related commands
from
cccli.exception
import
*
from
sjrpc.core.exceptions
import
*
from
cccli.printer
import
Printer
,
color
from
cccli.command.command
import
Command
from
cccli.command.command
import
Option
Command
from
optparse
import
OptionParser
class
VmCommand
(
Command
):
class
VmCommand
(
OptionCommand
):
'''
Command for vm style
'''
def
_
vm_action
(
self
,
argv
,
filters
=
None
):
try
:
oparser
=
OptionParser
(
prog
=
argv
[
0
]
)
oparser
.
add_option
(
"
--raw
"
,
action
=
"
store_true
"
,
dest
=
"
raw
"
,
def
_
_init__
(
self
,
cli
,
argv0
):
OptionCommand
.
__init__
(
self
,
cli
,
argv0
)
self
.
option
.
set_usage
(
"
%prog [options] <tql>
"
)
self
.
option
.
add_option
(
"
--raw
"
,
action
=
"
store_true
"
,
dest
=
"
raw
"
,
help
=
"
Don
'
t append filter on request
"
)
oparser
.
add_option
(
"
--direct
"
,
action
=
"
store_true
"
,
dest
=
"
direct
"
,
self
.
option
.
add_option
(
"
--direct
"
,
action
=
"
store_true
"
,
dest
=
"
direct
"
,
help
=
"
Directly send tql to server (don
'
t list before)
"
)
oparser
.
add_option
(
"
--
force
"
,
action
=
"
store_true
"
,
dest
=
"
force
"
,
self
.
option
.
add_option
(
"
--
tg
"
,
action
=
"
store_true
"
,
dest
=
"
noask
"
,
help
=
"
Don
'
t ask confirmation (Dangerous)
"
)
(
options
,
args
)
=
oparser
.
parse_args
(
argv
[
1
:])
def
_vm_action
(
self
,
argv
,
filters
=
None
):
try
:
(
options
,
args
)
=
self
.
option
.
parse_args
(
argv
[
1
:])
except
SystemExit
:
return
if
len
(
args
)
==
0
:
...
...
@@ -78,9 +79,6 @@ class Command_start(VmCommand):
def
__call__
(
self
,
argv
):
self
.
_vm_action
(
argv
,
"
&role=vm&status=stopped
"
)
def
usage
(
self
):
return
"
Usage: start [--raw] [--direct] [--force] [--help] <tql>
"
class
Command_stop
(
VmCommand
):
'''
Stop a running vm
'''
...
...
@@ -88,9 +86,6 @@ class Command_stop(VmCommand):
def
__call__
(
self
,
argv
):
self
.
_vm_action
(
argv
,
"
&role=vm&status=running
"
)
def
usage
(
self
):
return
"
Usage: stop [--raw] [--direct] [--force] [--help] <tql>
"
class
Command_destroy
(
VmCommand
):
'''
Force a vm to stop
'''
...
...
@@ -98,18 +93,12 @@ class Command_destroy(VmCommand):
def
__call__
(
self
,
argv
):
self
.
_vm_action
(
argv
,
"
&role=vm&status!=stopped
"
)
def
usage
(
self
):
return
"
Usage: destroy [--raw] [--direct] [--force] [--help] <tql>
"
class
Command_restart
(
VmCommand
):
'''
Restart a vm
'''
def
__call__
(
self
,
argv
):
self
.
_vm_action
(
argv
,
"
&role=vm&status=running
"
)
def
usage
(
self
):
return
"
Usage: restart [--raw] [--direct] [--force] [--help] <tql>
"
class
Command_pause
(
VmCommand
):
'''
Pause a running vm
'''
...
...
@@ -117,15 +106,9 @@ class Command_pause(VmCommand):
def
__call__
(
self
,
argv
):
self
.
_vm_action
(
argv
,
"
&role=vm&status=running
"
)
def
usage
(
self
):
return
"
Usage: pause [--raw] [--direct] [--force] [--help] <tql>
"
class
Command_resume
(
VmCommand
):
'''
Resume a paused vm
'''
def
__call__
(
self
,
argv
):
self
.
_vm_action
(
argv
,
"
&role=vm&status=stalled
"
)
def
usage
(
self
):
return
"
Usage: resume [--raw] [--direct] [--force] [--help] <tql>
"
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment