Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
kamaki
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
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
itminedu
kamaki
Commits
8194b51b
Commit
8194b51b
authored
12 years ago
by
Stavros Sachtouris
Browse files
Options
Downloads
Patches
Plain Diff
Enrich helps in server create
parent
d7259dd5
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
kamaki/cli/commands/cyclades_cli.py
+29
-6
29 additions, 6 deletions
kamaki/cli/commands/cyclades_cli.py
kamaki/clients/compute.py
+3
-2
3 additions, 2 deletions
kamaki/clients/compute.py
with
32 additions
and
8 deletions
kamaki/cli/commands/cyclades_cli.py
+
29
−
6
View file @
8194b51b
...
...
@@ -66,8 +66,8 @@ howto_token = [
'
to get current token: /config get [server.]token
'
]
howto_personality
=
[
'
Value syntax: PATH,[SERVER_PATH,[OWNER,[GROUP,[MODE]]]]
'
,
'
Defines a file to be injected to VMs personality.
'
,
'
Personality value syntax: PATH,[SERVER_PATH,[OWNER,[GROUP,[MODE]]]]
'
,
'
PATH: of local file to be injected
'
,
'
SERVER_PATH: destination location inside server Image
'
,
'
OWNER: user id of destination file owner
'
,
...
...
@@ -76,7 +76,7 @@ howto_personality = [
def
raise_if_connection_error
(
err
):
if
err
.
status
in
range
(
100
,
200
):
if
err
.
status
in
range
(
-
12
,
200
):
raiseCLIError
(
err
,
details
=
[
'
Check if service is up or set compute.url
'
,
'
to get service url: /config get compute.url
'
,
...
...
@@ -209,7 +209,10 @@ class PersonalityArgument(KeyValueArgument):
details
=
howto_personality
)
path
=
termlist
[
0
]
if
not
exists
(
path
):
raiseCLIError
(
None
,
"
File %s does not exist
"
%
path
,
1
)
raiseCLIError
(
None
,
'
--personality: File %s does not exist
'
%
path
,
importance
=
1
,
details
=
howto_personality
)
self
.
_value
.
append
(
dict
(
path
=
path
))
with
open
(
path
)
as
f
:
self
.
_value
[
i
][
'
contents
'
]
=
b64encode
(
f
.
read
())
...
...
@@ -224,7 +227,12 @@ class PersonalityArgument(KeyValueArgument):
@command
(
server_cmds
)
class
server_create
(
_init_cyclades
):
"""
Create a server
"""
"""
Create a server (aka Virtual Machine)
Parameters:
name: (single quoted text)
flavor id: Hardware flavor. Pick one from: /flavor list
image id: OS images. Pick one from: /image list
"""
arguments
=
dict
(
personality
=
PersonalityArgument
(
...
...
@@ -242,8 +250,23 @@ class server_create(_init_cyclades):
image_id
,
self
[
'
personality
'
]
)
except
ClientError
as
err
:
raiseCLIError
(
err
)
except
ClientError
as
ce
:
if
ce
.
status
==
404
:
msg
=
(
'
%s
'
%
ce
).
lower
()
if
'
flavor
'
in
msg
:
raiseCLIError
(
ce
,
'
Flavor id %s not found
'
%
flavor_id
,
details
=
[
'
How to pick a valid flavor id:
'
,
'
- get a list of flavor ids: /flavor list
'
,
'
- details on a flavor: /flavor info <flavor id>
'
])
elif
'
image
'
in
msg
:
raiseCLIError
(
ce
,
'
Image id %s not found
'
%
image_id
,
details
=
[
'
How to pick a valid image id:
'
,
'
- get a list of image ids: /image list
'
,
'
- details on an image: /image info <image id>
'
])
raise_if_connection_error
(
ce
)
raiseCLIError
(
ce
)
except
ValueError
as
err
:
raiseCLIError
(
err
,
'
Invalid flavor id %s
'
%
flavor_id
,
details
=
'
Flavor id must be a positive integer
'
,
...
...
This diff is collapsed.
Click to expand it.
kamaki/clients/compute.py
+
3
−
2
View file @
8194b51b
...
...
@@ -98,7 +98,8 @@ class ComputeClient(ComputeClientApi):
r
=
self
.
servers_post
(
json_data
=
req
)
except
ClientError
as
err
:
try
:
tmp_err
=
err
.
details
.
split
(
'
,
'
)
tmp_err
=
err
.
details
if
isinstance
(
err
.
details
,
list
)
\
else
unicode
(
err
.
details
).
split
(
'
,
'
)
tmp_err
=
tmp_err
[
0
].
split
(
'
:
'
)
tmp_err
=
tmp_err
[
2
].
split
(
'"'
)
err
.
message
=
tmp_err
[
1
]
...
...
@@ -112,7 +113,7 @@ class ComputeClient(ComputeClientApi):
:param server_id: integer (str or int)
:param new_name: (str)
:param new_name: (str)
"""
req
=
{
'
server
'
:
{
'
name
'
:
new_name
}}
r
=
self
.
servers_put
(
server_id
,
json_data
=
req
)
...
...
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