Skip to content
This repository has been archived by the owner on Sep 26, 2019. It is now read-only.

Commit

Permalink
Merge "Allow to use any IPs with fuel-devops"
Browse files Browse the repository at this point in the history
  • Loading branch information
Jenkins authored and openstack-gerrit committed Feb 2, 2016
2 parents 706f8b2 + cb8cb0b commit 227fbdb
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 35 deletions.
28 changes: 24 additions & 4 deletions utils/jenkins/env.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
import os
import sys
import yaml

from devops.models import Environment
Expand Down Expand Up @@ -28,17 +29,36 @@ def create_config():
node['params'] = node_params
return {'template': {'devops_settings': conf}}

def get_ips(env):
def get_env():
env = os.environ
env_name = env['ENV_NAME']
return Environment.get(name=env_name)

def get_master_ip(env):
admin=env.get_node(role='master')
return admin.get_ip_address_by_network_name('public')

def get_slave_ips(env):
slaves = env.get_nodes(role='slave')
ips = []
for slave in slaves:
ips.append(slave.get_ip_address_by_network_name('public'))
return ips

def define_from_config(conf):
env = Environment.create_environment(conf)
env.define()
env.start()
print get_ips(env)


if __name__ == '__main__':
config = create_config()
define_from_config(config)
if len(sys.argv) != 2:
sys.exit(2)
cmd = sys.argv[1]
if cmd == 'create_env':
config = create_config()
define_from_config(config)
elif cmd == 'get_admin_ip':
print get_master_ip(get_env())
elif cmd == 'get_slaves_ips':
print get_slave_ips(get_env())
34 changes: 5 additions & 29 deletions utils/jenkins/repository/nodes/1.0.0/nodes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,12 @@ id: simple_riak_with_transports
resources:
#% for i in range(count|int) %#
#% set j = i +1 %#
- id: ssh_transport#{j}#
from: resources/transport_ssh
input:
user: 'vagrant'
password: 'vagrant'
- id: rsync#{j}#
from: resources/transport_rsync
input:
user: vagrant
password: vagrant
- id: transports#{j}#
from: resources/transports
input:
transports:
- password: ssh_transport#{j}#::password
user: ssh_transport#{j}#::user
port: ssh_transport#{j}#::port
name: ssh_transport#{j}#::name
- password: rsync#{j}#::password
name: rsync#{j}#::name
user: rsync#{j}#::user
port: rsync#{j}#::port
- id: node#{j}#
from: resources/ro_node
from: templates/node
input:
name: node#{j}#
ip: '10.0.0.#{i + 3}#'
transports_id: transports#{j}#::transports_id
- id: hosts_file#{j}#
from: resources/hosts_file
location: node#{j}#
tags: ['location=node#{j}#']
ssh_user: 'vagrant'
ssh_key: ''
ssh_password: 'vagrant'
ip: '#{ips[i]}#'
#% endfor %#
7 changes: 5 additions & 2 deletions utils/jenkins/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
set -xe

# for now we assume that master ip is 10.0.0.2 and slaves ips are 10.0.0.{3,4,5,...}
ADMIN_IP=10.0.0.2
ADMIN_PASSWORD=vagrant
ADMIN_USER=vagrant
INSTALL_DIR=/vagrant
Expand All @@ -16,7 +15,10 @@ TEST_SCRIPT=${TEST_SCRIPT:-/vagrant/examples/hosts_file/hosts.py}
DEPLOY_TIMEOUT=${DEPLOY_TIMEOUT:-60}

dos.py erase ${ENV_NAME} || true
ENV_NAME=${ENV_NAME} SLAVES_COUNT=${SLAVES_COUNT} IMAGE_PATH=${IMAGE_PATH} CONF_PATH=${CONF_PATH} python utils/jenkins/env.py
ENV_NAME=${ENV_NAME} SLAVES_COUNT=${SLAVES_COUNT} IMAGE_PATH=${IMAGE_PATH} CONF_PATH=${CONF_PATH} python utils/jenkins/env.py create_env

SLAVE_IPS=`ENV_NAME=${ENV_NAME} python utils/jenkins/env.py get_slaves_ips`
ADMIN_IP=`ENV_NAME=${ENV_NAME} python utils/jenkins/env.py get_admin_ip`

# Wait for master to boot
sleep 30
Expand All @@ -42,6 +44,7 @@ export SOLAR_CONFIG_OVERRIDE="/.solar_config_override"
solar repo update templates ${INSTALL_DIR}/utils/jenkins/repository
solar resource create nodes templates/nodes ips="${SLAVE_IPS}" count="${SLAVES_COUNT}"
bash -c "${TEST_SCRIPT}"
solar changes stage
Expand Down

0 comments on commit 227fbdb

Please sign in to comment.