diff options
-rw-r--r-- | .coveragerc | 28 | ||||
-rw-r--r-- | .gitignore | 1 | ||||
-rwxr-xr-x | deploy/check_openstack_progress.sh | 8 | ||||
-rw-r--r-- | deploy/config/bm_environment/zte-baremetal1/deploy.yml | 1 | ||||
-rw-r--r-- | deploy/config/vm_environment/zte-virtual1/deploy.yml | 2 | ||||
-rwxr-xr-x | deploy/get_conf.py | 3 | ||||
-rw-r--r-- | deploy/tempest.py | 31 | ||||
-rw-r--r-- | requirements.txt | 0 | ||||
-rw-r--r-- | setup.py | 9 | ||||
-rw-r--r-- | test-requirements.txt | 5 | ||||
-rw-r--r-- | tests/__init__.py | 0 | ||||
-rw-r--r-- | tests/unit/__init__.py | 0 | ||||
-rw-r--r-- | tests/unit/test_placeholder.py | 2 | ||||
-rw-r--r-- | tox.ini | 42 |
14 files changed, 123 insertions, 9 deletions
diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 00000000..d58e2766 --- /dev/null +++ b/.coveragerc @@ -0,0 +1,28 @@ +# .coveragerc to control coverage.py + +[run] +branch = True +source = + deploy + tests + +[report] +# Regexes for lines to exclude from consideration +exclude_lines = + # Have to re-enable the standard pragma + pragma: no cover + + # Don't complain about missing debug-only code: + def __repr__ + if self\.debug + + # Don't complain if tests don't hit defensive assertion code: + raise AssertionError + raise NotImplementedError + + # Don't complain if non-runnable code isn't run: + if 0: + if __name__ == .__main__.: + +ignore_errors = True + @@ -42,6 +42,7 @@ pip-delete-this-directory.txt .tox/ .coverage .cache +coverage.xml # Log files: *.log diff --git a/deploy/check_openstack_progress.sh b/deploy/check_openstack_progress.sh index 3512d6bc..f0ab1e90 100755 --- a/deploy/check_openstack_progress.sh +++ b/deploy/check_openstack_progress.sh @@ -44,8 +44,9 @@ while true; do fi count=$[count + 1] - openstack_install_active=`daisy host-list --cluster-id $cluster_id | awk -F "|" '{print $12}' | grep -c "active" ` - openstack_install_failed=`daisy host-list --cluster-id $cluster_id | awk -F "|" '{print $12}' | grep -c "install-failed" ` + # get 'Role_status' column + openstack_install_active=`daisy host-list --cluster-id $cluster_id | awk -F "|" '{print $13}' | grep -c "active" ` + openstack_install_failed=`daisy host-list --cluster-id $cluster_id | awk -F "|" '{print $13}' | grep -c "install-failed" ` if [ $openstack_install_active -eq $hosts_num ]; then echo "openstack installing successful ..." break @@ -54,7 +55,8 @@ while true; do tail -n 200 /var/log/daisy/kolla_$cluster_id* exit 1 else - progress=`daisy host-list --cluster-id $cluster_id |grep DISCOVERY_SUCCESSFUL |awk -F "|" '{print $11}'|sed s/[[:space:]]//g|sed ':a;N;$ s/\n/ /g;ba'` + # get 'Role_progress' column + progress=`daisy host-list --cluster-id $cluster_id |grep DISCOVERY_SUCCESSFUL |awk -F "|" '{print $12}'|sed s/[[:space:]]//g|sed ':a;N;$ s/\n/ /g;ba'` echo " openstack in installing , progress of each node is $progress%" sleep 30 fi diff --git a/deploy/config/bm_environment/zte-baremetal1/deploy.yml b/deploy/config/bm_environment/zte-baremetal1/deploy.yml index eafff5fd..58516e88 100644 --- a/deploy/config/bm_environment/zte-baremetal1/deploy.yml +++ b/deploy/config/bm_environment/zte-baremetal1/deploy.yml @@ -21,3 +21,4 @@ disks: daisy_passwd: 'r00tme'
daisy_ip: '10.20.7.3'
daisy_gateway: '10.20.7.1'
+ceph_disk_name: '/dev/sdb'
diff --git a/deploy/config/vm_environment/zte-virtual1/deploy.yml b/deploy/config/vm_environment/zte-virtual1/deploy.yml index 1bf254f5..12fa1690 100644 --- a/deploy/config/vm_environment/zte-virtual1/deploy.yml +++ b/deploy/config/vm_environment/zte-virtual1/deploy.yml @@ -10,4 +10,4 @@ disks: daisy_passwd: 'r00tme'
daisy_ip: '10.20.11.2'
daisy_gateway: '10.20.11.1'
-deploy_env: 'virtual'
\ No newline at end of file +ceph_disk_name: '/dev/sdb'
diff --git a/deploy/get_conf.py b/deploy/get_conf.py index a2d7bf6a..37da2beb 100755 --- a/deploy/get_conf.py +++ b/deploy/get_conf.py @@ -91,7 +91,8 @@ def dha_config_parse(s, dha_file): def config(dha_file, network_file): data = init(dha_file) + ceph_disk_name = data.get('ceph_disk_name') hosts_name = dha_config_parse(data, dha_file) data = init(network_file) network_map, vip, interface_map = network_config_parse(data, network_file) - return interface_map, hosts_name, network_map, vip + return interface_map, hosts_name, network_map, vip, ceph_disk_name diff --git a/deploy/tempest.py b/deploy/tempest.py index 263e62e0..3bf0ccc7 100644 --- a/deploy/tempest.py +++ b/deploy/tempest.py @@ -66,7 +66,7 @@ def prepare_install(): print("get config...") conf = cfg.ConfigOpts() parse(conf, sys.argv[1:]) - host_interface_map, hosts_name, network_map, vip = \ + host_interface_map, hosts_name, network_map, vip, ceph_disk_name = \ get_conf.config(conf['dha'], conf['network']) if conf['cluster'] and conf['cluster'] == 'yes': print("add cluster...") @@ -88,6 +88,14 @@ def prepare_install(): cluster_id = cluster_info.id add_hosts_interface(cluster_id, hosts_info, hosts_name, host_interface_map, vip) + if len(hosts_name) == 1: + protocol_type = 'LVM' + elif len(hosts_name) > 2: + protocol_type = 'CEPH' + else: + print('hosts_num is %s' % len(hosts_name)) + protocol_type = None + enable_cinder_backend(cluster_id, ceph_disk_name, protocol_type) if 'isbare' in conf and conf['isbare'] == 0: install_os_for_vm_step1(cluster_id) else: @@ -117,9 +125,7 @@ def install_os_for_vm_step1(cluster_id): def install_os_for_bm_oneshot(cluster_id): - cluster_meta = {'cluster_id': cluster_id, - 'pxe_only': "false", - 'skip_pxe_ipmi': "false"} + cluster_meta = {'cluster_id': cluster_id} client.install.install(**cluster_meta) @@ -217,5 +223,22 @@ def add_host_role(cluster_id, host_id, host_exp_name, host_real_name, vip): client.roles.update(computer_role_id, **role_computer_update_meta) +def enable_cinder_backend(cluster_id, disk_name, protocol_type): + role_meta = {'filters': {'cluster_id': cluster_id}} + role_list_generator = client.roles.list(**role_meta) + role_list = [role for role in role_list_generator] + lb_role_id = [role.id for role in role_list if + role.name == "CONTROLLER_LB"][0] + service_disk_meta = {'service': 'cinder', + 'disk_location': 'local', + 'partition': disk_name, + 'protocol_type': protocol_type, + 'role_id': lb_role_id} + try: + client.disk_array.service_disk_add(**service_disk_meta) + except Exception as e: + print e + + if __name__ == "__main__": prepare_install() diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/requirements.txt diff --git a/setup.py b/setup.py new file mode 100644 index 00000000..d556de77 --- /dev/null +++ b/setup.py @@ -0,0 +1,9 @@ +#!/usr/bin/env python + +from setuptools import setup + +setup( + name="daisy", + version="master", + url="https://www.opnfv.org", +) diff --git a/test-requirements.txt b/test-requirements.txt new file mode 100644 index 00000000..0483907e --- /dev/null +++ b/test-requirements.txt @@ -0,0 +1,5 @@ +pytest +pytest-cov +pytest-faker +pytest-mock + diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/tests/__init__.py diff --git a/tests/unit/__init__.py b/tests/unit/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/tests/unit/__init__.py diff --git a/tests/unit/test_placeholder.py b/tests/unit/test_placeholder.py new file mode 100644 index 00000000..457e464c --- /dev/null +++ b/tests/unit/test_placeholder.py @@ -0,0 +1,2 @@ +def test_holder(): + assert True diff --git a/tox.ini b/tox.ini new file mode 100644 index 00000000..28fbf8f5 --- /dev/null +++ b/tox.ini @@ -0,0 +1,42 @@ +# Tox (http://tox.testrun.org/) is a tool for running tests +# in multiple virtualenvs. This configuration file will run the +# test suite on all supported python versions. To use it, "pip install tox" +# and then run "tox" from this directory. + +[tox] +envlist = py27,pep8 +skipsdist = True + +[testenv] +usedevelop = True +install_command = pip install -U {opts} {packages} +deps = + -rrequirements.txt + -rtest-requirements.txt +commands= + py.test \ + --basetemp={envtmpdir} \ + --cov \ + --cov-report term-missing \ + --cov-report xml \ + {posargs} +setenv= + HOME = {envtmpdir} + PYTHONPATH = {toxinidir} + +[testenv:pep8] +deps = flake8 +commands = flake8 {toxinidir} + +[flake8] +# H803 skipped on purpose per list discussion. +# E123, E125 skipped as they are invalid PEP-8. + +show-source = True +ignore = E123,E125,H803,E501 +builtins = _ +exclude = build,dist,doc,legacy,.eggs,.git,.tox,.venv + +[pytest] +testpaths = tests +python_functions = test_* |