Allow to use any IPs with fuel-devops
- removing hardcoded 10.0.0.2 IP - adding new template to create the nodes Closes-bug: #1537176 Related-bug: #1533609 Change-Id: I245039eac2f78afca8157b033f64e051b9365463
This commit is contained in:
parent
d9cb2c0cd7
commit
cb8cb0b315
@ -1,5 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import os
|
||||
import sys
|
||||
import yaml
|
||||
|
||||
from devops.models import Environment
|
||||
@ -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())
|
||||
|
@ -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 %#
|
||||
|
@ -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
|
||||
@ -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
|
||||
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user