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
254d3991
Commit
254d3991
authored
Aug 06, 2013
by
Ilias Tsitsimpis
Committed by
Christos Stavrakakis
Sep 24, 2013
Browse files
ci: Specify a flavor_name instead of a flavor_id
Specify a flavor_name (in form of a reg expression) to use.
parent
d13c8f7c
Changes
3
Hide whitespace changes
Inline
Side-by-side
ci/new_config
View file @
254d3991
...
...
@@ -31,9 +31,8 @@ temporary_config = /tmp/ci_temp_conf
kamaki_cloud =
# Server name to use for our machine
server_name = Synnefo Deployment
# Flavor ID to use
# (149 for production, 639 for okeanos.io)
flavor_id = 639
# Flavor name (reg expression) to use
flavor_name = C8R8...D100drbd
# Image to use (name must contain this)
image_name = OldStable
# File containing the ssh keys to upload/install to server
...
...
ci/snf-ci
View file @
254d3991
...
...
@@ -104,7 +104,7 @@ def main(): # Too many branches. pylint: disable-msg=R0912
cloud
=
options
.
kamaki_cloud
)
if
getattr
(
options
,
CREATE_SERVER_CMD
,
False
):
synnefo_ci
.
create_server
(
flavor_
id
=
options
.
flavor
,
synnefo_ci
.
create_server
(
flavor_
name
=
options
.
flavor
,
image_id
=
options
.
image
,
ssh_keys
=
options
.
ssh_keys
)
synnefo_ci
.
clone_repo
()
...
...
ci/utils.py
View file @
254d3991
...
...
@@ -5,6 +5,7 @@ Synnefo ci utils module
"""
import
os
import
re
import
sys
import
time
import
logging
...
...
@@ -17,6 +18,7 @@ from kamaki.cli import config as kamaki_config
from
kamaki.clients.astakos
import
AstakosClient
from
kamaki.clients.cyclades
import
CycladesClient
from
kamaki.clients.image
import
ImageClient
from
kamaki.clients.compute
import
ComputeClient
DEFAULT_CONFIG_FILE
=
"new_config"
# UUID of owner of system images
...
...
@@ -165,12 +167,13 @@ class SynnefoCI(object):
self
.
fabric_installed
=
False
self
.
kamaki_installed
=
False
self
.
cyclades_client
=
None
self
.
compute_client
=
None
self
.
image_client
=
None
def
setup_kamaki
(
self
):
"""Initialize kamaki
Setup cyclades_client
and imag
e_client
Setup cyclades_client
, image_client and comput
e_client
"""
config
=
kamaki_config
.
Config
()
...
...
@@ -198,6 +201,12 @@ class SynnefoCI(object):
self
.
image_client
=
ImageClient
(
cyclades_url
,
token
)
self
.
image_client
.
CONNECTION_RETRY_LIMIT
=
2
compute_url
=
\
astakos_client
.
get_service_endpoints
(
'compute'
)[
'publicURL'
]
self
.
logger
.
debug
(
"Compute API url is %s"
%
_green
(
compute_url
))
self
.
compute_client
=
ComputeClient
(
compute_url
,
token
)
self
.
compute_client
.
CONNECTION_RETRY_LIMIT
=
2
def
_wait_transition
(
self
,
server_id
,
current_status
,
new_status
):
"""Wait for server to go from current_status to new_status"""
self
.
logger
.
debug
(
"Waiting for server to become %s"
%
new_status
)
...
...
@@ -232,7 +241,7 @@ class SynnefoCI(object):
self
.
_wait_transition
(
server_id
,
"ACTIVE"
,
"DELETED"
)
@
_check_kamaki
def
create_server
(
self
,
image_id
=
None
,
flavor_
id
=
None
,
ssh_keys
=
None
):
def
create_server
(
self
,
image_id
=
None
,
flavor_
name
=
None
,
ssh_keys
=
None
):
"""Create slave server"""
self
.
logger
.
info
(
"Create a new server.."
)
if
image_id
is
None
:
...
...
@@ -240,8 +249,7 @@ class SynnefoCI(object):
self
.
logger
.
debug
(
"Will use image
\"
%s
\"
"
%
_green
(
image
[
'name'
]))
image_id
=
image
[
"id"
]
self
.
logger
.
debug
(
"Image has id %s"
%
_green
(
image_id
))
if
flavor_id
is
None
:
flavor_id
=
self
.
config
.
getint
(
"Deployment"
,
"flavor_id"
)
flavor_id
=
self
.
_find_flavor
(
flavor_name
)
server
=
self
.
cyclades_client
.
create_server
(
self
.
config
.
get
(
'Deployment'
,
'server_name'
),
flavor_id
,
...
...
@@ -274,6 +282,24 @@ class SynnefoCI(object):
"""
.
format
(
accept_ssh_from
)
_run
(
cmd
,
False
)
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
)
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
)
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