Working with a JSON cluster configuration

Various components in Storlets require to know the cluster config.
Examples are:
1. The functional tests need to know the keystone auth uri
2. The installation needs to know where are the proxies / object servers
3. The management scripts need to know about all the nodes.

Now all information is expected to be in a single json file used by all components
There is a template of such file in install/storlets/templates/cluster_config which
is used for the s2aio installation.

changes include:
1. Adapting the ansible scripts to use a dynamic inventory that uses the json
2. refactoring setup_functional_test.sh moving work to
   /install/storlets/install_storlets.sh
3. general cleanups and fixes to  the ansible scripts

Change-Id: I2810f01a977c40870cada476a9c54ce4a7bdcc1a
This commit is contained in:
Eran Rom 2016-05-09 10:44:29 +03:00
parent 2811c86a09
commit 42690a28a2
37 changed files with 334 additions and 348 deletions

1
.gitignore vendored
View File

@ -27,6 +27,7 @@ pip-log.txt
# auto created for deploy
install/storlets/deploy/
install/storlets/prepare_vars.yml
install/swift/vars.yml
cluster_config.json

View File

@ -13,7 +13,9 @@ Quick Installation Guide
sudo apt-get install python-tox python-nose git
git clone https://github.com/openstack/storlets.git
cd storlets
./s2aio.sh
./s2aio.sh 1
Note the extra parameter being passed to s2aio.sh, it is important!
Browse through the StorletSamples directory so see storlet code examples,
and through the SystemTests to see samples of deploying and invoking a storlet

View File

@ -71,16 +71,13 @@ def deploy_storlet(url, token, storlet_jar,
def storlet_get_auth(conf):
auth_ip = conf['auth_ip']
auth_port = conf['auth_port']
account = conf['account']
user = conf['user_name']
passwd = conf['password']
auth_url = conf['all']['keystone_public_url']
account = conf['all']['storlets_default_tenant_name']
user = conf['all']['storlets_default_tenant_user_name']
passwd = conf['all']['storlets_default_tenant_user_password']
os_options = {'tenant_name': account}
if conf['region']:
os_options['region_name'] = conf['region']
url, token = c.get_auth('http://' + auth_ip + ":" +
auth_port + '/v2.0',
os_options['region_name'] = conf['all'].get('region', '')
url, token = c.get_auth(auth_url,
account + ':' + user,
passwd,
os_options=os_options,

View File

@ -0,0 +1,33 @@
"""-------------------------------------------------------------------------
Copyright (c) 2010-2016 OpenStack Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
Limitations under the License.
-------------------------------------------------------------------------"""
mgmt_vars = [
'lxc_device',
'keystone_endpoint_host',
'keystone_admin_url',
'keystone_public_url',
'keystone_admin_token',
'keystone_admin_password',
'swift_public_url',
'swift_endpoint_host',
'storlet_management_account',
'storlet_management_admin_username',
'storlet_manager_admin_password',
'storlet_management_swift_topology_container',
'storlet_management_swift_topology_object',
'base_os_image',
'docker_registry_port',
'storlet_management_install_dir'
]

View File

@ -14,13 +14,8 @@
#---------------------------------------------------------------------------
- hosts: storlet-proxy:storlet-storage:docker
vars_files:
- [ deploy/common.yml ]
roles:
- role: test_os_version
tasks:
- name: create lxc_device directory
shell: mkdir -p {{ lxc_device }} creates={{ lxc_device }}
- shell: chmod 777 {{ lxc_device }}
file: path={{ lxc_device }} state=directory mode=0777 recurse=yes

View File

@ -1,75 +0,0 @@
{
"groups" : {
"keystone": [ "127.0.0.1" ],
"swift-proxy": [ "127.0.0.1" ],
"swift-md": [ "127.0.0.1" ],
"swift-object": [ "10.20.0.1" , "10.20.0.3" ],
"swift-ring-builder": [ "127.0.0.1" ]
},
"127.0.0.1" : {
"rings_info": {
"ip" : "127.0.0.1",
"zone": "1",
"region": "1"
},
"swift_devices": {
"object_devices": [
{ "name" : "sda", "weight": "100", "fs":"xfs", "port": "6000" }
],
"container_devices": [
{ "name" : "sda", "weight": "100", "fs":"xfs", "port": "6001" }
],
"account_devices" : [
{ "name" : "sda", "weight": "100", "fs":"xfs", "port": "6002" }
]
},
"ansible_ssh_user" : "root",
"internal_ip" : "127.0.0.1"
},
"keystone" : {
"vars": {
"keystone_endpoint_host": "127.0.0.1",
"keystone_internal_url": "http://127.0.0.1:5000/v2.0",
"keystone_admin_url": "http://127.0.0.1:35357/v2.0",
"keystone_public_url": "http://127.0.0.1:5000/v2.0",
"keystone_admin_token": "ADMIN",
"swift_identity_password": "passw0rd",
"openstack_region" : "1",
"swift_public_endpoint": "127.0.0.1",
"swift_management_endpoint": "127.0.0.1",
"swift_internal_endpoint": "127.0.0.1",
"proxy_port": "80"
}
},
"swift": {
"vars": {
"swift_hash_path_prefix": "d55ca1881f1e09b1",
"swift_hash_path_suffix": "a3f3c381c916a198",
"log_swift_statsd": true,
"openstack_version": "liberty",
"installation_source": "git",
"swift_git": "https://github.com/openstack/swift.git",
"swift_git_dir": "/tmp/git/swift",
"swift_git_tag": "2.7.0"
}
},
"swift-ring-builder": {
"ring_builder" : {
"account": {
"min_part_hours": "1",
"part_power": "18",
"replicas": "1"
},
"object": {
"min_part_hours": "1",
"part_power": "18",
"replicas": "1"
},
"container": {
"min_part_hours": "1",
"part_power": "18",
"replicas": "1"
}
}
}
}

View File

@ -1,66 +0,0 @@
ibm_container_install_dir: opt/ibm
lxc_device: /home/docker_device
storlet_source_dir: ~/storlets
python_dist_packages_dir: usr/local/lib/python2.7/dist-packages
storlet_gateway_conf_file: /etc/swift/storlet_docker_gateway.conf
#----------------------------------------------------------------
# storlet_management / swift_storlet_management
# The below keystone vars MUST be synchronized with the swift_install variables.
keystone_endpoint_host: <Set Me!>
keystone_admin_url: "http://{{ keystone_endpoint_host }}:35357/v2.0"
keystone_public_url: "http://{{ keystone_endpoint_host }}:5000/v2.0"
keystone_admin_token: ADMIN
keystone_admin_password: passw0rd
swift_endpoint_host: <Set Me!>
swift_public_url: "http://{{ swift_endpoint_host }}:80/v1"
storlet_management_account: storlet_management
storlet_management_admin_username: storlet_manager
storlet_manager_admin_password: storlet_manager
storlet_management_swift_topology_container: swift_cluster
storlet_management_swift_topology_object : swift_cluster_nodes
storlet_management_ansible_dir: /opt/ibm/ansible/playbook
storlet_management_install_dir: /opt/ibm
# The below attribute can take true / false
storlets_enabled_attribute_name: storlet-enabled
#----------------------------------------------------------------
#----------------------------------------------------------------
# Storlets default tenant
storlets_default_tenant_name: service
storlets_default_tenant_user_name: swift
storlets_default_tenant_user_password: passw0rd
#----------------------------------------------------------------
#----------------------------------------------------------------
# docker_repository / docker_registry
docker_registry_random_string: ABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJ1234
docker_registry_port: 5001
#----------------------------------------------------------------
#----------------------------------------------------------------
# docker_base_storlet_images / docekr_base_images
base_image_maintainer: root
base_os_image: ubuntu_14.04
storlets_image_name_suffix: ubuntu_14.04_jre8_storlets
swift_user_id: 1003
swift_group_id: 1003
#----------------------------------------------------------------
#----------------------------------------------------------------
# middleware and gateway config file constants
storlet_middleware: storlet_handler
storlet_container: storlet
storlet_dependency: dependency
storlet_log: storletlog
storlet_images: docker_images
storlet_timeout: 40
storlet_gateway_module: storlet_gateway.storlet_docker_gateway:StorletGatewayDocker
storlet_execute_on_proxy_only: false
restart_linux_container_timeout: 3
#----------------------------------------------------------------

View File

@ -14,8 +14,5 @@
#---------------------------------------------------------------------------
- hosts: storlet-mgmt
vars_files:
- [ deploy/common.yml ]
roles:
- role: create_default_tenant

View File

@ -14,8 +14,5 @@
#---------------------------------------------------------------------------
- hosts: docker
vars_files:
- [ deploy/common.yml ]
roles:
- role: docker_base_jre_image

View File

@ -14,22 +14,14 @@
#---------------------------------------------------------------------------
- hosts: docker
vars_files:
- [ deploy/common.yml ]
roles:
- role: docker_client
- hosts: docker # TODO: This patch probably needs to propegate to all clients on all nodes.
vars_files:
- [ deploy/common.yml ]
tasks:
- include: roles/docker_registry/tasks/patch_docker_configs.yml
- hosts: docker
vars_files:
- [ deploy/common.yml ]
roles:
- role: docker_registry

View File

@ -14,8 +14,5 @@
#---------------------------------------------------------------------------
- hosts: docker
vars_files:
- [ deploy/common.yml ]
roles:
- role: docker_storlet_engine_image

View File

@ -14,10 +14,6 @@
#---------------------------------------------------------------------------
- hosts: storlet-proxy:storlet-storage
vars_files:
- [ deploy/common.yml ]
roles:
- role: docker_client
- role: host_storlet_engine

View File

@ -1,34 +1,41 @@
sudo mkdir deploy
echo "Copying vars and hosts file to deploy directory"
sudo cp common.yml-sample deploy/common.yml
sudo cp hosts-sample deploy/hosts
sudo chown -R $USER:$USER deploy
sed -i 's/<Set Me!>/127.0.0.1/g' deploy/common.yml
sed -i 's/<Set Me!>/'$USER'/g' deploy/hosts
sed -i '/ansible_ssh_pass/d' deploy/hosts
# If no arguments are supplied, assume we are under jenkins job, and
# we need to edit common.yml to set the appropriate source dir
if [ ! -d deploy ]; then
mkdir deploy
fi
cp prepare_vars.yml-sample deploy/prepare_vars.yml
sed -i 's/<ANSIBLE_USER>/'$USER'/g' deploy/prepare_vars.yml
sed -i 's/<MGMT_USER>/'$USER'/g' deploy/prepare_vars.yml
ansible-playbook -i prepare_host prepare_storlets_install.yml
#echo "Copying vars and hosts file to deploy directory"
if [ -z "$1" ]
then
sed -i 's/~\/storlets/\/home\/'$USER'\/workspace\/gate-storlets-functional\//g' deploy/common.yml
sed -i 's/~\/storlets/\/home\/'$USER'\/workspace\/gate-storlets-functional\//g' deploy/cluster_config.json
fi
echo "Running hosts cluster_check playbook"
ansible-playbook -s -i deploy/hosts cluster_check.yml
ansible-playbook -s -i storlets_dynamic_inventory.py cluster_check.yml
echo "Running docker_repository playbook"
ansible-playbook -s -i deploy/hosts docker_repository.yml
ansible-playbook -s -i storlets_dynamic_inventory.py docker_repository.yml
echo "Running docker_base_storlet_images playbook"
ansible-playbook -s -i deploy/hosts docker_base_storlet_images.yml
ansible-playbook -s -i storlets_dynamic_inventory.py docker_base_storlet_images.yml
echo "Running docker_storlet_engine_image playbook"
ansible-playbook -s -i deploy/hosts docker_storlet_engine_image.yml
ansible-playbook -s -i storlets_dynamic_inventory.py docker_storlet_engine_image.yml
echo "Running hosts storlet_mgmt playbook"
ansible-playbook -s -i deploy/hosts storlet_mgmt.yml
ansible-playbook -s -i storlets_dynamic_inventory.py storlet_mgmt.yml
echo "Running hosts fetch_proxy_conf playbook"
ansible-playbook -s -i deploy/hosts fetch_proxy_conf.yml
ansible-playbook -s -i storlets_dynamic_inventory.py fetch_proxy_conf.yml
echo "Running host_storlet_engine playbook"
ansible-playbook -s -i deploy/hosts host_storlet_engine.yml
ansible-playbook -s -i storlets_dynamic_inventory.py host_storlet_engine.yml
sudo chmod -R 777 /opt/ibm
echo "Running create_default_tenant playbook"
ansible-playbook -i deploy/hosts create_default_tenant.yml
# This assumes the user running the script is also the storlet-mgmt user!
ansible-playbook -i storlets_dynamic_inventory.py create_default_tenant.yml
#ansible-playbook -s -i $1 storlet.yml

View File

@ -0,0 +1,17 @@
#---------------------------------------------------------------------------
# Copyright (c) 2010-2016 OpenStack Foundation
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# Limitations under the License.
#---------------------------------------------------------------------------
[s2aio]
127.0.0.1

View File

@ -0,0 +1,27 @@
#---------------------------------------------------------------------------
# Copyright IBM Corp. 2015, 2016 All Rights Reserved
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# Limitations under the License.
#---------------------------------------------------------------------------
- name: cluster_config.json from template
hosts: s2aio
vars_files:
- [ deploy/prepare_vars.yml ]
tasks:
- stat: path="{{ playbook_dir }}/deploy/cluster_config.json"
register: st0
- template:
src: templates/cluster_config
dest: "{{ playbook_dir }}/deploy/cluster_config.json"
when: not st0.stat.exists

View File

@ -12,23 +12,11 @@
# See the License for the specific language governing permissions and
# Limitations under the License.
#---------------------------------------------------------------------------
[docker]
localhost
[storlet-proxy]
localhost
[storlet-storage]
localhost
[storlet-mgmt]
localhost
[storlet-proxy:vars]
ansible_ssh_user = <Set Me!>
ansible_ssh_pass = passw0rd
[storlet-storage:vars]
ansible_ssh_user = <Set Me!>
ansible_ssh_pass = passw0rd
ansible_ssh_user: <ANSIBLE_USER>
storlets_management_user: <MGMT_USER>
keystone_endpoint_host: 127.0.0.1
keystone_admin_token: ADMIN
keystone_admin_password: passw0rd
swift_endpoint_host: 127.0.0.1
swift_endpoint_port: 80

View File

@ -14,9 +14,5 @@
#---------------------------------------------------------------------------
- hosts: storlet-proxy:storlet-storage
vars_files:
- {{ storlet_management_ansible_dir }}/common.yml
roles:
- pull_tenant_image

View File

@ -14,9 +14,5 @@
#---------------------------------------------------------------------------
- hosts: storlet-mgmt
vars_files:
- {{ storlet_management_ansible_dir }}/common.yml
roles:
- push_tenant_image

View File

@ -15,9 +15,5 @@
- hosts: storlet-mgmt
vars_files:
- {{ storlet_management_ansible_dir }}/common.yml
roles:
- add_new_tenant

View File

@ -43,34 +43,10 @@
- "{{ storlet_management_ansible_dir }}/roles/pull_tenant_image/tasks"
- "{{ storlet_management_ansible_dir }}/roles/push_tenant_image/tasks"
- "{{ storlet_management_ansible_dir }}/roles/push_tenant_image/templates"
- "{{ storlet_management_ansible_dir }}/deploy"
- name: create storlet management var file
template:
src: "var_yml_file"
dest: "{{ storlet_management_ansible_dir }}/common.yml"
owner: root
mode: 0644
- name: create storlets_add_new_tenant.yml file
template:
src: "storlets_add_new_tenant_yml_file"
dest: "{{ storlet_management_ansible_dir }}/storlets_add_new_tenant.yml"
owner: root
mode: 0644
- name: create pull_tenant_image.yml file
template:
src: "pull_tenant_image_yml_file"
dest: "{{ storlet_management_ansible_dir }}/pull_tenant_image.yml"
owner: root
mode: 0644
- name: create push_tenant_image.yml file
template:
src: "push_tenant_image_yml_file"
dest: "{{ storlet_management_ansible_dir }}/push_tenant_image.yml"
owner: root
mode: 0644
- name: copy dynamic inventory file
copy: src="{{ inventory_file }}" dest="{{ storlet_management_ansible_dir }}/storlets_mgmt_dynamic_inventory.py" mode=0755
- name: create storlet_mgmt_common.py file
template:
@ -93,6 +69,13 @@
owner: root
mode: 0755
- copy: src={{item}} dest={{ storlet_management_ansible_dir }}/{{ item }}
with_items:
- pull_tenant_image.yml
- push_tenant_image.yml
- storlets_add_new_tenant.yml
- ansible_storlet_management_vars.py
- copy: src=add_new_tenant_main.yml dest={{ storlet_management_ansible_dir }}/roles/add_new_tenant/tasks/main.yml
- copy: src=pull_tenant_image_main.yml dest={{ storlet_management_ansible_dir }}/roles/pull_tenant_image/tasks/main.yml

View File

@ -20,18 +20,19 @@ import subprocess
from storlet_mgmt_common import get_hosts_object, monitor_playbook_execution
def add_new_tenant(hosts_file, tenant_name, user_name, user_password):
p = subprocess.Popen(['ansible-playbook',
'-s',
'-i', hosts_file,
'{{ storlet_management_ansible_dir }}/storlets_add_new_tenant.yml',
def add_new_tenant(tenant_name, user_name, user_password):
p = subprocess.Popen(['ansible-playbook', '-vvvv' , '-s',
'-i', 'storlets_mgmt_dynamic_inventory.py',
'storlets_add_new_tenant.yml',
'-e', 'tenant_name=' + tenant_name,
'-e', 'user_name=' + user_name,
'-e', 'user_password=' + user_password,
'-e', 'storlets_image_name_suffix=' + '{{ storlets_image_name_suffix }}'],
# env={"ANSIBLE_HOST_KEY_CHECKING" : "False"},
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
'-e', 'storlets_image_name_suffix=' +
'{{ storlets_image_name_suffix }}'],
env={"ANSIBLE_HOST_KEY_CHECKING" : "False"},
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
cwd = "{{ storlet_management_ansible_dir }}")
monitor_playbook_execution(p)
@ -49,7 +50,7 @@ def main(argv):
user_password = argv[3]
get_hosts_object()
add_new_tenant("{{ storlet_management_ansible_dir }}/swift_cluster_nodes", tenant_name, user_name, user_password)
add_new_tenant(tenant_name, user_name, user_password)
if __name__ == "__main__":
main(sys.argv)

View File

@ -25,25 +25,25 @@ from storlet_mgmt_common import get_hosts_object, monitor_playbook_execution
def deploy_image(tenant_name, tar_object_name, tenant_image_name):
get_hosts_object()
p = subprocess.Popen(['ansible-playbook',
'-s',
'-i', '{{ storlet_management_ansible_dir }}/swift_cluster_nodes',
'{{ storlet_management_ansible_dir }}/push_tenant_image.yml',
p = subprocess.Popen(['ansible-playbook', '-s',
'-i', 'storlets_mgmt_dynamic_inventory.py',
'push_tenant_image.yml',
'-e', 'tar_object_name=' + tar_object_name,
'-e', 'tenant_name=' + tenant_name,
'-e', 'tenant_image_name=' + tenant_image_name],
# env={"ANSIBLE_HOST_KEY_CHECKING" : "False"},
env={"ANSIBLE_HOST_KEY_CHECKING" : "False"},
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
stderr=subprocess.PIPE,
cwd = "{{ storlet_management_ansible_dir }}")
monitor_playbook_execution(p)
p = subprocess.Popen(['ansible-playbook',
'-s',
'-i', '{{ storlet_management_ansible_dir }}/swift_cluster_nodes',
'{{ storlet_management_ansible_dir }}/pull_tenant_image.yml',
p = subprocess.Popen(['ansible-playbook', '-s',
'-i', 'storlets_mgmt_dynamic_inventory.py',
'pull_tenant_image.yml',
'-e', 'tenant_name=' + tenant_name],
# env={"ANSIBLE_HOST_KEY_CHECKING" : "False"},
env={"ANSIBLE_HOST_KEY_CHECKING" : "False"},
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
stderr=subprocess.PIPE,
cwd = "{{ storlet_management_ansible_dir }}")
monitor_playbook_execution(p)

View File

@ -15,6 +15,7 @@ See the License for the specific language governing permissions and
Limitations under the License.
-------------------------------------------------------------------------'''
import os
import sys
import select
import subprocess
@ -39,9 +40,10 @@ def get_hosts_object():
response_dict=response,
headers=None)
assert(response.get('status') == 200)
f = open("{{ storlet_management_ansible_dir }}/swift_cluster_nodes", "w")
f = open("{{ storlet_management_ansible_dir }}/deploy/{{ storlet_management_swift_topology_object }}", "w")
f.write(content)
f.close()
os.chmod("{{ storlet_management_ansible_dir }}/deploy/{{ storlet_management_swift_topology_object }}", 0666)
def monitor_playbook_execution(p):

View File

@ -1,36 +0,0 @@
#---------------------------------------------------------------------------
# Copyright IBM Corp. 2015, 2015 All Rights Reserved
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# Limitations under the License.
#---------------------------------------------------------------------------
lxc_device: {{ lxc_device }}
keystone_endpoint_host: {{ keystone_endpoint_host }}
keystone_admin_url: {{ keystone_admin_url }}
keystone_public_url: {{ keystone_public_url }}
keystone_admin_token: {{ keystone_admin_token }}
keystone_admin_password: {{ keystone_admin_password }}
swift_public_url: {{ swift_public_url }}
swift_endpoint_host: {{ swift_endpoint_host }}
storlet_management_account: {{ storlet_management_account }}
storlet_management_admin_username: {{ storlet_management_admin_username }}
storlet_manager_admin_password: {{ storlet_manager_admin_password }}
storlet_management_swift_topology_container: {{ storlet_management_swift_topology_container }}
storlet_management_swift_topology_object : {{ storlet_management_swift_topology_object }}
base_os_image : {{ base_os_image }}
docker_registry_port : {{ docker_registry_port }}
storlet_management_install_dir : {{ storlet_management_install_dir }}

View File

@ -14,7 +14,13 @@
#---------------------------------------------------------------------------
- name: Invoke the Create Storlet enabled Tenant script
command: python /opt/ibm/add_new_tenant.py "{{ storlets_default_tenant_name }}" "{{storlets_default_tenant_user_name }}" "{{ storlets_default_tenant_user_password }}"
command: python add_new_tenant.py "{{ storlets_default_tenant_name }}" "{{storlets_default_tenant_user_name }}" "{{ storlets_default_tenant_user_password }}" chdir=/opt/ibm/
register: command_result
- debug: var=command_result.stdout_lines
- name: Invoke the Deploy image script
command: python /opt/ibm/deploy_image.py "{{ storlets_default_tenant_name }}" "{{ base_os_image }}_jre8_storlets.tar" "{{ hostvars[groups['docker'][0]]['inventory_hostname'] }}:{{ docker_registry_port }}/{{ base_os_image }}_jre8_storlets"
command: python deploy_image.py "{{ storlets_default_tenant_name }}" "{{ base_os_image }}_jre8_storlets.tar" "{{ hostvars[groups['docker'][0]]['inventory_hostname'] }}:{{ docker_registry_port }}/{{ base_os_image }}_jre8_storlets" chdir=/opt/ibm/
register: command_result
- debug: var=command_result.stdout_lines

View File

@ -22,7 +22,6 @@
- "docker pull ubuntu:14.04"
- "docker tag ubuntu:14.04 {{ inventory_hostname }}:{{ docker_registry_port }}/ubuntu_14.04"
- "docker push {{ inventory_hostname }}:{{ docker_registry_port }}/ubuntu_14.04"
tags: ubuntu_14.04_jre8
when: "'0' in ubuntu_image.stdout_lines[0]"
- name: Create Repository for building the image
@ -34,7 +33,6 @@
state: directory
mode: 0755
owner: root
tags: ubuntu_14.04_jre8
when: not st0.stat.exists
- name: Download necessary Java dependencies
@ -45,7 +43,6 @@
- https://json-simple.googlecode.com/files/json_simple-1.1.jar
- http://www.slf4j.org/dist/slf4j-1.7.7.tar.gz
- http://logback.qos.ch/dist/logback-1.1.2.tar.gz
tags: ubuntu_14.04_jre8
- name: Untar downloaded dependencies
command: "{{ item }}"
@ -59,7 +56,6 @@
- "mv logback-1.1.2/logback-core-1.1.2.jar ."
- "mv logback-1.1.2/logback-classic-1.1.2.jar ."
- "rm -fr logback-1.1.2/ logback-1.1.2.tar.gz"
tags: ubuntu_14.04_jre8
- name: Copy additional resources
copy:
@ -67,6 +63,5 @@
dest: /data/registry/repositories/ubuntu_14.04_jre8
with_items:
- logback.xml
tags: ubuntu_14.04_jre8
- include: create_layer.yml dockerfile_prefix={{ base_os_image}}_jre8 layer_suffix=jre8 tags=jre8
- include: create_layer.yml dockerfile_prefix={{ base_os_image}}_jre8 layer_suffix=jre8

View File

@ -19,7 +19,6 @@
state: directory
mode: 0755
owner: root
tags: storlets
- name: Copy SBus resources
copy:
@ -30,7 +29,6 @@
- "Engine/SBus/SBusJavaFacade/bin/SBusJavaFacade.jar"
- "Engine/SBus/SBusPythonFacade/dist/SBusPythonFacade-1.0.linux-x86_64.tar.gz"
- "Engine/SBus/SBusTransportLayer/bin/sbus.so"
tags: storlets
- name: Copy SDaemon resources
copy:
@ -38,7 +36,6 @@
dest: /data/registry/repositories/{{ base_os_image }}_jre8_storlets
with_items:
- "Engine/SDaemon/bin/SDaemon.jar"
tags: storlets
- name: Copy SCommon resources
copy:
@ -46,7 +43,6 @@
dest: /data/registry/repositories/{{ base_os_image }}_jre8_storlets
with_items:
- "Engine/SCommon/bin/SCommon.jar"
tags: storlets
- name: Copy Daemon Factory resources
copy:
@ -54,12 +50,10 @@
dest: /data/registry/repositories/{{ base_os_image }}_jre8_storlets
with_items:
- "Engine/storlet_daemon_factory/dist/storlet_daemon_factory-1.0.linux-x86_64.tar.gz"
tags: storlets
- name: Copy Init Container Script
copy:
src: init_container.sh
dest: /data/registry/repositories/{{ base_os_image }}_jre8_storlets
tags: storlets
- include: create_layer.yml dockerfile_prefix={{ base_os_image }}_jre8_storlets layer_suffix=jre8_storlets tags=storlets
- include: create_layer.yml dockerfile_prefix={{ base_os_image }}_jre8_storlets layer_suffix=jre8_storlets

View File

@ -44,11 +44,12 @@
user: "{{ storlet_management_admin_username }}"
role: admin
- name: copy cluster information file
copy:
src="{{ inventory_file }}"
dest="/tmp/{{ storlet_management_swift_topology_object }}"
- name: Create the cluster information object
command: python storlets_dynamic_inventory.py
--inventory "{{ playbook_dir }}/deploy/temp_{{ storlet_management_swift_topology_object }}"
args:
chdir: "{{ playbook_dir }}"
- name: Create the cluster information container
command: swift
--os-auth-url="{{ keystone_public_url }}"
@ -60,17 +61,18 @@
--write-acl "{{ storlet_management_account }}:{{ storlet_management_admin_username }}"
--meta "{{ storlets_enabled_attribute_name }}:true"
- name: Create the cluster information object
- name: Upload the cluster information object
command: swift
--os-auth-url="{{ keystone_public_url }}"
--os-username="{{ storlet_management_admin_username }}"
--os-password="{{ storlet_manager_admin_password }}"
--os-tenant-name="{{ storlet_management_account }}"
upload "{{ storlet_management_swift_topology_container }}" "{{ storlet_management_swift_topology_object }}"
upload "{{ storlet_management_swift_topology_container }}" "temp_{{ storlet_management_swift_topology_object }}"
--object-name "{{ storlet_management_swift_topology_object }}"
args:
chdir: /tmp/
chdir: "{{ playbook_dir }}/deploy"
- name: delete cluster information file
file:
path="/tmp/{{ storlet_management_swift_topology_object }}"
path="{{ playbook_dir }}/deploy/temp_{{ storlet_management_swift_topology_object }}"
state=absent

View File

@ -17,4 +17,4 @@
assert:
that:
- "ansible_distribution == 'Ubuntu'"
- "ansible_distribution_version >= '13.04'"
- "ansible_distribution_version >= '14.04'"

View File

@ -14,10 +14,7 @@
#---------------------------------------------------------------------------
- hosts: storlet-mgmt
vars_files:
- [ deploy/common.yml ]
roles:
# - role: docker_client
- role: docker_client
- role: swift_storlet_management
- role: ansible_storlet_management

View File

@ -0,0 +1,94 @@
#! /usr/bin/python
"""-------------------------------------------------------------------------
Copyright (c) 2010-2016 OpenStack Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
Limitations under the License.
-------------------------------------------------------------------------"""
import argparse
import json
from ansible_storlet_management_vars import mgmt_vars
class Inventory(object):
'''
Ansible inventory , generated from config file
'''
def __init__(self, fname):
self.__load_config__(fname)
def __load_config__(self, name):
with open(name) as f:
# this function is a bit ugly and should be rewritten
self.conf = json.loads(f.read())
def show_list(self):
g = {}
for group in ['storlet-mgmt', 'storlet-proxy', 'storlet-storage',
'docker']:
g[group] = dict()
g[group]['hosts'] = self.conf['groups'][group]
g[group]['vars'] = dict()
g[group]['vars'].update(self.conf['all'])
return g
def show_host(self, name):
res = self.conf[name]
return res
def write_inventory(self, inventory_file):
inventory = dict()
inventory['groups'] = self.conf['groups']
for group in ['storlet-mgmt', 'storlet-proxy', 'storlet-storage',
'docker']:
for host in self.conf['groups'][group]:
if host not in inventory:
inventory[host] = self.conf[host]
if group == 'storlet-mgmt':
inventory[host]['ansible_ssh_user'] =\
self.conf['all']['storlets_management_user']
all_vars = dict()
for v in mgmt_vars:
all_vars[v] = self.conf['all'][v]
inventory['all'] = all_vars
with open(inventory_file, 'w') as f:
f.write(json.dumps(inventory))
return inventory
def main():
parser = argparse.ArgumentParser()
parser.add_argument('--list', action='store_true')
parser.add_argument('--host')
parser.add_argument('--inventory')
args = parser.parse_args()
inventory = Inventory('deploy/cluster_config.json')
out = {}
if args.list:
out = inventory.show_list()
if args.host:
out = inventory.show_host(args.host)
if args.inventory:
out = inventory.write_inventory(args.inventory)
print (json.dumps(out))
if __name__ == '__main__':
main()

View File

@ -0,0 +1,53 @@
{
"groups" : {
"storlet-mgmt": [ "127.0.0.1" ],
"storlet-proxy": [ "127.0.0.1" ],
"storlet-storage": [ "127.0.0.1" ],
"docker": [ "127.0.0.1" ]
},
"127.0.0.1" : {
"ansible_ssh_user" : "{{ ansible_ssh_user }}"
},
"all" : {
"ibm_container_install_dir": "opt/ibm",
"lxc_device": "/home/docker_device",
"storlet_source_dir": "~/storlets",
"python_dist_packages_dir": "usr/local/lib/python2.7/dist-packages",
"storlet_gateway_conf_file": "/etc/swift/storlet_docker_gateway.conf",
"keystone_endpoint_host": "{{ keystone_endpoint_host }}",
"keystone_admin_url": "http://{{ keystone_endpoint_host }}:35357/v2.0",
"keystone_public_url": "http://{{ keystone_endpoint_host }}:5000/v2.0",
"keystone_admin_token": "{{ keystone_admin_token }}",
"keystone_admin_password": "{{ keystone_admin_password }}",
"swift_endpoint_host": "{{ swift_endpoint_host }}",
"swift_public_url": "http://{{ swift_endpoint_host }}:{{ swift_endpoint_port }}/v1",
"storlets_management_user": "{{ storlets_management_user }}",
"storlet_management_account": "storlet_management",
"storlet_management_admin_username": "storlet_manager",
"storlet_manager_admin_password": "storlet_manager",
"storlet_management_swift_topology_container": "swift_cluster",
"storlet_management_swift_topology_object": "cluster_config.json",
"storlet_management_ansible_dir": "/opt/ibm/ansible/playbook",
"storlet_management_install_dir": "/opt/ibm",
"storlets_enabled_attribute_name": "storlet-enabled",
"docker_registry_random_string": "ABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJABCDEFGHIJ1234",
"docker_registry_port": "5001",
"storlets_default_tenant_name": "service",
"storlets_default_tenant_user_name": "swift",
"storlets_default_tenant_user_password": "passw0rd",
"base_image_maintainer": "root",
"base_os_image": "ubuntu_14.04",
"storlets_image_name_suffix": "ubuntu_14.04_jre8_storlets",
"swift_user_id": "1003",
"swift_group_id": "1003",
"storlet_middleware": "storlet_handler",
"storlet_container": "storlet",
"storlet_dependency": "dependency",
"storlet_log": "storletlog",
"storlet_images": "docker_images",
"storlet_timeout": "40",
"storlet_gateway_module": "storlet_gateway.storlet_docker_gateway:StorletGatewayDocker",
"storlet_execute_on_proxy_only": "false",
"restart_linux_container_timeout": "3"
}
}

View File

@ -2,6 +2,7 @@
# of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later.
pbr>=0.6,!=0.7,<1.0
pbr>=1.9
setuptools>=17.1
Babel>=1.3
oslosphinx>=2.2.0 # Apache-2.0

View File

@ -25,5 +25,5 @@ except ImportError:
pass
setuptools.setup(
setup_requires=['pbr'],
setup_requires=['pbr>=1.9', 'setuptools>=17.1'],
pbr=True)

View File

@ -60,7 +60,7 @@ cd install/storlets
cd -
# TODO: this is for tests. Deal accordingly.
cp cluster_config.json-sample cluster_config.json
cp install/storlets/deploy/cluster_config.json .
sudo chown $USER:$USER cluster_config.json
echo "export OS_USERNAME=swift; export OS_PASSWORD=passw0rd;" >> ~/.bashrc

View File

@ -10,7 +10,7 @@ setenv =
VIRTUAL_ENV={envdir}
deps =
-r{toxinidir}/test-requirements.txt
git+git://github.com/openstack/swift.git
git+git://github.com/openstack/swift.git@2.7.0
#commands = python setup.py test --slowest --testr-args='{posargs}'
commands = ./.unittests