Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
itminedu
synnefo
Commits
22e9fd1b
Commit
22e9fd1b
authored
Aug 20, 2013
by
Ilias Tsitsimpis
Browse files
ci: Get flavor by name
The option flavor_name support a list of flavors to try. Refs #4192
parent
af241a62
Changes
2
Hide whitespace changes
Inline
Side-by-side
ci/new_config
View file @
22e9fd1b
...
...
@@ -32,6 +32,7 @@ kamaki_cloud =
# Server name to use for our machine
server_name = Synnefo Deployment
# Flavor name (reg expression) to use
# This is a list of flavor_names (comma seperated) to try
flavor_name = C8R8...D100drbd
# Image to use (name must contain this)
image_name = OldStable
...
...
ci/utils.py
View file @
22e9fd1b
...
...
@@ -284,21 +284,25 @@ class SynnefoCI(object):
def
_find_flavor
(
self
,
flavor_name
):
"""Given a flavor_name (reg expression) find a flavor id to use"""
if
flavor_name
is
None
:
flavor_name
=
self
.
config
.
get
(
'Deployment'
,
'flavor_name'
)
self
.
logger
.
debug
(
"Try to find a flavor with name
\"
%s
\"
"
%
flavor_name
)
# Get a list of flavor names from config file
flavor_names
=
self
.
config
.
get
(
'Deployment'
,
'flavor_name'
).
split
(
","
)
if
flavor_name
is
not
None
:
# If we have a flavor_name to use, add it to our list
flavor_names
.
insert
(
0
,
flavor_name
)
flavors
=
self
.
compute_client
.
list_flavors
()
flavors
=
[
f
for
f
in
flavors
if
re
.
search
(
flavor_name
,
f
[
'name'
])
is
not
None
]
if
flavors
:
self
.
logger
.
debug
(
"Will use %s with id %s"
%
(
flavors
[
0
][
'name'
],
flavors
[
0
][
'id'
]))
return
flavors
[
0
][
'id'
]
else
:
self
.
logger
.
error
(
"No matching flavor found.. aborting"
)
sys
.
exit
(
1
)
for
flname
in
flavor_names
:
sflname
=
flname
.
strip
()
self
.
logger
.
debug
(
"Try to find a flavor with name
\"
%s
\"
"
%
sflname
)
fls
=
[
f
for
f
in
flavors
if
re
.
search
(
sflname
,
f
[
'name'
])
is
not
None
]
if
fls
:
self
.
logger
.
debug
(
"Will use %s with id %s"
%
(
fls
[
0
][
'name'
],
fls
[
0
][
'id'
]))
return
fls
[
0
][
'id'
]
self
.
logger
.
error
(
"No matching flavor found.. aborting"
)
sys
.
exit
(
1
)
def
_find_image
(
self
):
"""Find a suitable image to use
...
...
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