├── .gitignore ├── Dockerfile ├── LICENSE ├── README.md ├── check-basic-services.yaml ├── check-ceph-status.yaml ├── check-openstack-services.yaml ├── inventory ├── regionone └── regionone_hosts ├── osop ├── ping-local.yaml ├── restart-cinder-service.yaml ├── restart-glance-service.yaml ├── restart-haproxy.yaml ├── restart-httpd.yaml ├── restart-memcache.yaml ├── restart-neutron-server.yaml ├── restart-nova-api-scheduler-conductor.yaml ├── restart-nova-compute.yaml ├── screenshot.png ├── test-boot-vm.sh ├── test-boot-vm.yaml ├── test-create-volume.sh ├── test-create-volume.yaml ├── todo ├── update-admin-quota.sh ├── update-admin-quota.yaml └── vendor └── dialog-1.1-9.20080819.1.el6.x86_64.rpm /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | env/ 12 | build/ 13 | develop-eggs/ 14 | dist/ 15 | downloads/ 16 | eggs/ 17 | .eggs/ 18 | lib/ 19 | lib64/ 20 | parts/ 21 | sdist/ 22 | var/ 23 | *.egg-info/ 24 | .installed.cfg 25 | *.egg 26 | 27 | # PyInstaller 28 | # Usually these files are written by a python script from a template 29 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 30 | *.manifest 31 | *.spec 32 | 33 | # Installer logs 34 | pip-log.txt 35 | pip-delete-this-directory.txt 36 | 37 | # Unit test / coverage reports 38 | htmlcov/ 39 | .tox/ 40 | .coverage 41 | .coverage.* 42 | .cache 43 | nosetests.xml 44 | coverage.xml 45 | *,cover 46 | .hypothesis/ 47 | 48 | # Translations 49 | *.mo 50 | *.pot 51 | 52 | # Django stuff: 53 | *.log 54 | 55 | # Sphinx documentation 56 | docs/_build/ 57 | 58 | # PyBuilder 59 | target/ 60 | 61 | #Ipython Notebook 62 | .ipynb_checkpoints 63 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM python:3 2 | MAINTAINER tobe tobeg3oogle@gmail.com 3 | 4 | RUN pip install ansible 5 | 6 | Add . /osop 7 | 8 | CMD bash 9 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 tobe 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # OSOP 2 | 3 | ## Introduction 4 | 5 | OSOP is short for OpenStack Operation toolkits. 6 | 7 | ## Installation 8 | 9 | Install ansible. 10 | 11 | ``` 12 | pip install -U ansible 13 | 14 | yum install ncurses 15 | ``` 16 | 17 | Install osop. 18 | 19 | ``` 20 | git clone https://github.com/tobegit3hub/osop.git 21 | 22 | mv ./osop /root/ 23 | 24 | # Edit regionone_hosts and region 25 | ls -s /root/osop/regionone /bin/ 26 | ``` 27 | 28 | ## Usage 29 | 30 | Run commands with ncurses. 31 | 32 | ``` 33 | regiononej 34 | ``` 35 | 36 | Run commands in cluster or nodes. 37 | 38 | ``` 39 | ansible -i region_hosts api1 -m shell -a "ping -c 1 -W 1 127.0.0.1" 40 | ``` 41 | 42 | Run playbooks in cluster or nodes. 43 | 44 | ``` 45 | ansible-playbook -i region_hosts ping-local.yaml 46 | ``` 47 | 48 | ## Screenshot 49 | 50 | ![](./screenshot.png) 51 | 52 | ## Developer 53 | 54 | * yifan 55 | * tobe 56 | -------------------------------------------------------------------------------- /check-basic-services.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | - hosts: lb1 3 | gather_facts: no 4 | tasks: 5 | - name: 通过Pacemaker获取Vip状态 6 | register: vip_status 7 | shell: pcs status | grep vip | grep -E "FAILED|Stopped" | wc -l 8 | 9 | - fail: msg = "判断Vip状态是否异常" 10 | when: vip_status.stdout.strip() > '0' 11 | 12 | - hosts: lb 13 | gather_facts: no 14 | tasks: 15 | - name: 通过Systemd检查Haproxy状态 16 | register: haproxy_status 17 | shell: systemctl status haproxy | grep Active | awk '{print $2}' 18 | 19 | - fail: msg = "判断Haproxy状态是否异常" 20 | when: haproxy_status.stdout != "active" 21 | 22 | - hosts: mc 23 | gather_facts: no 24 | tasks: 25 | - name: 通过Systemd检查Memcache状态 26 | register: memcache_status 27 | shell: systemctl status memcached | grep Active | awk '{print $2}' 28 | 29 | - fail: msg = "判断Memcache状态是否异常" 30 | when: memcache_status.stdout != "active" 31 | 32 | - hosts: mq 33 | gather_facts: no 34 | tasks: 35 | - name: 通过Systemd检查Rabbitmq状态 36 | register: rabbitmq_status 37 | shell: systemctl status rabbitmq-server | grep Active | awk '{print $2}' 38 | 39 | - fail: msg = "判断Rabbitmq状态是否异常" 40 | when: rabbitmq_status.stdout != "active" 41 | 42 | - hosts: db1 43 | gather_facts: no 44 | tasks: 45 | - name: 通过Pacemaker获取MySQL状态 46 | register: mysql_status 47 | shell: pcs status | grep mysql | grep -E "FAILED|Stopped" | wc -l 48 | 49 | - fail: msg = "判断MySQL状态是否异常" 50 | when: mysql_status.stdout.strip() > '0' -------------------------------------------------------------------------------- /check-ceph-status.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | - hosts: api1 3 | gather_facts: no 4 | tasks: 5 | - name: 获取Ceph状态 6 | register: ceph_status 7 | shell: ceph -s | grep health | awk '{print $2}' 8 | 9 | - fail: msg = "Ceph状态异常" 10 | when: ceph_status.stdout != "HEALTH_OK" 11 | -------------------------------------------------------------------------------- /check-openstack-services.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | - hosts: api1 3 | gather_facts: no 4 | tasks: 5 | - name: 获取Nova service-list状态 6 | register: nova_service_status 7 | shell: nova service-list | awk '{print $12}' | grep -v State | grep -v ^$ | grep down | wc -l 8 | 9 | - fail: msg = "判断Nova service-list状态是否异常" 10 | when: nova_service_status.stdout.strip() > '0' 11 | 12 | - name: 获取Neutron agent-list状态 13 | register: neutron_service_status 14 | shell: agent-list | awk -F '|' '{print $5}' | grep -v ^$ | grep -v alive | grep xxx | wc -l 15 | 16 | - fail: msg = "判断Neutron agent-list状态是否异常" 17 | when: neutron_service_status.stdout.strip() > '0' 18 | 19 | - name: 获取Cinder service-list状态 20 | register: cinder_service_status 21 | shell: cinder service-list | grep enabled | grep down | wc -l 22 | 23 | - fail: msg = "判断Cinder service-list状态是否异常" 24 | when: cinder_service_status.stdout.strip() > '0' 25 | 26 | - name: 通过Pacemake检查Cinder服务 27 | register: pcs_cinder_status 28 | shell: pcs status | grep -E "FAILED|Stopped" | wc -l 29 | 30 | - fail: msg = "判断Pacemaker检查Cinder状态是否异常" 31 | when: pcs_cinder_status.stdout.strip() > '0' 32 | -------------------------------------------------------------------------------- /inventory/regionone: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Contant variables 4 | export REGION_NAME="RegionOne" 5 | export HOST_FILE="/root/osop/region_hosts" 6 | export ROLE_DIR="/root/osop" 7 | 8 | /root/osop/osop 9 | -------------------------------------------------------------------------------- /inventory/regionone_hosts: -------------------------------------------------------------------------------- 1 | [compute] 2 | 55.17.52.[1:30] 3 | 4 | [api1] 5 | 55.22.56.105 6 | 7 | [lb] 8 | 55.22.[56:57].101 9 | 55.22.56.102 10 | 11 | [api] 12 | 55.22.[56:57].105 13 | 55.22.56.106 14 | 15 | [db] 16 | 55.22.[56:57].135 17 | 55.22.56.136 18 | 19 | [mq] 20 | 55.22.[56:57].125 21 | 55.22.56.126 22 | 23 | [mc] 24 | 55.22.[56:57].131 25 | 26 | [mon] 27 | 55.17.52.1 28 | 55.17.52.11 29 | 55.17.52.21 30 | 31 | [dhcp] 32 | 55.17.52.2 33 | 55.17.52.12 34 | 35 | [puppet] 36 | 55.17.52.2 37 | 55.17.52.12 38 | 39 | [hyper] 40 | 55.22.[56:57].1 41 | 55.22.56.11 42 | -------------------------------------------------------------------------------- /osop: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Add these in each region 4 | # export REGION_NAME="RegionOne" 5 | # export HOST_FILE="/root/osop/regionone_hosts" 6 | # export ROLE_DIR="/root/osop" 7 | 8 | # Contant variables 9 | DIALOG_CANCEL=1 10 | DIALOG_ESC=255 11 | HEIGHT=0 12 | WIDTH=0 13 | 14 | display_confirm_dialog() { 15 | # $1 command name 16 | if dialog --backtitle $REGION_NAME --yesno "Please confirm again?" $HEIGHT $WIDTH 17 | then 18 | clear 19 | echo $1 20 | eval $1 21 | exit 22 | else 23 | clear 24 | echo "Cancel the command." 25 | exit 26 | fi 27 | } 28 | 29 | while true; do 30 | exec 3>&1 31 | selection=$(dialog \ 32 | --backtitle $REGION_NAME \ 33 | --clear \ 34 | --cancel-label "Exit" \ 35 | --menu "Please select:" $HEIGHT $WIDTH 0 \ 36 | "1" "检查Ceph状态" \ 37 | "2" "检查基础服务状态" \ 38 | "3" "检查OpenStack服务状态" \ 39 | "4" "测试创建云硬盘" \ 40 | "5" "测试创建虚拟机" \ 41 | "6" "重启Httpd服务" \ 42 | "7" "重启Memcache服务" \ 43 | "8" "重启Haproxy服务" \ 44 | "9" "重启Glance服务" \ 45 | "10" "重启Cinder服务" \ 46 | "11" "重启neutron-server服务" \ 47 | "12" "重启API节点Nova服务" \ 48 | "13" "重启nova-compute服务" \ 49 | 2>&1 1>&3) 50 | exit_status=$? 51 | exec 3>&- 52 | case $exit_status in 53 | $DIALOG_CANCEL) 54 | clear 55 | echo "Program terminated." 56 | exit 57 | ;; 58 | $DIALOG_ESC) 59 | clear 60 | echo "Program aborted." >&2 61 | exit 1 62 | ;; 63 | esac 64 | 65 | case $selection in 66 | 0 ) 67 | clear 68 | echo "Program terminated." 69 | ;; 70 | 1 ) 71 | YAML_FILE="check-ceph-status.yaml" 72 | ;; 73 | 2 ) 74 | YAML_FILE="check-basic-services.yaml" 75 | ;; 76 | 3 ) 77 | YAML_FILE="check-openstack-services.yaml" 78 | ;; 79 | 4 ) 80 | YAML_FILE="test-create-volume.yaml" 81 | ;; 82 | 5 ) 83 | YAML_FILE="test-boot-vm.yaml" 84 | ;; 85 | 6 ) 86 | YAML_FILE="restart-httpd.yaml" 87 | ;; 88 | 7 ) 89 | YAML_FILE="restart-memcache.yaml" 90 | ;; 91 | 8 ) 92 | YAML_FILE="restart-haproxy.yaml" 93 | ;; 94 | 9 ) 95 | YAML_FILE="restart-glance-service.yaml" 96 | ;; 97 | 10 ) 98 | YAML_FILE="restart-cinder-service.yaml" 99 | ;; 100 | 11 ) 101 | YAML_FILE="restart-neutron-server.yaml" 102 | ;; 103 | 12 ) 104 | YAML_FILE="restart-nova-api-scheduler-conductor.yaml" 105 | ;; 106 | 13 ) 107 | YAML_FILE="restart-nova-compute.yaml" 108 | ;; 109 | esac 110 | display_confirm_dialog "ansible-playbook -vvv -i $HOST_FILE $ROLE_DIR/$YAML_FILE" 111 | 112 | done 113 | 114 | -------------------------------------------------------------------------------- /ping-local.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | - hosts: api 3 | gather_facts: no 4 | tasks: 5 | - name: 测试能否Ping本地 6 | command: ping -c 1 -W 1 127.0.0.1 7 | -------------------------------------------------------------------------------- /restart-cinder-service.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | - hosts: api1 3 | gather_facts: no 4 | tasks: 5 | - name: 重启cinder-api 6 | command: pcs resource restart openstack-cinder-api 7 | - name: 重启cinder-scheduler 8 | command: pcs resource restart openstack-cinder-scheduler 9 | - name: 重启cinder-volume 10 | command: pcs resource restart openstack-cinder-volume 11 | -------------------------------------------------------------------------------- /restart-glance-service.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | - hosts: api 3 | gather_facts: no 4 | tasks: 5 | - name: 重启glance-api 6 | command: systemctl restart openstack-glance-api 7 | - name: 重启glance-registry 8 | command: systemctl restart openstack-glance-registry 9 | -------------------------------------------------------------------------------- /restart-haproxy.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | - hosts: lb 3 | gather_facts: no 4 | tasks: 5 | - name: 重启haproxy服务 6 | command: systemctl restart haproxy 7 | -------------------------------------------------------------------------------- /restart-httpd.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | - hosts: api 3 | gather_facts: no 4 | tasks: 5 | - name: 重启httpd服务 6 | command: systemctl restart httpd 7 | -------------------------------------------------------------------------------- /restart-memcache.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | - hosts: mc 3 | gather_facts: no 4 | tasks: 5 | - name: 重启memcache服务 6 | command: systemctl restart memcached 7 | -------------------------------------------------------------------------------- /restart-neutron-server.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | - hosts: api 3 | gather_facts: no 4 | tasks: 5 | - name: 重启neutron-server 6 | command: systemctl restart neutron-server 7 | -------------------------------------------------------------------------------- /restart-nova-api-scheduler-conductor.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | - hosts: api 3 | gather_facts: no 4 | tasks: 5 | - name: 重启nova-api 6 | command: systemctl restart openstack-nova-api 7 | - name: 重启nova-scheduler 8 | command: systemctl restart openstack-nova-scheduler 9 | - name: 重启nova-conductor 10 | command: systemctl restart openstack-nova-conductor 11 | -------------------------------------------------------------------------------- /restart-nova-compute.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | - hosts: comp 3 | gather_facts: no 4 | tasks: 5 | - name: 重启openstack-nova-compute服务 6 | command: systemctl restart openstack-nova-compute 7 | -------------------------------------------------------------------------------- /screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tobegit3hub/osop/44f6cb2cbe596120ab9d98d35a139e2142e79a95/screenshot.png -------------------------------------------------------------------------------- /test-boot-vm.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -x 4 | set -e 5 | 6 | # Get resource ids 7 | image_id=`glance image-list | grep 'cirro' | awk '{print $2}'` 8 | flavor_id=`nova flavor-list | grep "standard-1" | awk '{print $2}'` 9 | net_id=`neutron net-create osop-test-net | grep "\ id\ " | awk '{print $4}'` 10 | subnet_id=`neutron subnet-create $net_id "192.168.0.0/24" | grep "\ id\ " | awk '{print $4}'` 11 | 12 | # Boot instance 13 | #nova boot --image 4ad99265-1b00-4446-a602-863bb07caef6 --flavor d240156f-4414-4dc0-8a11-dc0c5e690e5c --nic net-id=298a065e-5a33-4aa6-aaa5-904d2413f1aa --availability_zone module_A --poll tobe-test-1 14 | nova boot --image $image_id --flavor $flavor_id --nic net-id=$net_id --poll osop-test-vm 15 | 16 | # Cleanup resources 17 | nova_id=`nova list | grep "osop-test-vm" | awk '{print $2}'` 18 | nova delete $nova_id 19 | 20 | sleep 30 21 | neutron subnet-delete $subnet_id 22 | 23 | sleep 10 24 | neutron net-delete $net_id 25 | -------------------------------------------------------------------------------- /test-boot-vm.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | - hosts: api1 3 | gather_facts: no 4 | tasks: 5 | - name: 拷贝创建虚拟机脚本 6 | copy: 7 | src: ./test-boot-vm.sh 8 | dest: /tmp/test-boot-vm.sh 9 | owner: root 10 | group: root 11 | mode: 0755 12 | - name: 测试能否创建虚拟机 13 | command: /tmp/test-boot-vm.sh 14 | -------------------------------------------------------------------------------- /test-create-volume.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -x 4 | set -e 5 | 6 | # Create volume 7 | volume_id=`cinder create 1 --name osop-test-volume | grep "\ id\ " | awk '{print $4}'` 8 | 9 | # Clean volume 10 | cinder delete $volume_id 11 | -------------------------------------------------------------------------------- /test-create-volume.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | - hosts: api1 3 | gather_facts: no 4 | tasks: 5 | - name: 拷贝创建云硬盘脚本 6 | copy: 7 | src: ./test-create-volume.sh 8 | dest: /tmp/test-create-volume.sh 9 | owner: root 10 | group: root 11 | mode: 0755 12 | - name: 测试能否创建云硬盘 13 | command: /tmp/test-create-volume.sh 14 | -------------------------------------------------------------------------------- /todo: -------------------------------------------------------------------------------- 1 | 2 | # Check 3 | 4 | 5 | * ceph -s, rados -p openstack-00 ls 6 | 7 | * pcs status --full(haproxy, vip) 8 | 9 | * mysql 10 | 11 | * rabbitmq(cluster_status, list_queues) 12 | 13 | * nova(service list) 14 | * keystone 15 | * cinder 16 | * neutron(agent list) 17 | 18 | 19 | 20 | 21 | 22 | # oprations 23 | 24 | * 创建cinder卷 25 | 26 | 27 | -------------------------------------------------------------------------------- /update-admin-quota.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -x 4 | set -e 5 | 6 | # Get admin tenant id 7 | admin_tenant_name=`cat /root/openrc | grep "TENANT_NAME" | awk -F "=" '{print $2}'` 8 | admin_tenant_id=`openstack project list | grep $admin_tenant_name | awk '{print $2}'` 9 | 10 | # Update nova quota 11 | nova quota-update --instances -1 --cores -1 --ram -1 --force $admin_tenant_id 12 | 13 | # Update cinder quota 14 | cinder quota-update --volumes -1 --snapshots -1 --gigabytes -1 $admin_tenant_id 15 | 16 | # Update neutron quota 17 | neutron quota-update --network -1 --subnet -1 --port -1 --tenant-id $admin_tenant_id 18 | -------------------------------------------------------------------------------- /update-admin-quota.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | - hosts: api1 3 | gather_facts: no 4 | tasks: 5 | - name: 拷贝update-admin-quota.sh脚本 6 | copy: 7 | src: ./update-admin-quota.sh 8 | dest: /tmp/update-admin-quota.sh 9 | owner: root 10 | group: root 11 | mode: 0755 12 | - name: 修改admin租户的quota 13 | command: /tmp/update-admin-quota.sh 14 | -------------------------------------------------------------------------------- /vendor/dialog-1.1-9.20080819.1.el6.x86_64.rpm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tobegit3hub/osop/44f6cb2cbe596120ab9d98d35a139e2142e79a95/vendor/dialog-1.1-9.20080819.1.el6.x86_64.rpm --------------------------------------------------------------------------------