Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cc-cli
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
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
8084e877
Commit
8084e877
authored
9 years ago
by
Antoine Millet
Committed by
Sébastien Luttringer
9 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Added allocate command (automatic VM allocation)
parent
ef3e542b
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cloudcontrol/cli/commands/allocate.py
+56
-0
56 additions, 0 deletions
cloudcontrol/cli/commands/allocate.py
with
56 additions
and
0 deletions
cloudcontrol/cli/commands/allocate.py
0 → 100644
+
56
−
0
View file @
8084e877
#coding=utf8
# This file is part of CloudControl.
#
# CloudControl is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# CloudControl is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with CloudControl. If not, see <http://www.gnu.org/licenses/>.
"""
CloudControl server command
"""
import
json
from
cloudcontrol.cli.exception
import
cmdBadArgument
from
cloudcontrol.cli.printer
import
color
from
cloudcontrol.cli.command
import
RemoteCommand
class
Command_allocate
(
RemoteCommand
):
"""
VM allocation command
"""
def
__init__
(
self
,
cli
,
argv0
):
RemoteCommand
.
__init__
(
self
,
cli
,
argv0
)
self
.
set_usage
(
"
%prog [options] <path to vmspec>
"
)
self
.
add_option
(
"
-t
"
,
dest
=
"
target
"
,
default
=
"
id
"
,
help
=
"
target on which to spawn VMs
"
)
def
__call__
(
self
,
argv
):
self
.
parse_args
(
argv
)
if
len
(
self
.
args
)
!=
1
:
raise
cmdBadArgument
()
# Load vmspec
try
:
vmspec
=
json
.
load
(
open
(
self
.
args
[
0
]))
except
IOError
as
err
:
self
.
printer
.
error
(
"
Unable to load vmspec: %s
"
%
err
.
args
[
1
])
else
:
job_id
=
self
.
rpc
.
call
(
"
allocate
"
,
vmspec
,
self
.
options
.
target
)
self
.
printer
.
out
(
"
\n
%sA job doing this allocation has been started.%s
"
%
(
color
[
"
light
"
],
color
[
"
reset
"
]))
self
.
printer
.
out
(
"
%sWatch it%s: watch list id:%s$duration$state$status$title
"
%
(
color
[
"
light
"
],
color
[
"
reset
"
],
job_id
))
self
.
printer
.
out
(
"
%sGet logs:%s attachment id:%s logs
"
%
(
color
[
"
light
"
],
color
[
"
reset
"
],
job_id
))
self
.
printer
.
out
(
"
%sGet results:%s attachment id:%s results
\n
"
%
(
color
[
"
light
"
],
color
[
"
reset
"
],
job_id
))
def
remote_functions
(
self
):
return
set
((
"
allocate
"
,))
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