├── ku.stella ├── tests │ ├── __init__.py │ ├── base.py │ └── test_ku.stella.py ├── clouds.yaml ├── insert_sla.sh ├── __init__.py ├── README.md ├── connect_openstack.py └── Stella-OpenStack.py ├── releasenotes ├── notes │ └── .placeholder └── source │ ├── _static │ └── .placeholder │ ├── _templates │ └── .placeholder │ ├── unreleased.rst │ ├── index.rst │ └── conf.py ├── babel.cfg ├── doc ├── source │ ├── readme.rst │ ├── user │ │ └── index.rst │ ├── reference │ │ └── index.rst │ ├── configuration │ │ └── index.rst │ ├── contributor │ │ ├── contributing.rst │ │ └── index.rst │ ├── library │ │ └── index.rst │ ├── admin │ │ └── index.rst │ ├── cli │ │ └── index.rst │ ├── install │ │ ├── next-steps.rst │ │ ├── get_started.rst │ │ ├── common_configure.rst │ │ ├── index.rst │ │ ├── verify.rst │ │ ├── install.rst │ │ ├── install-ubuntu.rst │ │ ├── install-rdo.rst │ │ ├── install-obs.rst │ │ └── common_prerequisites.rst │ ├── index.rst │ └── conf.py └── requirements.txt ├── .zuul.yaml ├── .stestr.conf ├── .coveragerc ├── .gitreview ├── .mailmap ├── HACKING.rst ├── requirements.txt ├── JBNUscripts ├── block-ip-all-project.sh ├── find-cpu-spinning-all.sh ├── compute-reload.sh ├── find-cpu-spinning-single-node.sh ├── backup-snapshot.sh └── nat-portforwarding.sh ├── test-requirements.txt ├── CONTRIBUTING.rst ├── setup.cfg ├── setup.py ├── .gitignore ├── README.rst ├── tox.ini └── LICENSE /ku.stella/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /releasenotes/notes/.placeholder: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /babel.cfg: -------------------------------------------------------------------------------- 1 | [python: **.py] 2 | 3 | -------------------------------------------------------------------------------- /releasenotes/source/_static/.placeholder: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /releasenotes/source/_templates/.placeholder: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /doc/source/readme.rst: -------------------------------------------------------------------------------- 1 | .. include:: ../../README.rst 2 | -------------------------------------------------------------------------------- /.zuul.yaml: -------------------------------------------------------------------------------- 1 | - project: 2 | templates: 3 | - noop-jobs 4 | -------------------------------------------------------------------------------- /.stestr.conf: -------------------------------------------------------------------------------- 1 | [DEFAULT] 2 | test_path=./ku.stella/tests 3 | top_dir=./ 4 | -------------------------------------------------------------------------------- /.coveragerc: -------------------------------------------------------------------------------- 1 | [run] 2 | branch = True 3 | source = ku.stella 4 | 5 | [report] 6 | ignore_errors = True 7 | -------------------------------------------------------------------------------- /.gitreview: -------------------------------------------------------------------------------- 1 | [gerrit] 2 | host=review.openstack.org 3 | port=29418 4 | project=openstack/ku.stella.git 5 | -------------------------------------------------------------------------------- /doc/source/user/index.rst: -------------------------------------------------------------------------------- 1 | =========== 2 | Users guide 3 | =========== 4 | 5 | Users guide of ku.stella. 6 | -------------------------------------------------------------------------------- /.mailmap: -------------------------------------------------------------------------------- 1 | # Format is: 2 | # 3 | # 4 | -------------------------------------------------------------------------------- /doc/source/reference/index.rst: -------------------------------------------------------------------------------- 1 | ========== 2 | References 3 | ========== 4 | 5 | References of ku.stella. 6 | -------------------------------------------------------------------------------- /doc/source/configuration/index.rst: -------------------------------------------------------------------------------- 1 | ============= 2 | Configuration 3 | ============= 4 | 5 | Configuration of ku.stella. 6 | -------------------------------------------------------------------------------- /doc/source/contributor/contributing.rst: -------------------------------------------------------------------------------- 1 | ============ 2 | Contributing 3 | ============ 4 | .. include:: ../../../CONTRIBUTING.rst 5 | -------------------------------------------------------------------------------- /doc/source/library/index.rst: -------------------------------------------------------------------------------- 1 | ======== 2 | Usage 3 | ======== 4 | 5 | To use ku.stella in a project:: 6 | 7 | import ku.stella 8 | -------------------------------------------------------------------------------- /doc/source/admin/index.rst: -------------------------------------------------------------------------------- 1 | ==================== 2 | Administrators guide 3 | ==================== 4 | 5 | Administrators guide of ku.stella. 6 | -------------------------------------------------------------------------------- /releasenotes/source/unreleased.rst: -------------------------------------------------------------------------------- 1 | ============================== 2 | Current Series Release Notes 3 | ============================== 4 | 5 | .. release-notes:: 6 | -------------------------------------------------------------------------------- /doc/source/cli/index.rst: -------------------------------------------------------------------------------- 1 | ================================ 2 | Command line interface reference 3 | ================================ 4 | 5 | CLI reference of ku.stella. 6 | -------------------------------------------------------------------------------- /HACKING.rst: -------------------------------------------------------------------------------- 1 | ku.stella Style Commandments 2 | =============================================== 3 | 4 | Read the OpenStack Style Commandments https://docs.openstack.org/hacking/latest/ 5 | -------------------------------------------------------------------------------- /doc/requirements.txt: -------------------------------------------------------------------------------- 1 | # This work is done by Operating System Labs. 2 | sphinx!=1.6.6,!=1.6.7,>=1.6.2 # BSD 3 | openstackdocstheme>=1.18.1 # Apache-2.0 4 | # releasenotes 5 | reno>=2.5.0 # Apache-2.0 6 | -------------------------------------------------------------------------------- /doc/source/contributor/index.rst: -------------------------------------------------------------------------------- 1 | =========================== 2 | Contributor Documentation 3 | =========================== 4 | 5 | .. toctree:: 6 | :maxdepth: 2 7 | 8 | contributing 9 | 10 | -------------------------------------------------------------------------------- /releasenotes/source/index.rst: -------------------------------------------------------------------------------- 1 | ============================================ 2 | ku.stella Release Notes 3 | ============================================ 4 | 5 | .. toctree:: 6 | :maxdepth: 1 7 | 8 | unreleased 9 | -------------------------------------------------------------------------------- /doc/source/install/next-steps.rst: -------------------------------------------------------------------------------- 1 | .. _next-steps: 2 | 3 | Next steps 4 | ~~~~~~~~~~ 5 | 6 | Your OpenStack environment now includes the ku.stella service. 7 | 8 | To add additional services, see 9 | https://docs.openstack.org/project-install-guide/ocata/. 10 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | # The order of packages is significant, because pip processes them in the order 2 | # of appearance. Changing the order has an impact on the overall integration 3 | # process, which may cause wedges in the gate later. 4 | # This work is done by Operating System labs. 5 | 6 | pbr>=2.0 # Apache-2.0 7 | -------------------------------------------------------------------------------- /doc/source/install/get_started.rst: -------------------------------------------------------------------------------- 1 | ========================== 2 | ku.stella service overview 3 | ========================== 4 | The ku.stella service provides... 5 | 6 | The ku.stella service consists of the following components: 7 | 8 | ``ku.stella-api`` service 9 | Accepts and responds to end user compute API calls... 10 | -------------------------------------------------------------------------------- /ku.stella/clouds.yaml: -------------------------------------------------------------------------------- 1 | clouds: 2 | Stella: 3 | auth: 4 | auth_url: http://Controller:5000 5 | password: ADMIN_PASS 6 | project_domain_id: default 7 | project_name: admin 8 | user_domain_id: default 9 | username: admin 10 | identity_api_version: '3' 11 | region_name: RegionOne 12 | volume_api_version: '2' 13 | -------------------------------------------------------------------------------- /doc/source/install/common_configure.rst: -------------------------------------------------------------------------------- 1 | 2. Edit the ``/etc/ku.stella/ku.stella.conf`` file and complete the following 2 | actions: 3 | 4 | * In the ``[database]`` section, configure database access: 5 | 6 | .. code-block:: ini 7 | 8 | [database] 9 | ... 10 | connection = mysql+pymysql://ku.stella:KU.STELLA_DBPASS@controller/ku.stella 11 | -------------------------------------------------------------------------------- /JBNUscripts/block-ip-all-project.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 지금까지 194.163.182.183, 51.89.217.80, 186.195.132.204 185.167.96.138 178.154.224.45 155.159.120.74 차단됨 3 | ip="43.131.43.132" # 여기에 차단할 IP 주소 넣고 실행 4 | routers=$(sudo ip netns list | grep router | awk '{ print $1 }') 5 | for router in $routers 6 | do 7 | sudo ip netns exec $router iptables -I FORWARD 1 -s $ip -d 0.0.0.0/0 -j DROP 8 | sudo ip netns exec $router iptables -L 9 | 10 | done 11 | -------------------------------------------------------------------------------- /JBNUscripts/find-cpu-spinning-all.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | servers="com01 com02 com03 gpu01 gpu02" 3 | result="" 4 | for server in $servers 5 | do 6 | 7 | temp=`sshpass -p 0slab ssh $server -tt -p 3932 < ~/find-cpu-spinning-single-node.sh | sed -n '/^'$server'/p'` 8 | result="$result$temp" 9 | 10 | done 11 | TZ=Asia/Seoul date 12 | printf "%-10s\t%-10s\t%-17s\t%-36s\t%-30s\t%-20s\t%s\n" "HOSTNAME" "%CPU" "NAME" "UUID" "NOVA:NAME" "USER" "PROJECT" 13 | echo "$result" 14 | -------------------------------------------------------------------------------- /doc/source/install/index.rst: -------------------------------------------------------------------------------- 1 | ==================================== 2 | ku.stella service installation guide 3 | ==================================== 4 | 5 | .. toctree:: 6 | :maxdepth: 2 7 | 8 | get_started.rst 9 | install.rst 10 | verify.rst 11 | next-steps.rst 12 | 13 | The ku.stella service (ku.stella) provides... 14 | 15 | This chapter assumes a working setup of OpenStack following the 16 | `OpenStack Installation Tutorial 17 | `_. 18 | -------------------------------------------------------------------------------- /test-requirements.txt: -------------------------------------------------------------------------------- 1 | # The order of packages is significant, because pip processes them in the order 2 | # of appearance. Changing the order has an impact on the overall integration 3 | # process, which may cause wedges in the gate later. 4 | # This work is done by Operating System Labs. 5 | 6 | hacking>=0.12.0,<0.13 # Apache-2.0 7 | 8 | coverage>=4.0,!=4.4 # Apache-2.0 9 | python-subunit>=0.0.18 # Apache-2.0/BSD 10 | oslotest>=1.10.0 # Apache-2.0 11 | stestr>=1.0.0 # Apache-2.0 12 | testtools>=1.4.0 # MIT 13 | -------------------------------------------------------------------------------- /doc/source/install/verify.rst: -------------------------------------------------------------------------------- 1 | .. _verify: 2 | 3 | Verify operation 4 | ~~~~~~~~~~~~~~~~ 5 | 6 | Verify operation of the ku.stella service. 7 | 8 | .. note:: 9 | 10 | Perform these commands on the controller node. 11 | 12 | #. Source the ``admin`` project credentials to gain access to 13 | admin-only CLI commands: 14 | 15 | .. code-block:: console 16 | 17 | $ . admin-openrc 18 | 19 | #. List service components to verify successful launch and registration 20 | of each process: 21 | 22 | .. code-block:: console 23 | 24 | $ openstack ku.stella service list 25 | -------------------------------------------------------------------------------- /doc/source/install/install.rst: -------------------------------------------------------------------------------- 1 | .. _install: 2 | 3 | Install and configure 4 | ~~~~~~~~~~~~~~~~~~~~~ 5 | 6 | This section describes how to install and configure the 7 | ku.stella service, code-named ku.stella, on the controller node. 8 | 9 | This section assumes that you already have a working OpenStack 10 | environment with at least the following components installed: 11 | .. (add the appropriate services here and further notes) 12 | 13 | Note that installation and configuration vary by distribution. 14 | 15 | .. toctree:: 16 | :maxdepth: 2 17 | 18 | install-obs.rst 19 | install-rdo.rst 20 | install-ubuntu.rst 21 | -------------------------------------------------------------------------------- /CONTRIBUTING.rst: -------------------------------------------------------------------------------- 1 | If you would like to contribute to the development of OpenStack, you must 2 | follow the steps in this page: 3 | 4 | http://docs.openstack.org/infra/manual/developers.html 5 | 6 | If you already have a good understanding of how the system works and your 7 | OpenStack accounts are set up, you can skip to the development workflow 8 | section of this documentation to learn how changes to OpenStack should be 9 | submitted for review via the Gerrit tool: 10 | 11 | http://docs.openstack.org/infra/manual/developers.html#development-workflow 12 | 13 | Pull requests submitted through GitHub will be ignored. 14 | 15 | Bugs should be filed on Launchpadhttps://bugs.launchpad.net/KU.stella -------------------------------------------------------------------------------- /JBNUscripts/compute-reload.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo "systemctl stop nova-compute.service" 3 | systemctl stop nova-compute.service 4 | echo "systemctl stop neutron-linuxbridge-*" 5 | systemctl stop neutron-linuxbridge-agent.service 6 | systemctl stop neutron-linuxbridge-cleanup.service 7 | 8 | sleep 2 9 | 10 | echo "systemctl start nova-compute.service" 11 | systemctl start nova-compute.service 12 | echo "systemctl start neutron-linuxbridge-*" 13 | systemctl start neutron-linuxbridge-agent.service 14 | systemctl start neutron-linuxbridge-cleanup.service 15 | 16 | sleep 1 17 | 18 | systemctl status nova-compute.service 19 | systemctl status neutron-linuxbridge-agent.service 20 | systemctl status neutron-linuxbridge-cleanup.service 21 | -------------------------------------------------------------------------------- /ku.stella/insert_sla.sh: -------------------------------------------------------------------------------- 1 | vm=$1 2 | sla_option=$2 3 | sla_value=$3 4 | 5 | count=`expr 0` 6 | pid=$(sudo grep domstatus /var/run/libvirt/qemu/${vm}.xml | tr -dc '0-9') 7 | dev_string=$(virsh dumpxml ${vm} | egrep 'nvme|sd') 8 | name_dev=${dev_string#*\'} 9 | name_dev=${name_dev%\'*} 10 | 11 | if [ ! "${name_dev}"];then 12 | name_dev="null" 13 | fi 14 | 15 | if [ "$2" = "n_maxcredit" ];then 16 | vhost_cmd=$(ps -el | grep vhost | grep ${pid}) 17 | for vhost_pid in ${vhost_cmd} 18 | do 19 | count=`expr ${count} + 1` 20 | 21 | if [ ${count} = 4 ];then 22 | pid=${vhost_pid} 23 | fi 24 | done 25 | #check this command line 26 | #name_dev="null" 27 | fi 28 | 29 | cmd="$1 $2 $3 ${pid} ${name_dev}" 30 | echo ${cmd} > /proc/gos_vm_info 31 | -------------------------------------------------------------------------------- /doc/source/install/install-ubuntu.rst: -------------------------------------------------------------------------------- 1 | .. _install-ubuntu: 2 | 3 | Install and configure for Ubuntu 4 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5 | 6 | This section describes how to install and configure the ku.stella 7 | service for Ubuntu 14.04 (LTS). 8 | 9 | .. include:: common_prerequisites.rst 10 | 11 | Install and configure components 12 | -------------------------------- 13 | 14 | #. Install the packages: 15 | 16 | .. code-block:: console 17 | 18 | # apt-get update 19 | 20 | # apt-get install 21 | 22 | .. include:: common_configure.rst 23 | 24 | Finalize installation 25 | --------------------- 26 | 27 | Restart the ku.stella services: 28 | 29 | .. code-block:: console 30 | 31 | # service openstack-ku.stella-api restart 32 | -------------------------------------------------------------------------------- /doc/source/index.rst: -------------------------------------------------------------------------------- 1 | .. ku.stella documentation master file, created by 2 | sphinx-quickstart on Tue Jul 9 22:26:36 2013. 3 | You can adapt this file completely to your liking, but it should at least 4 | contain the root `toctree` directive. 5 | 6 | ========================================= 7 | Welcome to the documentation of ku.stella 8 | ========================================= 9 | 10 | Contents: 11 | 12 | .. toctree:: 13 | :maxdepth: 2 14 | 15 | readme 16 | install/index 17 | library/index 18 | contributor/index 19 | configuration/index 20 | cli/index 21 | user/index 22 | admin/index 23 | reference/index 24 | 25 | Indices and tables 26 | ================== 27 | 28 | * :ref:`genindex` 29 | * :ref:`modindex` 30 | * :ref:`search` 31 | -------------------------------------------------------------------------------- /ku.stella/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | # not use this file except in compliance with the License. You may obtain 5 | # a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | # This work is done by Operating System Lab 15 | 16 | import pbr.version 17 | 18 | 19 | __version__ = pbr.version.VersionInfo( 20 | 'ku.stella').version_string() 21 | -------------------------------------------------------------------------------- /ku.stella/tests/base.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Copyright 2010-2011 OpenStack Foundation 4 | # Copyright (c) 2013 Hewlett-Packard Development Company, L.P. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); you may 7 | # not use this file except in compliance with the License. You may obtain 8 | # a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 14 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 15 | # License for the specific language governing permissions and limitations 16 | # under the License. 17 | 18 | from oslotest import base 19 | 20 | 21 | class TestCase(base.BaseTestCase): 22 | 23 | """Test case base class for all unit tests.""" 24 | -------------------------------------------------------------------------------- /doc/source/install/install-rdo.rst: -------------------------------------------------------------------------------- 1 | .. _install-rdo: 2 | 3 | Install and configure for Red Hat Enterprise Linux and CentOS 4 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5 | 6 | 7 | This section describes how to install and configure the ku.stella service 8 | for Red Hat Enterprise Linux 7 and CentOS 7. 9 | 10 | .. include:: common_prerequisites.rst 11 | 12 | Install and configure components 13 | -------------------------------- 14 | 15 | #. Install the packages: 16 | 17 | .. code-block:: console 18 | 19 | # yum install 20 | 21 | .. include:: common_configure.rst 22 | 23 | Finalize installation 24 | --------------------- 25 | 26 | Start the ku.stella services and configure them to start when 27 | the system boots: 28 | 29 | .. code-block:: console 30 | 31 | # systemctl enable openstack-ku.stella-api.service 32 | 33 | # systemctl start openstack-ku.stella-api.service 34 | -------------------------------------------------------------------------------- /ku.stella/tests/test_ku.stella.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | # not use this file except in compliance with the License. You may obtain 5 | # a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | 15 | """ 16 | test_ku.stella 17 | ---------------------------------- 18 | 19 | Tests for `ku.stella` module. 20 | """ 21 | 22 | from ku.stella.tests import base 23 | 24 | 25 | class TestKu.stella(base.TestCase): 26 | 27 | def test_something(self): 28 | pass 29 | -------------------------------------------------------------------------------- /doc/source/install/install-obs.rst: -------------------------------------------------------------------------------- 1 | .. _install-obs: 2 | 3 | 4 | Install and configure for openSUSE and SUSE Linux Enterprise 5 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6 | 7 | This section describes how to install and configure the ku.stella service 8 | for openSUSE Leap 42.1 and SUSE Linux Enterprise Server 12 SP1. 9 | 10 | .. include:: common_prerequisites.rst 11 | 12 | Install and configure components 13 | -------------------------------- 14 | 15 | #. Install the packages: 16 | 17 | .. code-block:: console 18 | 19 | # zypper --quiet --non-interactive install 20 | 21 | .. include:: common_configure.rst 22 | 23 | 24 | Finalize installation 25 | --------------------- 26 | 27 | Start the ku.stella services and configure them to start when 28 | the system boots: 29 | 30 | .. code-block:: console 31 | 32 | # systemctl enable openstack-ku.stella-api.service 33 | 34 | # systemctl start openstack-ku.stella-api.service 35 | -------------------------------------------------------------------------------- /JBNUscripts/find-cpu-spinning-single-node.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | stty cols 300 4 | top=`top -bcn 1` 5 | 6 | result=$(echo "$top" | egrep "((\s[0-9][0-9][0-9][0-9]\s\s)|(\s[0-9][0-9][0-9]\.[0-9]\s))" | grep /usr/bin/qemu-system-x86_64 | awk -v OFS=',' '{print $9 , substr($14, 7, 17)}') 7 | hostname=$(hostname) 8 | for row in $result 9 | do 10 | cpu_usage=$(echo $row | awk -F, '{print $1}') 11 | instance=$(echo $row | awk -F, '{print $2}') 12 | uuid=$(virsh dumpxml $instance | grep "" | awk '{print substr($1, 7, 36)}') 13 | name=$(virsh dumpxml $instance | grep nova:name | sed 's/\|<\/nova:name>\| //g') 14 | user=$(virsh dumpxml $instance | grep nova:user | awk '{ print substr($2, 41) }' | sed 's/<\/nova:user>//g') 15 | project=$(virsh dumpxml $instance | grep nova:project | awk '{ print substr($2, 41) }' | sed 's/<\/nova:project>//g') 16 | printf "%-10s\t%-10s\t%-17s\t%-36s\t%-30s\t%-20s\t%s\n" $hostname $cpu_usage $instance $uuid $name $user $project 17 | done 18 | logout 19 | -------------------------------------------------------------------------------- /ku.stella/README.md: -------------------------------------------------------------------------------- 1 | # Stella-OpenStack 2 | This page is Stella-OpenStack code repository. 3 | 4 | Stella-OpenStack support Stella VM scheduler to set performance SLA in OpenStack IaaS clouds. 5 | 6 | Visit our project page for detailed information about Stella project. 7 | 8 | Contect information is below in this README.md file. 9 | 10 | ## Stella-OpenStack APIs 11 | Stella-OpenStack APIs(a.k.s Stella APIs) provide access Stella-OpenStack functions. 12 | 13 | Stella APIs support RestAPI(http based APIs). 14 | 15 | The list of Stella APIs is below. 16 | 17 | 1. /stella: Check the status of Stella scheduler and Stella-OpenStack. 18 | 2. /stella/vms: Returns the list of VMs and information of each VMs. 19 | 3. /stella/vms/sla: Set SLA for VM. Use instance name in horizon as a Input 20 | 4. /stella/hypervisor: Returns the IP address of the hypervisor host. 'hypervisor_name' field is essential. 21 | 22 | ## contact 23 | email: starlab@os.korea.ac.kr 24 | 25 | Stella Project page: http://stella.korea.ac.kr 26 | 27 | GitHub page: https://github.com/KUoslab 28 | -------------------------------------------------------------------------------- /setup.cfg: -------------------------------------------------------------------------------- 1 | [metadata] 2 | name = ku.stella 3 | summary = Stella Cloud project 4 | description-file = 5 | README.rst 6 | author = OpenStack 7 | author-email = openstack-discuss@lists.openstack.org 8 | home-page = http://www.openstack.org/ 9 | classifier = 10 | Environment :: OpenStack 11 | Intended Audience :: Information Technology 12 | Intended Audience :: System Administrators 13 | License :: OSI Approved :: Apache Software License 14 | Operating System :: POSIX :: Linux 15 | Programming Language :: Python 16 | Programming Language :: Python :: 2 17 | Programming Language :: Python :: 2.7 18 | Programming Language :: Python :: 3 19 | Programming Language :: Python :: 3.5 20 | 21 | [files] 22 | packages = 23 | ku.stella 24 | 25 | [compile_catalog] 26 | directory = ku.stella/locale 27 | domain = ku.stella 28 | 29 | [update_catalog] 30 | domain = ku.stella 31 | output_dir = ku.stella/locale 32 | input_file = ku.stella/locale/ku.stella.pot 33 | 34 | [extract_messages] 35 | keywords = _ gettext ngettext l_ lazy_gettext 36 | mapping_file = babel.cfg 37 | output_file = ku.stella/locale/ku.stella.pot 38 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2013 Hewlett-Packard Development Company, L.P. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 12 | # implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | # THIS FILE IS MANAGED BY THE GLOBAL REQUIREMENTS REPO - DO NOT EDIT 17 | import setuptools 18 | 19 | # In python < 2.7.4, a lazy loading of package `pbr` will break 20 | # setuptools if some other modules registered functions in `atexit`. 21 | # solution from: http://bugs.python.org/issue15881#msg170215 22 | # This work is done by Operating System Lab 23 | try: 24 | import multiprocessing # noqa 25 | except ImportError: 26 | pass 27 | 28 | setuptools.setup( 29 | setup_requires=['pbr'], 30 | pbr=True) # for setting pbr 31 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Add patterns in here to exclude files created by tools integrated with this 2 | # repository, such as test frameworks from the project's recommended workflow, 3 | # rendered documentation and package builds. 4 | # 5 | # Don't add patterns to exclude files created by preferred personal tools 6 | # (editors, IDEs, your operating system itself even). These should instead be 7 | # maintained outside the repository, for example in a ~/.gitignore file added 8 | # with: 9 | # 10 | # git config --global core.excludesfile '~/.gitignore' 11 | 12 | # Bytecompiled Python 13 | *.py[cod] 14 | 15 | # C extensions 16 | *.so 17 | 18 | # Packages 19 | *.egg* 20 | *.egg-info 21 | dist 22 | build 23 | eggs 24 | parts 25 | bin 26 | var 27 | sdist 28 | develop-eggs 29 | .installed.cfg 30 | lib 31 | lib64 32 | 33 | # Installer logs 34 | pip-log.txt 35 | 36 | # Unit test / coverage reports 37 | cover/ 38 | .coverage* 39 | !.coveragerc 40 | .tox 41 | nosetests.xml 42 | .testrepository 43 | .stestr 44 | .venv 45 | 46 | # Translations 47 | *.mo 48 | 49 | # Complexity 50 | output/*.html 51 | output/*/index.html 52 | 53 | # Sphinx 54 | doc/build 55 | 56 | # pbr generates these 57 | AUTHORS 58 | ChangeLog 59 | 60 | # Files created by releasenotes build 61 | releasenotes/build 62 | -------------------------------------------------------------------------------- /README.rst: -------------------------------------------------------------------------------- 1 | =============================== 2 | ku.stella 3 | =============================== 4 | 5 | Stella Cloud project 6 | 7 | This page is Stella-OpenStack code repository. 8 | 9 | Stella-OpenStack support Stella VM scheduler to set performance SLA in OpenStack IaaS clouds. 10 | 11 | Visit our project page for detailed information about Stella project. 12 | 13 | * Documentation 14 | https://stella.korea.ac.kr 15 | * Source 16 | OpenStack repo: https://git.openstack.org/cgit/openstack/ku.stella 17 | 18 | GitHub repo: https://github.com/KUoslab/Stella-OpenStack 19 | * Bugs 20 | Email: starlab@os.korea.ac.kr 21 | 22 | Lanchpad: https://bugs.launchpad.net/KU.stella 23 | 24 | 25 | -------- 26 | 27 | * Stella-OpenStack APIs 28 | 29 | Stella-OpenStack APIs(a.k.s Stella APIs) provide access Stella-OpenStack functions. 30 | 31 | Stella APIs support RestAPI(http based APIs). 32 | 33 | The list of Stella APIs is below. 34 | 35 | 1. /stella: 36 | Check the status of Stella scheduler(xGoS) and Stella-OpenStack. 37 | 2. /stella/vms: 38 | Returns the list of VMs and information of each VMs. 39 | 3. /stella/vms/sla: 40 | Set SLA for VM. Use instance name in horizon as a Input 41 | 4. /stella/hypervisor: 42 | Returns the IP address of the hypervisor host. 43 | 44 | 'hypervisor_name' field is essential. 45 | -------------------------------------------------------------------------------- /tox.ini: -------------------------------------------------------------------------------- 1 | [tox] 2 | minversion = 2.0 3 | envlist = py35,py27,pep8 4 | skipsdist = True 5 | 6 | [testenv] 7 | usedevelop = True 8 | install_command = pip install -c{env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt} {opts} {packages} 9 | setenv = 10 | VIRTUAL_ENV={envdir} 11 | PYTHONWARNINGS=default::DeprecationWarning 12 | OS_STDOUT_CAPTURE=1 13 | OS_STDERR_CAPTURE=1 14 | OS_TEST_TIMEOUT=60 15 | deps = -r{toxinidir}/test-requirements.txt 16 | commands = stestr run {posargs} 17 | 18 | [testenv:pep8] 19 | commands = flake8 {posargs} 20 | 21 | [testenv:venv] 22 | commands = {posargs} 23 | 24 | [testenv:cover] 25 | setenv = 26 | VIRTUAL_ENV={envdir} 27 | PYTHON=coverage run --source ku.stella --parallel-mode 28 | commands = 29 | stestr run {posargs} 30 | coverage combine 31 | coverage html -d cover 32 | coverage xml -o cover/coverage.xml 33 | 34 | [testenv:docs] 35 | deps = -r{toxinidir}/doc/requirements.txt 36 | commands = sphinx-build -W -b html doc/source doc/build/html 37 | 38 | [testenv:releasenotes] 39 | deps = {[testenv:docs]deps} 40 | commands = 41 | sphinx-build -a -E -W -d releasenotes/build/doctrees -b html releasenotes/source releasenotes/build/html 42 | 43 | [testenv:debug] 44 | commands = oslo_debug_helper {posargs} 45 | 46 | [flake8] 47 | # E123, E125 skipped as they are invalid PEP-8. 48 | 49 | show-source = True 50 | ignore = E123,E125 51 | builtins = _ 52 | exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build 53 | -------------------------------------------------------------------------------- /JBNUscripts/backup-snapshot.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # OpneStack의 프로젝트들에 존재하는 인스턴스의 스냅샷을 백업서버에 전송한다. 4 | 5 | 6 | PATH_TO_JOBLIST=queue 7 | PATH_TO_SNAPSHOT_DIR=/var/lib/glance/images 8 | #openstack server list -c "ID" --all-projects --host main02 | grep "[a-z0-9]" | sed 's/|\| //g' >> $PATH_TO_JOBLIST 9 | 10 | while [[ -n $(cat $PATH_TO_JOBLIST) ]]; do 11 | # 백업할 인스턴스 id 12 | instance_id=$(head -n 1 $PATH_TO_JOBLIST) 13 | # 백업할 인스턴스 이름 14 | instance_name=$(openstack server show $instance_id | grep " name " | awk -F '|' '{print $3}' | sed 's/ //g') 15 | echo $instance_name 16 | # 백업할 스냅샷 이름 정하기 17 | timestamp=$(date "+%Y%m%d") 18 | snapshot_name="${instance_name}__${instance_id}__${timestamp}" 19 | echo $snapshot_name 20 | # matadata 저장 21 | mkdir -p /home/ubuntu/backup/${instance_name}__${instance_id} 22 | openstack server show $instance_id > /home/ubuntu/backup/${instance_name}__${instance_id}/info 23 | # 스냅샷 생성 24 | snapshot_id=$(openstack server image create --name $snapshot_name $instance_id | grep " id" | awk -F '|' '{print $3}' | sed 's/ //g') 25 | echo $snapshot_id 26 | # 스냅샷 생성 될까지 기다림 27 | while [ $(openstack image show $snapshot_id | grep status | awk '{print $4}') != "active" ]; do 28 | echo "Waiting..." 29 | sleep 5 30 | done 31 | ls -al $PATH_TO_SNAPSHOT_DIR/$snapshot_id 32 | # 스냅샷 폴더로 이동 33 | cp -r $PATH_TO_SNAPSHOT_DIR/$snapshot_id /home/ubuntu/backup/${instance_name}__${instance_id}/${timestamp}__${snapshot_id} 34 | # 스냅샷 삭제 35 | openstack image delete $snapshot_id 36 | # 작업 리스트에서 삭제 37 | sed -i '1d' $PATH_TO_JOBLIST 38 | done 39 | -------------------------------------------------------------------------------- /doc/source/install/common_prerequisites.rst: -------------------------------------------------------------------------------- 1 | Prerequisites 2 | ------------- 3 | 4 | Before you install and configure the ku.stella service, 5 | you must create a database, service credentials, and API endpoints. 6 | 7 | #. To create the database, complete these steps: 8 | 9 | * Use the database access client to connect to the database 10 | server as the ``root`` user: 11 | 12 | .. code-block:: console 13 | 14 | $ mysql -u root -p 15 | 16 | * Create the ``ku.stella`` database: 17 | 18 | .. code-block:: none 19 | 20 | CREATE DATABASE ku.stella; 21 | 22 | * Grant proper access to the ``ku.stella`` database: 23 | 24 | .. code-block:: none 25 | 26 | GRANT ALL PRIVILEGES ON ku.stella.* TO 'ku.stella'@'localhost' \ 27 | IDENTIFIED BY 'KU.STELLA_DBPASS'; 28 | GRANT ALL PRIVILEGES ON ku.stella.* TO 'ku.stella'@'%' \ 29 | IDENTIFIED BY 'KU.STELLA_DBPASS'; 30 | 31 | Replace ``KU.STELLA_DBPASS`` with a suitable password. 32 | 33 | * Exit the database access client. 34 | 35 | .. code-block:: none 36 | 37 | exit; 38 | 39 | #. Source the ``admin`` credentials to gain access to 40 | admin-only CLI commands: 41 | 42 | .. code-block:: console 43 | 44 | $ . admin-openrc 45 | 46 | #. To create the service credentials, complete these steps: 47 | 48 | * Create the ``ku.stella`` user: 49 | 50 | .. code-block:: console 51 | 52 | $ openstack user create --domain default --password-prompt ku.stella 53 | 54 | * Add the ``admin`` role to the ``ku.stella`` user: 55 | 56 | .. code-block:: console 57 | 58 | $ openstack role add --project service --user ku.stella admin 59 | 60 | * Create the ku.stella service entities: 61 | 62 | .. code-block:: console 63 | 64 | $ openstack service create --name ku.stella --description "ku.stella" ku.stella 65 | 66 | #. Create the ku.stella service API endpoints: 67 | 68 | .. code-block:: console 69 | 70 | $ openstack endpoint create --region RegionOne \ 71 | ku.stella public http://controller:XXXX/vY/%\(tenant_id\)s 72 | $ openstack endpoint create --region RegionOne \ 73 | ku.stella internal http://controller:XXXX/vY/%\(tenant_id\)s 74 | $ openstack endpoint create --region RegionOne \ 75 | ku.stella admin http://controller:XXXX/vY/%\(tenant_id\)s 76 | -------------------------------------------------------------------------------- /ku.stella/connect_openstack.py: -------------------------------------------------------------------------------- 1 | # This work is done by Operating System Lab. 2 | 3 | """ 4 | This file defines wrapper to connect OpenStack cloud 5 | assume that we use DevStack for configuration file 6 | 7 | by jmlim@os.korea.ac.kr 8 | """ 9 | 10 | import argparse 11 | import os 12 | import sys 13 | 14 | import openstack 15 | from openstack import utils 16 | from openstack.config import loader 17 | 18 | # kwlee 19 | #utils.enable_logging(True, stream=sys.stdout) 20 | 21 | #: Defines the OpenStack Config loud key in your config file, 22 | #: typically in $HOME/.config/openstack/clouds.yaml. That configuration 23 | #: will determine where the examples will be run and what resource defaults 24 | #: will be used to run the examples. 25 | STELLA_CLOUD = os.getenv('OS_CLOUD', 'Stella') 26 | config = loader.OpenStackConfig() 27 | CLOUD = openstack.connect(cloud=STELLA_CLOUD) 28 | 29 | 30 | class Opts(object): 31 | def __init__(self, cloud_name='Stella-DevStack', debug=False): 32 | # This function is for init OpenStack connection 33 | # I use DevStack and the configureation file is automaticly generated in /etc/openstack/clouds.yaml 34 | self.cloud = cloud_name 35 | self.debug = debug 36 | # use identity v3 API 37 | self.identity_api_version = '3' 38 | 39 | def _get_resource_value(resource_key, default): 40 | return config.get_extra_config('example').get(resource_key, default) 41 | 42 | SERVER_NAME = 'openstacksdk-example' 43 | IMAGE_NAME = _get_resource_value('image_name', 'cirros-0.3.5-x86_64-disk') 44 | FLAVOR_NAME = _get_resource_value('flavor_name', 'm1.small') 45 | NETWORK_NAME = _get_resource_value('network_name', 'private') 46 | KEYPAIR_NAME = _get_resource_value('keypair_name', 'openstacksdk-example') 47 | SSH_DIR = _get_resource_value( 48 | 'ssh_dir', '{home}/.ssh'.format(home=os.path.expanduser("~"))) 49 | PRIVATE_KEYPAIR_FILE = _get_resource_value( 50 | 'private_keypair_file', '{ssh_dir}/id_rsa.{key}'.format( 51 | ssh_dir=SSH_DIR, key=KEYPAIR_NAME)) 52 | 53 | EXAMPLE_IMAGE_NAME = 'openstacksdk-example-public-image' 54 | 55 | def create_connection_from_config(): 56 | return openstack.connect(cloud=STELLA_CLOUD) 57 | 58 | def create_connection_from_args(): 59 | parser = argparse.ArgumentParser() 60 | config = loader.OpenStackConfig() 61 | config.register_argparse_arguments(parser, sys.argv[1:]) 62 | args = parser.parse_args() 63 | return openstack.connect(config=config.get_one(argparse=args)) 64 | 65 | def create_connection(auth_url, region, project_name, username, password): 66 | return openstack.connect( 67 | auth_url=auth_url, 68 | project_name=project_name, 69 | username=username, 70 | password=password, 71 | region_name=region, 72 | app_name='Stella-OpenStack', 73 | app_version='0.1', 74 | ) 75 | -------------------------------------------------------------------------------- /doc/source/conf.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Licensed under the Apache License, Version 2.0 (the "License"); 3 | # you may not use this file except in compliance with the License. 4 | # You may obtain a copy of the License at 5 | # 6 | # http://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an "AS IS" BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 11 | # implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # This work is done by Operating System Lab 15 | 16 | import os 17 | import sys 18 | 19 | sys.path.insert(0, os.path.abspath('../..')) 20 | # -- General configuration ---------------------------------------------------- 21 | 22 | # Add any Sphinx extension module names here, as strings. They can be 23 | # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones. 24 | extensions = [ 25 | 'sphinx.ext.autodoc', 26 | 'openstackdocstheme', 27 | #'sphinx.ext.intersphinx', 28 | ] 29 | 30 | # autodoc generation is a bit aggressive and a nuisance when doing heavy 31 | # text edit cycles. 32 | # execute "export SPHINX_DEBUG=1" in your terminal to disable 33 | 34 | # The suffix of source filenames. 35 | source_suffix = '.rst' 36 | 37 | # The master toctree document. 38 | master_doc = 'index' 39 | 40 | # General information about the project. 41 | project = u'ku.stella' 42 | copyright = u'2017, OpenStack Developers' 43 | 44 | # openstackdocstheme options 45 | repository_name = 'openstack/ku.stella' 46 | bug_project = 'KU.stella' 47 | bug_tag = '' 48 | html_last_updated_fmt = '%Y-%m-%d %H:%M' 49 | 50 | # If true, '()' will be appended to :func: etc. cross-reference text. 51 | add_function_parentheses = True 52 | 53 | # If true, the current module name will be prepended to all description 54 | # unit titles (such as .. function::). 55 | add_module_names = True 56 | 57 | # The name of the Pygments (syntax highlighting) style to use. 58 | pygments_style = 'sphinx' 59 | 60 | # -- Options for HTML output -------------------------------------------------- 61 | 62 | # The theme to use for HTML and HTML Help pages. Major themes that come with 63 | # Sphinx are currently 'default' and 'sphinxdoc'. 64 | # html_theme_path = ["."] 65 | # html_theme = '_theme' 66 | # html_static_path = ['static'] 67 | html_theme = 'openstackdocs' 68 | 69 | # Output file base name for HTML help builder. 70 | htmlhelp_basename = '%sdoc' % project 71 | 72 | # Grouping the document tree into LaTeX files. List of tuples 73 | # (source start file, target name, title, author, documentclass 74 | # [howto/manual]). 75 | latex_documents = [ 76 | ('index', 77 | '%s.tex' % project, 78 | u'%s Documentation' % project, 79 | u'OpenStack Developers', 'manual'), 80 | ] 81 | 82 | # Example configuration for intersphinx: refer to the Python standard library. 83 | #intersphinx_mapping = {'http://docs.python.org/': None} 84 | -------------------------------------------------------------------------------- /JBNUscripts/nat-portforwarding.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # iptables 로 ssh, http 를 NAT 설정하는 스크립트 4 | # ssh == (Public IP):19xxx -> 192.168.0.xxx:7777 5 | # http == (Public IP):18xxx -> 192.168.0.xxx:80 (TCP and UDP) 6 | # 위와 같이 포트 번호를 기준으로 내부 인스턴스로 NAT 7 | # 자세한 설명은 readme.md 를 참고하세요. 8 | 9 | 10 | # ip netns 로 확인: 최근에 만들어진 라우터가 id 가 더 높음 11 | # ip netns ifconfig <- 여기서 두 번째 NIC 확인해야함 12 | router="" 13 | #nic="qr-0cf50ae1-50" 14 | nic="" # 외부 IP가 할당된 인터페이스 15 | 16 | ssh_public_port_prefix="19" # ssh 19xxx -> 7777 17 | http_public_port_prefix="18" # http 18xxx -> 80 18 | https_public_port_prefix="17" # http 18xxx -> 80 19 | node_public_port_prefix="13" # nodejs devel 13xxx -> 3000 20 | http8080_public_port_prefix="10" # http 10xxx -> 8080 21 | 22 | ssh_inner_port="7777" 23 | http_inner_port="80" 24 | https_inner_port="443" 25 | node_inner_port="3000" 26 | http8080_inner_port="8080" 27 | 28 | 29 | inner_net_prefix="10.0.0." 30 | 31 | echo "편의를 위해 스크립트 내에 IP 와 라우터 이름을 하드코딩해 놓았습니다." 32 | echo "스크립트 유출에 주의해주세요." 33 | echo "" 34 | echo "ssh == (Public IP):${ssh_public_port_prefix}xxx -> ${inner_net_prefix}xxx:${ssh_inner_port}" 35 | echo "http == (Public IP):${http_public_port_prefix}xxx -> ${inner_net_prefix}xxx:${http_inner_port}" 36 | echo "" 37 | 38 | #ssh $username@$controller_ip -p $controller_ssh_port /bin/bash -s ${router} ${option} ${os2019_nic} ${ssh_public_port_prefix} ${inner_net_prefix} ${ssh_inner_port} ${http_public_port_prefix} ${http_inner_port} 39 | 40 | i=3 41 | 42 | while [ $i -lt 255 ]; do 43 | sudo ip netns exec $router iptables -t nat -A PREROUTING -i $nic -p tcp --dport $ssh_public_port_prefix$(printf '%03d' $i) -j DNAT --to $inner_net_prefix$(printf '%d' $i):$ssh_inner_port 44 | sudo ip netns exec $router iptables -t nat -A PREROUTING -i $nic -p tcp --dport $http_public_port_prefix$(printf '%03d' $i) -j DNAT --to $inner_net_prefix$(printf '%d' $i):$http_inner_port 45 | sudo ip netns exec $router iptables -t nat -A PREROUTING -i $nic -p udp --dport $http_public_port_prefix$(printf '%03d' $i) -j DNAT --to $inner_net_prefix$(printf '%d' $i):$http_inner_port 46 | sudo ip netns exec $router iptables -t nat -A PREROUTING -i $nic -p tcp --dport $https_public_port_prefix$(printf '%03d' $i) -j DNAT --to $inner_net_prefix$(printf '%d' $i):$https_inner_port 47 | sudo ip netns exec $router iptables -t nat -A PREROUTING -i $nic -p udp --dport $https_public_port_prefix$(printf '%03d' $i) -j DNAT --to $inner_net_prefix$(printf '%d' $i):$https_inner_port 48 | sudo ip netns exec $router iptables -t nat -A PREROUTING -i $nic -p tcp --dport $node_public_port_prefix$(printf '%03d' $i) -j DNAT --to $inner_net_prefix$(printf '%d' $i):$node_inner_port 49 | sudo ip netns exec $router iptables -t nat -A PREROUTING -i $nic -p udp --dport $node_public_port_prefix$(printf '%03d' $i) -j DNAT --to $inner_net_prefix$(printf '%d' $i):$node_inner_port 50 | sudo ip netns exec $router iptables -t nat -A PREROUTING -i $nic -p tcp --dport $http8080_public_port_prefix$(printf '%03d' $i) -j DNAT --to $inner_net_prefix$(printf '%d' $i):$http8080_inner_port 51 | sudo ip netns exec $router iptables -t nat -A PREROUTING -i $nic -p udp --dport $http8080_public_port_prefix$(printf '%03d' $i) -j DNAT --to $inner_net_prefix$(printf '%d' $i):$http8080_inner_port 52 | 53 | 54 | echo "$inner_net_prefix$(printf '%d' $i) 의 DNAT 설정이 ${text}되었습니다." 55 | ((i++)) 56 | done 57 | sudo ip netns exec $router iptables -t nat -A POSTROUTING -o $nic -j MASQUERADE 58 | 59 | echo "모든 설정이 완료되었습니다." 60 | -------------------------------------------------------------------------------- /releasenotes/source/conf.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Licensed under the Apache License, Version 2.0 (the "License"); 3 | # you may not use this file except in compliance with the License. 4 | # You may obtain a copy of the License at 5 | # 6 | # http://www.apache.org/licenses/LICENSE-2.0 7 | # 8 | # Unless required by applicable law or agreed to in writing, software 9 | # distributed under the License is distributed on an "AS IS" BASIS, 10 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 11 | # implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # This file is execfile()d with the current directory set to its 16 | # containing dir. 17 | # 18 | # Note that not all possible configuration values are present in this 19 | # autogenerated file. 20 | # 21 | # All configuration values have a default; values that are commented out 22 | # serve to show the default. 23 | 24 | # If extensions (or modules to document with autodoc) are in another directory, 25 | # add these directories to sys.path here. If the directory is relative to the 26 | # documentation root, use os.path.abspath to make it absolute, like shown here. 27 | # sys.path.insert(0, os.path.abspath('.')) 28 | 29 | # -- General configuration ------------------------------------------------ 30 | 31 | # If your documentation needs a minimal Sphinx version, state it here. 32 | # needs_sphinx = '1.0' 33 | 34 | # Add any Sphinx extension module names here, as strings. They can be 35 | # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom 36 | # ones. 37 | # This work is done by Operating System Labs 38 | # extentions 39 | extensions = [ 40 | 'openstackdocstheme', 41 | 'reno.sphinxext', 42 | ] 43 | 44 | # Add any paths that contain templates here, relative to this directory. 45 | templates_path = ['_templates'] 46 | 47 | # The suffix of source filenames. 48 | source_suffix = '.rst' 49 | 50 | # The encoding of source files. 51 | # source_encoding = 'utf-8-sig' 52 | 53 | # The master toctree document. 54 | master_doc = 'index' 55 | 56 | # General information about the project. 57 | project = u'ku.stella Release Notes' 58 | copyright = u'2017, OpenStack Developers' 59 | 60 | # openstackdocstheme options 61 | repository_name = 'openstack/ku.stella' 62 | bug_project = 'KU.stella' 63 | bug_tag = '' 64 | html_last_updated_fmt = '%Y-%m-%d %H:%M' 65 | 66 | # The version info for the project you're documenting, acts as replacement for 67 | # |version| and |release|, also used in various other places throughout the 68 | # built documents. 69 | # 70 | # The short X.Y version. 71 | # The full version, including alpha/beta/rc tags. 72 | release = '' 73 | # The short X.Y version. 74 | version = '' 75 | 76 | # The language for content autogenerated by Sphinx. Refer to documentation 77 | # for a list of supported languages. 78 | # language = None 79 | 80 | # There are two options for replacing |today|: either, you set today to some 81 | # non-false value, then it is used: 82 | # today = '' 83 | # Else, today_fmt is used as the format for a strftime call. 84 | # today_fmt = '%B %d, %Y' 85 | 86 | # List of patterns, relative to source directory, that match files and 87 | # directories to ignore when looking for source files. 88 | exclude_patterns = [] 89 | 90 | # The reST default role (used for this markup: `text`) to use for all 91 | # documents. 92 | # default_role = None 93 | 94 | # If true, '()' will be appended to :func: etc. cross-reference text. 95 | # add_function_parentheses = True 96 | 97 | # If true, the current module name will be prepended to all description 98 | # unit titles (such as .. function::). 99 | # add_module_names = True 100 | 101 | # If true, sectionauthor and moduleauthor directives will be shown in the 102 | # output. They are ignored by default. 103 | # show_authors = False 104 | 105 | # The name of the Pygments (syntax highlighting) style to use. 106 | pygments_style = 'sphinx' 107 | 108 | # A list of ignored prefixes for module index sorting. 109 | # modindex_common_prefix = [] 110 | 111 | # If true, keep warnings as "system message" paragraphs in the built documents. 112 | # keep_warnings = False 113 | 114 | 115 | # -- Options for HTML output ---------------------------------------------- 116 | 117 | # The theme to use for HTML and HTML Help pages. See the documentation for 118 | # a list of builtin themes. 119 | html_theme = 'openstackdocs' 120 | 121 | # Theme options are theme-specific and customize the look and feel of a theme 122 | # further. For a list of options available for each theme, see the 123 | # documentation. 124 | # html_theme_options = {} 125 | 126 | # Add any paths that contain custom themes here, relative to this directory. 127 | # html_theme_path = [] 128 | 129 | # The name for this set of Sphinx documents. If None, it defaults to 130 | # " v documentation". 131 | # html_title = None 132 | 133 | # A shorter title for the navigation bar. Default is the same as html_title. 134 | # html_short_title = None 135 | 136 | # The name of an image file (relative to this directory) to place at the top 137 | # of the sidebar. 138 | # html_logo = None 139 | 140 | # The name of an image file (within the static path) to use as favicon of the 141 | # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 142 | # pixels large. 143 | # html_favicon = None 144 | 145 | # Add any paths that contain custom static files (such as style sheets) here, 146 | # relative to this directory. They are copied after the builtin static files, 147 | # so a file named "default.css" will overwrite the builtin "default.css". 148 | html_static_path = ['_static'] 149 | 150 | # Add any extra paths that contain custom files (such as robots.txt or 151 | # .htaccess) here, relative to this directory. These files are copied 152 | # directly to the root of the documentation. 153 | # html_extra_path = [] 154 | 155 | # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, 156 | # using the given strftime format. 157 | # html_last_updated_fmt = '%b %d, %Y' 158 | 159 | # If true, SmartyPants will be used to convert quotes and dashes to 160 | # typographically correct entities. 161 | # html_use_smartypants = True 162 | 163 | # Custom sidebar templates, maps document names to template names. 164 | # html_sidebars = {} 165 | 166 | # Additional templates that should be rendered to pages, maps page names to 167 | # template names. 168 | # html_additional_pages = {} 169 | 170 | # If false, no module index is generated. 171 | # html_domain_indices = True 172 | 173 | # If false, no index is generated. 174 | # html_use_index = True 175 | 176 | # If true, the index is split into individual pages for each letter. 177 | # html_split_index = False 178 | 179 | # If true, links to the reST sources are added to the pages. 180 | # html_show_sourcelink = True 181 | 182 | # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. 183 | # html_show_sphinx = True 184 | 185 | # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. 186 | # html_show_copyright = True 187 | 188 | # If true, an OpenSearch description file will be output, and all pages will 189 | # contain a tag referring to it. The value of this option must be the 190 | # base URL from which the finished HTML is served. 191 | # html_use_opensearch = '' 192 | 193 | # This is the file name suffix for HTML files (e.g. ".xhtml"). 194 | # html_file_suffix = None 195 | 196 | # Output file base name for HTML help builder. 197 | htmlhelp_basename = 'ku.stellaReleaseNotesdoc' 198 | 199 | 200 | # -- Options for LaTeX output --------------------------------------------- 201 | 202 | latex_elements = { 203 | # The paper size ('letterpaper' or 'a4paper'). 204 | # 'papersize': 'letterpaper', 205 | 206 | # The font size ('10pt', '11pt' or '12pt'). 207 | # 'pointsize': '10pt', 208 | 209 | # Additional stuff for the LaTeX preamble. 210 | # 'preamble': '', 211 | } 212 | 213 | # Grouping the document tree into LaTeX files. List of tuples 214 | # (source start file, target name, title, 215 | # author, documentclass [howto, manual, or own class]). 216 | latex_documents = [ 217 | ('index', 'ku.stellaReleaseNotes.tex', 218 | u'ku.stella Release Notes Documentation', 219 | u'OpenStack Foundation', 'manual'), 220 | ] 221 | 222 | # The name of an image file (relative to this directory) to place at the top of 223 | # the title page. 224 | # latex_logo = None 225 | 226 | # For "manual" documents, if this is true, then toplevel headings are parts, 227 | # not chapters. 228 | # latex_use_parts = False 229 | 230 | # If true, show page references after internal links. 231 | # latex_show_pagerefs = False 232 | 233 | # If true, show URL addresses after external links. 234 | # latex_show_urls = False 235 | 236 | # Documents to append as an appendix to all manuals. 237 | # latex_appendices = [] 238 | 239 | # If false, no module index is generated. 240 | # latex_domain_indices = True 241 | 242 | 243 | # -- Options for manual page output --------------------------------------- 244 | 245 | # One entry per manual page. List of tuples 246 | # (source start file, name, description, authors, manual section). 247 | man_pages = [ 248 | ('index', 'ku.stellarereleasenotes', 249 | u'ku.stella Release Notes Documentation', 250 | [u'OpenStack Foundation'], 1) 251 | ] 252 | 253 | # If true, show URL addresses after external links. 254 | # man_show_urls = False 255 | 256 | 257 | # -- Options for Texinfo output ------------------------------------------- 258 | 259 | # Grouping the document tree into Texinfo files. List of tuples 260 | # (source start file, target name, title, author, 261 | # dir menu entry, description, category) 262 | texinfo_documents = [ 263 | ('index', 'ku.stella ReleaseNotes', 264 | u'ku.stella Release Notes Documentation', 265 | u'OpenStack Foundation', 'ku.stellaReleaseNotes', 266 | 'One line description of project.', 267 | 'Miscellaneous'), 268 | ] 269 | 270 | # Documents to append as an appendix to all manuals. 271 | # texinfo_appendices = [] 272 | 273 | # If false, no module index is generated. 274 | # texinfo_domain_indices = True 275 | 276 | # How to display URL addresses: 'footnote', 'no', or 'inline'. 277 | # texinfo_show_urls = 'footnote' 278 | 279 | # If true, do not generate a @detailmenu in the "Top" node's menu. 280 | # texinfo_no_detailmenu = False 281 | 282 | # -- Options for Internationalization output ------------------------------ 283 | locale_dirs = ['locale/'] 284 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | -------------------------------------------------------------------------------- /ku.stella/Stella-OpenStack.py: -------------------------------------------------------------------------------- 1 | # This work is done by Operating System Lab. 2 | 3 | import argparse 4 | import logging 5 | import os 6 | 7 | # for API server 8 | from flask import Flask, jsonify, request, abort 9 | from flask_restful import Resource, Api 10 | 11 | import connect_openstack 12 | 13 | app = Flask(__name__) 14 | api = Api(app) 15 | # 16 | 17 | """ 18 | 19 | Stella-OpenStack Conment main file 20 | 21 | - by jmlim@os.korea.ac.kr 22 | 23 | """ 24 | 25 | 26 | class VM_info: 27 | _list_vms = {} 28 | 29 | # _vm_name = " " 30 | # _instance_name = " " 31 | # _project_id = " " 32 | # _hypervisor_name = " " 33 | # _hypervisor_ip = " " 34 | 35 | def print_all(self): 36 | return self._list_vms 37 | 38 | def print_num(self): 39 | return len(self._list_vms) + 1 40 | 41 | def set_info(self, _vm_name, _instance_name, _project_id, _hypervisor_name, _hypervisor_ip, _sla_option, 42 | _sla_value): 43 | # Key for VMs list 44 | num = len(self._list_vms) 45 | # Add to VMs list 46 | # self._list_vms[num] = [_vm_name, _instance_name, _project_id, _hypervisor_name, _hypervisor_ip] 47 | self._list_vms[num] = {'vm_name': _vm_name, 'instance_name': _instance_name, 'project_id': _project_id, 48 | 'hypervisor_name': _hypervisor_name, 'hypervisor_ip': _hypervisor_ip, 49 | 'SLA_Option': _sla_option, 'SLA_Value': _sla_value} 50 | # _tmp = [ _vm_name, _instance_name, _project_id, _hypervisor_name, _hypervisor_ip] 51 | # self._vm_info.append(_tmp) 52 | return len(self._list_vms) 53 | 54 | def print_SLA(self, _name): 55 | count = -1 56 | for tmp in self._list_vms: 57 | # print(self._list_vms[tmp]) 58 | if _name in self._list_vms[tmp]["vm_name"]: 59 | count = tmp 60 | break 61 | else: 62 | print("N") 63 | # print SLA_option and SLA_Value 64 | # print(self._list_vms[tmp]["vm_name"]) 65 | # print(self._list_vms[count]["SLA_Option"]) 66 | # print(self._list_vms[count]["SLA_Value"]) 67 | 68 | # return self._list_vms['vm_name'] 69 | 70 | def get_instance_name_by_name(self, _name): 71 | count = -1 72 | for count in self._list_vms: 73 | # print(self._list_vms[tmp]) 74 | # print(count) 75 | if _name in self._list_vms[count]["vm_name"]: 76 | _instance_name = self._list_vms[count]["instance_name"] 77 | count = count 78 | # print("break") 79 | break 80 | return _instance_name 81 | 82 | def get_sla_option_by_name(self, _name): 83 | count = -1 84 | for count in self._list_vms: 85 | # print(self._list_vms[tmp]) 86 | # print(count) 87 | if _name in self._list_vms[count]["vm_name"]: 88 | _sla_option = self._list_vms[count]["SLA_Option"] 89 | count = count 90 | # print("break") 91 | break 92 | return _sla_option 93 | 94 | def get_sla_value_by_name(self, _name): 95 | count = -1 96 | for count in self._list_vms: 97 | # print(self._list_vms[tmp]) 98 | # print(count) 99 | if _name in self._list_vms[count]["vm_name"]: 100 | _sla_value = self._list_vms[count]["SLA_Value"] 101 | count = count 102 | # print("break") 103 | break 104 | return _sla_value 105 | 106 | def set_SLA(self, _name, _SLA_Option, _SLA_Value): 107 | count = -1 108 | for count in self._list_vms: 109 | # print(self._list_vms[tmp]) 110 | # print(count) 111 | if _name in self._list_vms[count]["vm_name"]: 112 | # print(self._list_vms[count]["vm_name"]) 113 | count = count 114 | # print("break") 115 | break 116 | # print SLA_option and SLA_Value 117 | # print(self._list_vms[count]["vm_name"]) 118 | self._list_vms[count].update(SLA_Option=_SLA_Option) 119 | # print(self._list_vms[count]["SLA_Option"]) 120 | # self._list_vms[count]['SLA_Option']: _SLA_Option 121 | self._list_vms[count].update(SLA_Value=_SLA_Value) 122 | # print(self._list_vms[count]["SLA_Value"]) 123 | 124 | return count 125 | 126 | 127 | # def get_info(self, _vm_name ): 128 | # _tmp = 129 | 130 | # for Hyperbisor info 131 | class hypervisor_info: 132 | _list_hypervisor = {} 133 | 134 | def set_data(self, _name, _ip): 135 | self._list_hypervisor[_name] = _ip 136 | 137 | def get_data(self, _name): 138 | return self._list_hypervisor[_name] 139 | 140 | 141 | class Stella_OpenStack(Resource): 142 | 143 | def __init__(self, log_file=None): 144 | logging.basicConfig(level=logging.INFO, format='%(message)s') 145 | self.logger = logging.getLogger("Stella-OpenStack START") 146 | self.log_file = log_file 147 | 148 | if log_file: 149 | self.log_handler = logging.FileHandler(self.log_file) 150 | self.logger.addHandler(self.log_handler) 151 | 152 | self.__stop = False 153 | 154 | # self.signal(signal.SIGINT, self.stop) 155 | # self.signal(signal.SIGTERM, self.stop) 156 | 157 | def main(self): 158 | self.logger.info("STELLA: PID {0}".format(os.getpid())) 159 | 160 | def stop(self, signum, frame): 161 | self.__stop = True 162 | self.logger.info("STELLA: Signal {0}".format(signum)) 163 | self.logger.info("STELLA: STOP") 164 | 165 | 166 | # global variables 167 | hypervisors = hypervisor_info 168 | vms = VM_info 169 | 170 | # Stella-OpenStack API list 171 | # /stella : Check status of Stella scheduler and Stella-OpenStack 172 | # /stella/vms : Returns the list of VMs and information of each VMs 173 | # /stella/vms/sla: Set SLA for VM. Use instance name in horizon as a Input 174 | # /stella/hypervisor : Returns Hypervisor IP address 175 | @app.route('/stella/', methods=['GET']) 176 | def StellaAPI_Status(): 177 | return "Stella-OpenStack is ON" 178 | 179 | @app.route('/stella/vms', methods=['GET']) 180 | def StellaAPI_listVMs(): 181 | return jsonify(vms.print_all(vms)) 182 | 183 | @app.route('/stella/vms/sla', methods=['POST']) 184 | def StellaAPI_Set_SLA_VM(): 185 | if not request.json or not 'name' in request.json: 186 | abort(400) 187 | if not request.json or not 'SLA_Option' in request.json: 188 | abort(400) 189 | if not request.json or not 'SLA_Value' in request.json: 190 | abort(400) 191 | 192 | _name = request.json['name'] 193 | _SLA_option = request.json['SLA_Option'] 194 | _SLA_value = request.json['SLA_Value'] 195 | 196 | count = vms.set_SLA(vms, _name, _SLA_option, _SLA_value) 197 | instance_name = vms.get_instance_name_by_name(vms, _name) 198 | sla_option = vms.get_sla_option_by_name(vms, _name) 199 | sla_value = vms.get_sla_value_by_name(vms, _name) 200 | # print(instance_name) 201 | 202 | # get_ROOT privilege 203 | olduid = 0 204 | if os.geteuid() != 0: 205 | # running as normal user 206 | olduid = os.geteuid() 207 | print(olduid) 208 | os.seteuid(0) 209 | 210 | # execute SLA setting script 211 | cmd_str = './insert_sla.sh' + ' ' + instance_name + ' ' + sla_option + ' ' + sla_value 212 | print(cmd_str) 213 | os.system(cmd_str) 214 | 215 | # reset user privilege 216 | if olduid != 0: 217 | os.seteuid(olduid) 218 | 219 | if (count < 0): 220 | return jsonify({'message': 'error'}) 221 | else: 222 | return jsonify(vms.print_all(vms)) 223 | 224 | @app.route('/stella/hypervisor', methods=['POST']) 225 | def StellaAPI_SearchHypervisorsByName(): 226 | if not request.json or not 'name' in request.json: 227 | abort(400) 228 | else: 229 | _name = request.json['name'] 230 | hypervisors.get_data(hypervisors, _name) 231 | return jsonify({'hypervisor_ip': hypervisors.get_data(hypervisors, _name)}) 232 | 233 | # 234 | # Stella-OpenStack API list end 235 | 236 | if __name__ == '__main__': 237 | parser = argparse.ArgumentParser() 238 | parser.add_argument("--log", help="log filename", default=None) 239 | parser.add_argument("--pid", help="pid filename", default='/tmp/stella.pid') 240 | args = parser.parse_args() 241 | 242 | # fork to make deamin process 243 | # pid = os.fork() 244 | # if pid > 0: 245 | # for parent process 246 | 247 | # exit(0) 248 | 249 | # else: 250 | # For children process 251 | # os.chdir('/') 252 | # os.setsid() 253 | # os.umask(0) 254 | 255 | # pid = os.fork() 256 | # if pid > 0: 257 | # exit(0) 258 | 259 | # else: 260 | # sys.stdout.flush() 261 | # sys.stderr.flush() 262 | 263 | # si = open(os.devnull, 'r') 264 | # so = open(os.devnull, 'a+') 265 | # se = open(os.devnull, 'a+') 266 | 267 | # os.dup2(si.fileno(), sys.stdin.fileno()) 268 | # os.dup2(so.fileno(), sys.stdout.fileno()) 269 | # os.dup2(se.fileno(), sys.stderr.fileno()) 270 | 271 | # with open(args.pid, "w") as pid_file: 272 | # pid_file.write(str(os.getpid())) 273 | 274 | # Stella = Stella_OpenStack(args.log) 275 | # code = Stella.main() 276 | # exit(code) 277 | 278 | Stella = Stella_OpenStack(args.log) 279 | code = Stella.main() 280 | 281 | Stella.logger.info("STELLA: connect to Stella-cloud") 282 | conn = connect_openstack.Opts.create_connection_from_config() 283 | 284 | Stella.logger.info("STELLA: listing hypervisor") 285 | 286 | list_hypervisor_name = [] 287 | list_hypervisor_ip = [] 288 | # list_hypervisor = {} 289 | 290 | for HYPERVISOR in conn.compute.hypervisors(): 291 | list_hypervisor_name.append(HYPERVISOR.name) 292 | 293 | for HYPERVISOR in conn.compute.hypervisors(list_hypervisor_name): 294 | list_hypervisor_ip.append(HYPERVISOR.host_ip) 295 | 296 | # Make key-value storage for hypervisor 297 | # e.g. hypervisor name: hypervisor ip 298 | #hypervisors = hypervisor_info 299 | # print(hypervisors.print_num(hypervisors)) 300 | count = 0 301 | for index in list_hypervisor_name: 302 | print(index) 303 | list_hypervisor = {list_hypervisor_name[count]: list_hypervisor_ip[count]} 304 | hypervisors.set_data(hypervisors, list_hypervisor_name[count], list_hypervisor_ip[count]) 305 | count = count + 1 306 | # for debugging 307 | # hypervisors.print_all(hypervisors) 308 | # print(hypervisors.print_num(hypervisors)) 309 | 310 | # Storing VM information 311 | 312 | print("VM information") 313 | for VM in conn.compute.servers(): 314 | # print("VM_NAME: " + VM.name) 315 | # print("INSTANCE_NAME: " + VM.instance_name) 316 | # print("PROJECT_ID: " + VM.project_id) 317 | # print("HYPERVISOR_HOST: " + VM.hypervisor_hostname) 318 | # print("HOST_ID: " + VM.host_id) 319 | # print(vms.print_num(vms)) 320 | ip = hypervisors.get_data(hypervisors, VM.hypervisor_hostname) 321 | vms.set_info(vms, VM.name, VM.instance_name, VM.project_id, VM.hypervisor_hostname, ip, '-', '-') 322 | 323 | # vms.print_SLA(vms, "stella_test-3") 324 | # vms.set_SLA(vms, "stella_test-3", 'b_bw', '100000') 325 | 326 | # print(VM) 327 | 328 | # hypervisor_list_name = " " 329 | # hypervisor_list_ip = " " 330 | 331 | # Get hypervisor list AND ip address 332 | # for HYPERVISOR in conn.compute.hypervisors(): 333 | # tmp_hypervisor['name'] = HYPERVISOR.name 334 | # hypervisor_list_name = 335 | # 336 | # for HYPERVISOR in conn.compute.hypervisors(hypervisor_list_name): 337 | # hypervisor_list_ip = HYPERVISOR.host_ip 338 | 339 | # for Debugging 340 | 341 | # print(hypervisor_list_name) 342 | # print(hypervisor_list_ip) 343 | 344 | # print("VM information") 345 | # for VM in conn.compute.servers(): 346 | # print("VM_NAME: " + VM.name) 347 | # print("INSTANCE_NAME: " + VM.instance_name) 348 | # print("PROJECT_ID: " + VM.project_id) 349 | # print("HYPERVISOR_HOST: " + VM.hypervisor_hostname) 350 | # print("HOST_ID: " + VM.host_id) 351 | # print(VM) 352 | 353 | # for HYPERVISOR in conn.compute.hypervisors("DevStack"): 354 | # print(HYPERVISOR) 355 | 356 | # print("tenant information: ") 357 | # for HYPERVISOR in conn.identity.projects(): 358 | # print(HYPERVISOR) 359 | 360 | # VM_info = VM_info.set_info() 361 | # print(VM_info) 362 | 363 | # run API server 364 | app.run(host='0.0.0.0') 365 | --------------------------------------------------------------------------------