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
2d2be899
Commit
2d2be899
authored
14 years ago
by
Seblu
Browse files
Options
Downloads
Patches
Plain Diff
Split shutdown and execute in separate files
parent
e23af3bc
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
cccli/command/__init__.py
+2
-1
2 additions, 1 deletion
cccli/command/__init__.py
cccli/command/execute.py
+32
-0
32 additions, 0 deletions
cccli/command/execute.py
cccli/command/shutdown.py
+0
-23
0 additions, 23 deletions
cccli/command/shutdown.py
with
34 additions
and
24 deletions
cccli/command/__init__.py
+
2
−
1
View file @
2d2be899
...
...
@@ -8,15 +8,16 @@ CloudControl CLI Commands Package
# bunch of command
from
cccli.command.account
import
*
from
cccli.command.alias
import
*
from
cccli.command.host
import
*
from
cccli.command.right
import
*
from
cccli.command.shell
import
*
from
cccli.command.tag
import
*
from
cccli.command.vm
import
*
# by command module
from
cccli.command.execute
import
Command_execute
from
cccli.command.expert
import
Command_expert
from
cccli.command.kill
import
Command_kill
from
cccli.command.list
import
Command_list
from
cccli.command.server
import
Command_server
from
cccli.command.shutdown
import
Command_shutdown
from
cccli.command.tagdisplay
import
Command_tagdisplay
This diff is collapsed.
Click to expand it.
cccli/command/execute.py
0 → 100644
+
32
−
0
View file @
2d2be899
'''
CloudControl execute command
'''
from
cccli.exception
import
*
from
sjrpc.core.exceptions
import
*
from
cccli.printer
import
Printer
,
color
from
cccli.command.command
import
TqlCommand
class
Command_execute
(
TqlCommand
):
'''
Execute a command on the remote host
'''
def
__init__
(
self
,
cli
,
argv0
):
TqlCommand
.
__init__
(
self
,
cli
,
argv0
)
self
.
set_usage
(
"
%prog [options] <tql> <command>
"
)
self
.
tql_filter
+=
"
&con&r~
'
host|hv
'"
def
__call__
(
self
,
argv
):
# arg parse
self
.
parse_args
(
argv
)
if
len
(
self
.
args
)
!=
2
:
raise
cmdBadArgument
()
# rpc call
self
.
rpccall
(
"
execute
"
,
self
.
args
[
0
],
self
.
args
[
1
],
_callback
=
self
.
_cb_print_output
)
def
_cb_print_output
(
self
,
d
):
'''
Print output of execute by object
'''
for
o
in
d
[
"
objects
"
]:
self
.
printer
.
out
(
"
%sid:%s%s%s output:
"
%
(
self
.
tdtc
(
"
id
"
),
self
.
tdc
(
"
id
"
),
o
[
"
id
"
],
color
[
"
reset
"
]))
self
.
printer
.
out
(
o
.
get
(
"
output
"
,
""
),
nl
=
""
)
This diff is collapsed.
Click to expand it.
cccli/command/
host
.py
→
cccli/command/
shutdown
.py
+
0
−
23
View file @
2d2be899
...
...
@@ -8,29 +8,6 @@ from sjrpc.core.exceptions import *
from
cccli.printer
import
Printer
,
color
from
cccli.command.command
import
TqlCommand
class
Command_execute
(
TqlCommand
):
'''
Execute a command on the remote host
'''
def
__init__
(
self
,
cli
,
argv0
):
TqlCommand
.
__init__
(
self
,
cli
,
argv0
)
self
.
set_usage
(
"
%prog [options] <tql> <command>
"
)
self
.
tql_filter
+=
"
&con&r~
'
host|hv
'"
def
__call__
(
self
,
argv
):
# arg parse
self
.
parse_args
(
argv
)
if
len
(
self
.
args
)
!=
2
:
raise
cmdBadArgument
()
# rpc call
self
.
rpccall
(
"
execute
"
,
self
.
args
[
0
],
self
.
args
[
1
],
_callback
=
self
.
_cb_print_output
)
def
_cb_print_output
(
self
,
d
):
'''
Print output of execute by object
'''
for
o
in
d
[
"
objects
"
]:
self
.
printer
.
out
(
"
%sid:%s%s%s output:
"
%
(
self
.
tdtc
(
"
id
"
),
self
.
tdc
(
"
id
"
),
o
[
"
id
"
],
color
[
"
reset
"
]))
self
.
printer
.
out
(
o
.
get
(
"
output
"
,
""
),
nl
=
""
)
class
Command_shutdown
(
TqlCommand
):
'''
Shutdown a physical host
'''
...
...
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