Functional tests and Vagrant environment

Proposed environment utilizes Vagrant that works with KVM or
Virtualbox based VM that runs Swift storage node. There are
two major run scripts. Rhe first one run-remote.sh will expect
successfully setup of the Swift VM. Then rsync freezer directory
to the VM and finally execute remotely via SSH run-local.py script
that will create LVM volume and mount it so the functional tests
could be facilitated.

Regular file system (non LVM) and LVM snapshot non incremental
backup tests are included in this commit as the most common usecase.

BLUEPRINT: functional-testing
Change-Id: Ia9c1e2e770ca413fe4a896dd0a55c4babf3df686
This commit is contained in:
Zahari Zahariev 2015-03-30 14:35:35 +01:00
parent daaecadcd8
commit 8e3a5cf8ca
15 changed files with 768 additions and 1 deletions

1
.gitignore vendored
View File

@ -2,6 +2,7 @@ __pycache__
dist
build
.venv
tests/scenario/.vagrant
.idea
.autogenerated
.coverage

View File

@ -17,6 +17,7 @@ Contributors
- Duncan Thomas
- Coleman Corrigan
- Zahari Zahariev
Credits
=======

View File

@ -54,7 +54,7 @@ def alter_proxy(args_dict):
raise Exception('Proxy has unknown scheme')
def backup_arguments():
def backup_arguments(args_dict={}):
"""
Default arguments and command line options interface. The function return
a name space called backup_args.
@ -275,6 +275,9 @@ def backup_arguments():
dest='dry_run', default=False)
backup_args = arg_parser.parse_args()
# Intercept command line arguments if you are not using the CLI
if args_dict:
backup_args.__dict__.update(args_dict)
# Set additional namespace attributes
backup_args.__dict__['remote_match_backup'] = []
backup_args.__dict__['remote_objects'] = []

56
tests/scenario/README.txt Normal file
View File

@ -0,0 +1,56 @@
Freezer Scenario Functional Testing
====================================
The most straight forward way to set up the Freezer functional testing
environment is by utilizing VAGRANT. There is initial Vagrant file that
by default is setup to work with Virtualbox and Ubuntu 14.04 as virtual
machine OS.
In order to prepare your Vagrant + VirtualBox/KVM environment there is:
$ ./prepare-vagrant.sh
The script is tested to work on Ubuntu and will automatically download
and deploy Vagrant, VirtualBox, KVM and libvrt as well as mutate Vagrant
plugins. It will also download a base Ubuntu 14.04 64bit Vagrant box and
use mutate plugin to deoplu a libvrt version for KVM use.
Before running 'vagrant up' for the first time make sure you have replaced
the 'P-R-O-X-Y' string (Vagrant file) with the correct HTTP proxy URL and
port if behind one e.g. P-R-O-X-Y => http://proxy.test.company.com:3344
To start the process of MV deployment run:
$ vagrant destroy -f #This will delete any previosly deployed instances
$ vagrant up #This kick starts the Devstack Swift VM that tests use
When process is done normalyy it take 10 - 20 min depends on your network.
You should have a fully configured Swift object storage VM that is
accessible on a host only IP e.g 10.199.199.199
Copy file swiftrc.sample to swiftrc and edited properly should you need to.
Next you need to decide weather you want to perform the integration tests
locally on your station or into the Vagrant VM. There are two scripts to
do just that:
$ ./run-local.py
$ ./run-remote.sh
The first of them will setup loopback LVM disk that your Freezer scenario
tests will need and mount it in /mnt.
The second will create the LVM disk in the Vagrant virtual machine and will
synchronize all Freezer files to the VM as well where it is going to trigger
the integration test.
Successful test run should look something similar to this:
............
test_lvm_level0 (backup_scenario.BackupScenarioFS) ... ok
test_no_lvm_level0 (backup_scenario.BackupScenarioFS) ... ok
test_utils_methods (backup_scenario.BackupScenarioFS) ... ok
----------------------------------------------------------------------
Ran 3 tests in 2.696s
OK

27
tests/scenario/Vagrantfile vendored Normal file
View File

@ -0,0 +1,27 @@
#ENV['VAGRANT_DEFAULT_PROVIDER'] = 'libvirt'
Vagrant.configure("2") do |config|
config.ssh.username = 'vagrant'
config.ssh.password = 'vagrant'
config.vm.provider "virtualbox" do |vb|
vb.gui = false
vb.memory = 2048
vb.cpus = 2
end
config.vm.provider "libvirt" do |lbv|
lbv.driver = "kvm"
lbv.memory = 2048
lbv.cpus = 2
end
config.vm.define "freezer-vm" do |machine|
machine.vm.box = "trusty64"
machine.vm.network "private_network" , ip: "10.199.199.199"
machine.vm.provision :shell, path: "vagrant-scripts/fix-proxy.sh", args: "P-R-O-X-Y", keep_color: true
machine.vm.provision :shell, path: "vagrant-scripts/deploy-devstack.sh", args: "", keep_color: true
machine.vm.provision :shell, path: "vagrant-scripts/test-swift.sh", args: "", keep_color: true
end
end

View File

View File

@ -0,0 +1,269 @@
"""
Copyright 2015 Hewlett-Packard
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.
This product includes cryptographic software written by Eric Young
(eay@cryptsoft.com). This product includes software written by Tim
Hudson (tjh@cryptsoft.com).
========================================================================
"""
import os
import sys
import uuid
import unittest
import tempfile
import shutil
import random
import hashlib
from copy import copy
lib_path = os.path.abspath(os.path.join('..', '..'))
sys.path.append(lib_path)
from freezer import arguments, main, swift
class BackupScenarioFS(unittest.TestCase):
def create_tmp_tree(self, path):
"""
freezer_test_XXXXXX
|-dir_foo
| |-dir_bar
| | |
| | |-hello.lock
| | |-foo
| | |-bar
| | |-foobar
| |
| |-hello.lock
| |-foo
| |-bar
| |-foobar
|
|-hello.lock
|-foo
|-bar
|-foobar
"""
dir_path = copy(path)
tmp_files = ['foo', 'bar', 'foobar', 'hello.lock']
tmp_dirs = ['', 'dir_foo', 'dir_bar']
self.tmp_files = []
for fd in tmp_dirs:
if fd:
dir_path += os.path.sep + fd
os.mkdir(dir_path)
for fn in tmp_files:
file_path = dir_path + os.path.sep + fn
with open(file_path, 'w') as handle:
handle.write(fn + '\n' + dir_path + '\n')
handle.close()
self.tmp_files.append(file_path)
def hashfile(self, filepath):
"""
Get GIT style sha1 hash for a file
"""
filesize_bytes = os.path.getsize(filepath)
hash_obj = hashlib.sha1()
hash_obj.update(("blob %u\0" % filesize_bytes).encode('utf-8'))
with open(filepath, 'rb') as handle:
hash_obj.update(handle.read())
return hash_obj.hexdigest()
def snap_tmp_tree_sha1(self, file_list):
hash_dict = {}
for file_name in file_list:
if os.path.isfile(file_name):
hash_dict[file_name] = self.hashfile(file_name)
return hash_dict
def damage_tmp_tree(self, tmp_files):
"""
Delete and modify random files from the tree file structure
"""
# Delete 4 file
tmp_files = copy(tmp_files)
for nfile in range(4):
fn = random.choice(tmp_files)
os.unlink(fn)
tmp_files.remove(fn)
self.tmp_deleted.append(fn)
# Change the content of 3 files
for nfile in range(3):
fn = random.choice(tmp_files)
f = open(fn, 'w')
f.write('foofoo\n')
f.close()
self.tmp_modified.append(fn)
def setUp(self):
self.tmp_files = []
self.tmp_deleted = []
self.tmp_modified = []
self.tmp_path = tempfile.mkdtemp(prefix='freezer_test_')
self.create_tmp_tree(self.tmp_path)
def tearDown(self):
# shutil.rmtree(self.tmp_path)
pass
def test_utils_methods(self):
"""
Test functions that manipulate the files
"""
dict_1 = self.snap_tmp_tree_sha1(self.tmp_files)
self.damage_tmp_tree(self.tmp_files)
dict_2 = self.snap_tmp_tree_sha1(self.tmp_files)
self.assertEqual(len(self.tmp_files), len(dict_1))
self.assertEqual(len(dict_1), len(self.tmp_deleted) + len(dict_2))
for key in self.tmp_files:
if key in self.tmp_deleted:
self.assertFalse(os.path.isfile(key))
self.assertFalse(key in dict_2)
elif key in self.tmp_modified:
self.assertTrue(os.path.isfile(key))
self.assertNotEqual(key + dict_1[key], key + dict_2[key])
else:
self.assertTrue(os.path.isfile(key))
self.assertEqual(key + dict_1[key], key + dict_2[key])
def test_no_lvm_level0(self):
"""
Maximum level filesystem backup
freezerc --action backup
--path-to-backup /var/log
--backup-name rsync-var-log-test-XX
--container var-log-test-XX
"""
# Set arguments
test_args = {
#'proxy' : '',
'action' : 'backup',
'src_file' : copy(self.tmp_path),
'backup_name' : str(uuid.uuid4()),
'container' : str(uuid.uuid4())
}
(backup_args, _) = arguments.backup_arguments(test_args)
self.assertEqual(backup_args.mode, 'fs')
self.assertEqual(backup_args.max_backup_level, 0)
main.freezer_main(backup_args)
backup_args = swift.get_containers_list(backup_args)
name_list = [item['name'] for item in backup_args.containers_list]
self.assertTrue(backup_args.container in name_list)
self.assertTrue(backup_args.container_segments in name_list)
fdict_before = self.snap_tmp_tree_sha1(self.tmp_files)
self.damage_tmp_tree(self.tmp_files)
# Restore
test_args = {
#'proxy' : '',
'action' : 'restore',
'restore_abs_path' : copy(self.tmp_path),
'backup_name' : copy(backup_args.backup_name),
'container' : copy(backup_args.container)
}
(restore_args, _) = arguments.backup_arguments(test_args)
self.assertEqual(backup_args.mode, 'fs')
main.freezer_main(restore_args)
fdict_after = self.snap_tmp_tree_sha1(self.tmp_files)
self.assertEqual(len(self.tmp_files), len(fdict_before))
self.assertEqual(len(self.tmp_files), len(fdict_after))
for key in self.tmp_files:
self.assertTrue(os.path.isfile(key))
self.assertEqual(key + fdict_before[key], key + fdict_after[key])
def test_lvm_level0(self):
"""
LVM snapshot filesystem backup
freezerc --action backup
--lvm-srcvol /dev/freezer-test1-volgroup/freezer-test1-vol
--lvm-dirmount /tmp/freezer-test-lvm-snapshot
--lvm-volgroup freezer-test1-volgroup
--lvm-snapsize 1M
--file-to-backup /mnt/freezer-test-lvm/lvm_test_XXXX/
--container UUID
--exclude "\*.lock"
--backup-name UUID
"""
# Set arguments
lvm_path = '/mnt/freezer-test-lvm'
self.tmp_path = tempfile.mkdtemp(prefix='lvm_test_', dir=lvm_path)
self.create_tmp_tree(self.tmp_path)
test_args = {
#'proxy' : '',
'action' : 'backup',
'lvm_srcvol' : '/dev/freezer-test1-volgroup/freezer-test1-vol',
'lvm_dirmount' : '/tmp/freezer-test-lvm-snapshot',
'lvm_volgroup' : 'freezer-test1-volgroup',
'lvm_snapsize' : '1M',
'exclude' : '*.lock',
'src_file' : copy(self.tmp_path),
'backup_name' : str(uuid.uuid4()),
'container' : str(uuid.uuid4())
}
(backup_args, _) = arguments.backup_arguments(test_args)
# Make sure default value for MODE is filesystem
self.assertEqual(backup_args.mode, 'fs')
# Check that if not explicitly defined the MAX-BACKUP is 0
self.assertEqual(backup_args.max_backup_level, 0)
# Call the actual BACKUP
main.freezer_main(backup_args)
# Retrieve a list of all container data on Swift
backup_args = swift.get_containers_list(backup_args)
# Filter only the container names from all other data
name_list = [item['name'] for item in backup_args.containers_list]
# Amke sure that we have created a container with the desired name
# in Swift
self.assertTrue(backup_args.container in name_list)
# Ensure that the SEGMENTS container is found on Swift as well
self.assertTrue(backup_args.container_segments in name_list)
# Create a file => SAH1 hash dictionary that will recored file
# hashes before any files being modified or deleted
fdict_before = self.snap_tmp_tree_sha1(self.tmp_files)
# Delete and modify random files in the test directory
# structure
self.damage_tmp_tree(self.tmp_files)
# RESTORE section
# Create RESTORE action dictionary to be passed to
# arguments.backup_arguments() they will emulate the
# command line arguments
test_args = {
#'proxy' : '',
'action' : 'restore',
'restore_abs_path' : copy(self.tmp_path),
'backup_name' : copy(backup_args.backup_name),
'container' : copy(backup_args.container)
}
(restore_args, _) = arguments.backup_arguments(test_args)
self.assertEqual(restore_args.mode, 'fs')
# Call RESTORE on Freezer code base
main.freezer_main(restore_args)
fdict_after = self.snap_tmp_tree_sha1(self.tmp_files)
self.assertEqual(len(self.tmp_files), len(fdict_before))
# Check if cout of all original files match recovered files
# plus the number of deleted .LOCK files which were not restored
self.assertEqual(len(self.tmp_files), len(fdict_after) +
len([x for x in self.tmp_deleted if x.endswith('.lock')]))
for key in self.tmp_files:
if key.endswith('.lock') and key in self.tmp_deleted:
self.assertFalse(os.path.isfile(key))
elif key.endswith('.lock') and key in self.tmp_modified:
self.assertNotEqual(key + fdict_before[key], key + fdict_after[key])
else:
self.assertTrue(os.path.isfile(key))
self.assertEqual(key + fdict_before[key], key + fdict_after[key])
if __name__ == '__main__':
unittest.main()

View File

@ -0,0 +1,56 @@
#!/usr/bin/env bash
# Copyright 2015 Hewlett-Packard
#
# 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.
#
# This product includes cryptographic software written by Eric Young
# (eay@cryptsoft.com). This product includes software written by Tim
# Hudson (tjh@cryptsoft.com).
# ========================================================================
if [ "X$(python -mplatform | grep Ubuntu)" == "X" ]; then
echo "Only Ubunu support!";
exit 1;
fi
if [ ! -e /usr/bin/vagrant ]; then
### Download Vagrant 1.7.2 ###
wget https://dl.bintray.com/mitchellh/vagrant/vagrant_1.7.2_x86_64.deb || exit 1;
sudo dpkg -i vagrant*.deb || exit 1;
fi
sudo apt-get -y install virtualbox || exit 1;
### VAGRANT LIBVIRT ###
sudo apt-get -y install libxslt-dev libxml2-dev libvirt-dev qemu-kvm || exit 1;
if [ "X$(vagrant plugin list|awk '{print $1}'|grep vagrant-libvirt)" == "X" ]; then
vagrant plugin install vagrant-libvirt || exit 1;
fi
### VAGRANT MUTATE ###
sudo apt-get -y install qemu-utils || exit 1;
if [ "X$(vagrant plugin list|awk '{print $1}'|grep vagrant-mutate)" == "X" ]; then
vagrant plugin install vagrant-mutate || exit 1;
fi
### UBUNTU 14.04 - TRUSTY 64BIT ###
if [ "$(vagrant box list|awk '{print $1}'|grep ^trusty64|wc -l)" != "2" ]; then
vagrant box add --force trusty64 https://vagrantcloud.com/ubuntu/boxes/trusty64/versions/14.04/providers/virtualbox.box || exit 1;
vagrant mutate trusty64 libvirt || exit 1;
fi
### CREATE VAGRANT MACHINE ###
#vagrant destroy -f || exit 1;
time vagrant up || exit 1
exit 0;

53
tests/scenario/run-local.py Executable file
View File

@ -0,0 +1,53 @@
#!/usr/bin/python
"""
Copyright 2015 Hewlett-Packard
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.
This product includes cryptographic software written by Eric Young
(eay@cryptsoft.com). This product includes software written by Tim
Hudson (tjh@cryptsoft.com).
========================================================================
"""
import os
import sys
import logging
from unittest import TestLoader, TextTestRunner, TestSuite
from backup_scenario import BackupScenarioFS
SWIFT_CONF = 'swiftrc'
def load_swift_env(fname):
file_lines = open(fname, 'r').readlines()
for line in file_lines:
if ' ' not in line.strip():
continue
(cmd, line) = line.split()
if cmd.strip().lower() == 'unset':
os.environ.pop(line, None)
elif '=' in line.strip():
(key, val) = line.split('=')
os.environ[key.strip()] = val.strip()
if __name__ == "__main__":
load_swift_env(SWIFT_CONF)
logging.disable(logging.CRITICAL)
os.system('./vagrant-scripts/create-lvm.sh 1')
loader = TestLoader()
suite = TestSuite(
loader.loadTestsFromTestCase(BackupScenarioFS),
)
runner = TextTestRunner(verbosity = 2)
runner.run(suite)

40
tests/scenario/run-remote.sh Executable file
View File

@ -0,0 +1,40 @@
#!/bin/bash
# Copyright 2015 Hewlett-Packard
#
# 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.
#
# This product includes cryptographic software written by Eric Young
# (eay@cryptsoft.com). This product includes software written by Tim
# Hudson (tjh@cryptsoft.com).
# ========================================================================
REMOTE_USER=vagrant
REMOTE_PASS=vagrant
REMOTE_HOST=10.199.199.199
if [ ! -e /usr/bin/sshpass ]; then
sudo apt-get install sshpass -y || sudo yum install sshpass -y
fi
if [ ! -e /usr/bin/rsync ]; then
sudo apt-get install rsync -y || sudo yum install rsync -y
fi
ssh-keygen -R ${REMOTE_HOST}
sshpass -p ${REMOTE_PASS} ssh -o StrictHostKeyChecking=no ${REMOTE_USER}@${REMOTE_HOST} echo
sshpass -p ${REMOTE_PASS} rsync -azvr --exclude '.git/' --exclude '.vagrant' --exclude '.tox' \
--exclude '*.pyc' ./../../ ${REMOTE_USER}@${REMOTE_HOST}:~/freezer
# Quotes below are important and without them tests will run on the localhost
sshpass -p ${REMOTE_PASS} ssh ${REMOTE_USER}@${REMOTE_HOST} 'cd freezer/tests/scenario/ && sudo ./run-local.py'
exit 0;

View File

@ -0,0 +1,14 @@
unset OS_USERNAME
unset OS_PASSWORD
unset OS_TENANT_NAME
unset OS_AUTH_URL
unset OS_REGION_NAME
unset OS_TENANT_ID
unset OS_SERVICE_TOKEN
unset OS_SERVICE_ENDPOINT
export OS_USERNAME=admin
export OS_PASSWORD=admin
export OS_TENANT_NAME=admin
export OS_AUTH_URL=http://10.199.199.199:5000/v2.0

View File

@ -0,0 +1,53 @@
#!/bin/bash
set -x
set -e
if [ "X$EUID" != "X0" ]; then
echo "Please run as root";
exit 1;
fi
if [ -z "${1##*[!0-9]*}" ]; then
echo "Please provide /dev/loopX number"
exit 1;
fi
MOUNT_DIR='/mnt/freezer-test-lvm'
IMG_DIR='/tmp'
function delete_test_lvm {
cd ~
# This should be empty => sudo dmsetup table
sudo umount -vd ${MOUNT_DIR} || test 0
sudo rm ${MOUNT_DIR} -rf
sudo fuser -k /dev/loop${1} || test 0
sudo dmsetup remove -f freezer--test${1}--volgroup-freezer--test${1}--vol || test 0
sudo losetup -d /dev/loop${1} || test 0
}
function create_test_lvm {
dd if=/dev/zero of=${IMG_DIR}/freezer-test-lvm${1}.img bs=20 count=1048576
sudo losetup /dev/loop${1} ${IMG_DIR}/freezer-test-lvm${1}.img
sudo apt-get install lvm2 -y || yum install lvm2 -y
sudo pvcreate /dev/loop${1}
sudo vgcreate freezer-test${1}-volgroup /dev/loop${1}
sudo lvcreate -L 10M --name freezer-test${1}-vol freezer-test${1}-volgroup
LVM_VOL=/dev/freezer-test${1}-volgroup/freezer-test${1}-vol
sudo mkfs.ext4 ${LVM_VOL}
sudo mkdir -p ${MOUNT_DIR}
sudo mount ${LVM_VOL} ${MOUNT_DIR}
df -Th
}
### MAIN ###
# >>> Uncomment if you get stuck <<<
# delete_test_lvm ${1};
# exit 0;
if [ "X$(sudo losetup -a|grep loop${1})" == "X" ]; then
delete_test_lvm ${1};
create_test_lvm ${1};
fi
exit 0;

View File

@ -0,0 +1,83 @@
#!/bin/bash
# Copyright 2015 Hewlett-Packard
#
# 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.
#
# This product includes cryptographic software written by Eric Young
# (eay@cryptsoft.com). This product includes software written by Tim
# Hudson (tjh@cryptsoft.com).
# ========================================================================
set -x
HOST_ONLY_IP=$(hostname -I|awk '{print $2}')
USER=vagrant
sudo apt-get update
sudo apt-get upgrade -y
sudo apt-get install git-core -y
git clone https://git.openstack.org/openstack-dev/devstack
sudo cat > devstack/local.conf << E-O-L
[[local|localrc]]
HOST_IP=$HOST_ONLY_IP
DEST=/opt/stack
ADMIN_PASSWORD=admin
DATABASE_PASSWORD=\$ADMIN_PASSWORD
RABBIT_PASSWORD=\$ADMIN_PASSWORD
SERVICE_PASSWORD=\$ADMIN_PASSWORD
SERVICE_TOKEN=a682f596-76f3-11e3-b3b2-e716f9080d50
### Logging ###
LOGFILE=\$DEST/logs/stack.sh.log
LOGDAYS=1
### Services ###
disable_all_services
enable_service key mysql s-proxy s-object s-container s-account
### Swift ###
SWIFT_HASH=66a3d6b56c1f479c8b4e70ab5c2000f5
SWIFT_REPLICAS=1
SWIFT_DATA_DIR=\$DEST/data/swift
GIT_BASE=http://github.com
E-O-L
sudo cat > keystonerc << E-O-L
unset OS_USERNAME
unset OS_PASSWORD
unset OS_TENANT_NAME
unset OS_AUTH_URL
unset OS_REGION_NAME
unset OS_TENANT_ID
export OS_USERNAME=admin
export OS_PASSWORD=admin
export OS_TENANT_NAME=admin
export OS_AUTH_URL=http://$HOST_ONLY_IP:35357/v2.0
export OS_REGION_NAME=RegionOne
E-O-L
chown ${USER}.${USER} -R *
cd devstack
su ${USER} -c './unstack.sh'
su ${USER} -c './stack.sh'
cd ..
source keystonerc
keystone service-list
sleep 5
keystone service-list
sleep 5
keystone service-list
exit 0;

View File

@ -0,0 +1,56 @@
#!/bin/bash
# Copyright 2015 Hewlett-Packard
#
# 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.
#
# This product includes cryptographic software written by Eric Young
# (eay@cryptsoft.com). This product includes software written by Tim
# Hudson (tjh@cryptsoft.com).
# ========================================================================
set -x
HOST_IPS=$(hostname -I)
HOST_IPS=$(echo $HOST_IPS)
HOST_IPS=$(echo $HOST_IPS|sed 's/ /,/')
if [ "$1" == "P-R-O-X-Y" ]; then
exit 0;
fi
# Proxy goes here
PROXY="$1"
sudo cat >> /etc/environment << E-O-L
export http_proxy=$PROXY
export https_proxy=$PROXY
export HTTP_PROXY=$PROXY
export HTTPS_PROXY=$PROXY
export no_proxy=127.0.0.1,localhost,$HOST_IPS
export NO_PROXY=127.0.0.1,localhost,$HOST_IPS
E-O-L
sudo cat > /etc/apt/apt.conf.d/01proxies << E-O-L
Acquire::http::proxy "$PROXY";
Acquire::https::proxy "$PROXY";
E-O-L
sudo apt-get update
sudo apt-get upgrade -y
sudo apt-get install git-core -y
git config --global http.proxy $PROXY
git config --global https.proxy $PROXY
exit 0;

View File

@ -0,0 +1,55 @@
#!/bin/bash
# Copyright 2015 Hewlett-Packard
#
# 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.
#
# This product includes cryptographic software written by Eric Young
# (eay@cryptsoft.com). This product includes software written by Tim
# Hudson (tjh@cryptsoft.com).
# ========================================================================
set +x
SERVICE_IP=127.0.0.1
if [ "X$1" != "X" ]; then
SERVICE_IP=$1
fi
#SW="swift -v -V 2.0 -A http://$SERVICE_IP:5000/v2.0/ --os-username=admin --os-password=admin --os-tenant-name=admin"
SW="swift"
function get_status() {
if [ $? -eq 0 ]; then
echo "OK"
else
echo "FAIL"
fi
}
sudo apt-get install python-swiftclient -y 2>&1 > /dev/null
source keystonerc
$SW post TEST 2>&1 > /dev/null
get_status
$SW list TEST 2>&1 > /dev/null
get_status
SOURCE_DIR='/etc/swift /etc/apache2'
$SW upload TEST $SOURCE_DIR 2>&1 > /dev/null
get_status
$SW delete TEST 2>&1 > /dev/null
get_status