diff --git a/cron/example.sh b/cron/example.sh deleted file mode 100755 index 98acd25..0000000 --- a/cron/example.sh +++ /dev/null @@ -1,17 +0,0 @@ -# -# Example script to use with cron to regular send metrics to Monasca -# - -# Example crontab entry to run this script every 5 mins: -# -# */5 * * * * /home/stack/os-capacity/cron/example.sh > /tmp/metrics_last.log - -set -e - -source /home/stack/os-capacity/.openrc -source /home/stack/os-capacity/.venv-test/bin/activate - -export OS_CAPACITY_SEND_METRICS=1 - -os-capacity usages group -os-capacity resources group diff --git a/cron/grafana_dashboard.json b/cron/grafana_dashboard.json deleted file mode 100644 index 75fd35a..0000000 --- a/cron/grafana_dashboard.json +++ /dev/null @@ -1,524 +0,0 @@ -{ - "__inputs": [ - { - "name": "DS_MONASCA-METRICS", - "label": "Monasca-metrics", - "description": "", - "type": "datasource", - "pluginId": "monasca-datasource", - "pluginName": "Monasca" - } - ], - "__requires": [ - { - "type": "panel", - "id": "table", - "name": "Table", - "version": "" - }, - { - "type": "panel", - "id": "graph", - "name": "Graph", - "version": "" - }, - { - "type": "grafana", - "id": "grafana", - "name": "Grafana", - "version": "4.1.0-pre1" - }, - { - "type": "datasource", - "id": "monasca-datasource", - "name": "Monasca", - "version": "1.0.0" - } - ], - "id": null, - "title": "Resource Usage Dashboard", - "tags": [], - "style": "dark", - "timezone": "browser", - "editable": true, - "sharedCrosshair": true, - "hideControls": true, - "time": { - "from": "now-6h", - "to": "now" - }, - "timepicker": { - "refresh_intervals": [ - "5s", - "10s", - "30s", - "1m", - "5m", - "15m", - "30m", - "1h", - "2h", - "1d" - ], - "time_options": [ - "5m", - "15m", - "1h", - "6h", - "12h", - "24h", - "2d", - "7d", - "30d" - ] - }, - "templating": { - "list": [] - }, - "annotations": { - "list": [] - }, - "refresh": false, - "schemaVersion": 13, - "version": 12, - "links": [], - "gnetId": null, - "rows": [ - { - "title": "Dashboard Row", - "panels": [ - { - "columns": [ - { - "text": "Current", - "value": "current" - } - ], - "datasource": "${DS_MONASCA-METRICS}", - "editable": true, - "error": false, - "fontSize": "100%", - "id": 2, - "links": [], - "pageSize": null, - "scroll": true, - "showHeader": true, - "sort": { - "col": null, - "desc": false - }, - "span": 4, - "styles": [ - { - "dateFormat": "YYYY-MM-DD HH:mm:ss", - "pattern": "Time", - "type": "date" - }, - { - "colorMode": "cell", - "colors": [ - "rgba(245, 54, 54, 0.9)", - "rgba(237, 176, 40, 0.89)", - "rgba(50, 172, 45, 0.97)" - ], - "dateFormat": "YYYY-MM-DD HH:mm:ss", - "decimals": 0, - "pattern": "/.*/", - "thresholds": [ - "0.1", - "1.1" - ], - "type": "number", - "unit": "short" - } - ], - "targets": [ - { - "aggregator": "max", - "alias": "@flavor", - "dimensions": [ - { - "key": "flavor", - "value": "$all" - } - ], - "error": "", - "group": true, - "metric": "os_capacity.resources.free", - "period": "300", - "refId": "A" - } - ], - "title": "Free Resources", - "transform": "timeseries_aggregations", - "type": "table" - }, - { - "columns": [ - { - "text": "Current", - "value": "current" - } - ], - "datasource": "${DS_MONASCA-METRICS}", - "editable": true, - "error": false, - "fontSize": "100%", - "id": 3, - "links": [], - "pageSize": null, - "scroll": true, - "showHeader": true, - "sort": { - "col": null, - "desc": false - }, - "span": 4, - "styles": [ - { - "dateFormat": "YYYY-MM-DD HH:mm:ss", - "pattern": "Time", - "type": "date" - }, - { - "colorMode": null, - "colors": [ - "rgba(245, 54, 54, 0.9)", - "rgba(237, 129, 40, 0.89)", - "rgba(50, 172, 45, 0.97)" - ], - "decimals": 0, - "pattern": "/.*/", - "thresholds": [ - "0" - ], - "type": "number", - "unit": "short" - } - ], - "targets": [ - { - "aggregator": "max", - "alias": "@flavor", - "dimensions": [ - { - "key": "flavor", - "value": "$all" - } - ], - "error": "", - "group": true, - "metric": "os_capacity.resources.used", - "period": "300", - "refId": "A" - } - ], - "title": "Used Resources", - "transform": "timeseries_aggregations", - "type": "table" - }, - { - "columns": [ - { - "text": "Current", - "value": "current" - } - ], - "datasource": "${DS_MONASCA-METRICS}", - "editable": true, - "error": false, - "fontSize": "100%", - "id": 4, - "links": [], - "pageSize": null, - "scroll": true, - "showHeader": true, - "sort": { - "col": null, - "desc": false - }, - "span": 4, - "styles": [ - { - "dateFormat": "YYYY-MM-DD HH:mm:ss", - "pattern": "Time", - "type": "date" - }, - { - "colorMode": null, - "colors": [ - "rgba(245, 54, 54, 0.9)", - "rgba(237, 129, 40, 0.89)", - "rgba(50, 172, 45, 0.97)" - ], - "dateFormat": "YYYY-MM-DD HH:mm:ss", - "decimals": 0, - "pattern": "/.*/", - "thresholds": [], - "type": "number", - "unit": "short" - } - ], - "targets": [ - { - "aggregator": "max", - "alias": "@flavor", - "dimensions": [ - { - "key": "flavor", - "value": "$all" - } - ], - "error": "", - "group": true, - "metric": "os_capacity.resources.total", - "period": "300", - "refId": "A" - } - ], - "title": "Total Resources in System", - "transform": "timeseries_aggregations", - "type": "table" - } - ], - "showTitle": false, - "titleSize": "h6", - "height": 250, - "repeat": null, - "repeatRowId": null, - "repeatIteration": null, - "collapse": false - }, - { - "title": "Dashboard Row", - "panels": [ - { - "aliasColors": {}, - "bars": false, - "datasource": "${DS_MONASCA-METRICS}", - "editable": true, - "error": false, - "fill": 1, - "id": 1, - "legend": { - "avg": false, - "current": false, - "max": false, - "min": false, - "show": true, - "total": false, - "values": false - }, - "lines": true, - "linewidth": 1, - "links": [], - "nullPointMode": "connected", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "span": 4, - "stack": true, - "steppedLine": false, - "targets": [ - { - "aggregator": "none", - "alias": "@flavor", - "dimensions": [], - "error": "", - "group": true, - "hide": false, - "metric": "os_capacity.resources.used", - "period": "300", - "refId": "A" - } - ], - "thresholds": [], - "timeFrom": null, - "timeShift": null, - "title": "Servers Used per Flavor", - "tooltip": { - "msResolution": false, - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - } - ] - }, - { - "aliasColors": {}, - "bars": false, - "datasource": "${DS_MONASCA-METRICS}", - "editable": true, - "error": false, - "fill": 1, - "id": 5, - "legend": { - "avg": false, - "current": false, - "max": false, - "min": false, - "show": true, - "total": false, - "values": false - }, - "lines": true, - "linewidth": 1, - "links": [], - "nullPointMode": "connected", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "span": 4, - "stack": true, - "steppedLine": false, - "targets": [ - { - "aggregator": "none", - "alias": "@username", - "dimensions": [], - "error": "", - "group": true, - "hide": false, - "metric": "os_capacity.usage.user.count", - "period": "300", - "refId": "A" - } - ], - "thresholds": [], - "timeFrom": null, - "timeShift": null, - "title": "Servers Used per User", - "tooltip": { - "msResolution": false, - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - } - ] - }, - { - "columns": [ - { - "text": "Current", - "value": "current" - } - ], - "datasource": "${DS_MONASCA-METRICS}", - "editable": true, - "error": false, - "fontSize": "100%", - "id": 7, - "links": [], - "pageSize": null, - "scroll": true, - "showHeader": true, - "sort": { - "col": 1, - "desc": true - }, - "span": 4, - "styles": [ - { - "dateFormat": "YYYY-MM-DD HH:mm:ss", - "pattern": "Time", - "type": "date" - }, - { - "colorMode": null, - "colors": [ - "rgba(245, 54, 54, 0.9)", - "rgba(237, 129, 40, 0.89)", - "rgba(50, 172, 45, 0.97)" - ], - "dateFormat": "YYYY-MM-DD HH:mm:ss", - "decimals": 0, - "pattern": "/.*/", - "thresholds": [], - "type": "number", - "unit": "short" - } - ], - "targets": [ - { - "aggregator": "max", - "alias": "@username", - "dimensions": [ - { - "key": "flavor", - "value": "$all" - } - ], - "error": "", - "group": true, - "metric": "os_capacity.usage.user.days.count", - "period": "300", - "refId": "A" - } - ], - "title": "Number of Server Days per User", - "transform": "timeseries_aggregations", - "type": "table" - } - ], - "showTitle": false, - "titleSize": "h6", - "height": "250px", - "repeat": null, - "repeatRowId": null, - "repeatIteration": null, - "collapse": false - } - ] -} diff --git a/doc/source/conf.py b/doc/source/conf.py deleted file mode 100644 index e492ae3..0000000 --- a/doc/source/conf.py +++ /dev/null @@ -1,91 +0,0 @@ -# Copyright (c) 2017 StackHPC Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -# -*- coding: utf-8 -*- -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -# implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import os -import sys - -sys.path.insert(0, os.path.abspath('../..')) -# -- General configuration ---------------------------------------------------- - -# Add any Sphinx extension module names here, as strings. They can be -# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones. -extensions = [ - 'sphinx.ext.autodoc', - #'sphinx.ext.intersphinx', - # Uncomment this to enable the OpenStack documentation style, adding - # oslosphinx to test-requirements.txt. - #'oslosphinx', -] - -# autodoc generation is a bit aggressive and a nuisance when doing heavy -# text edit cycles. -# execute "export SPHINX_DEBUG=1" in your terminal to disable - -# The suffix of source filenames. -source_suffix = '.rst' - -# The master toctree document. -master_doc = 'index' - -# General information about the project. -project = u'os-capacity' -copyright = u'2017, StackHPC Ltd.' - -# If true, '()' will be appended to :func: etc. cross-reference text. -add_function_parentheses = True - -# If true, the current module name will be prepended to all description -# unit titles (such as .. function::). -add_module_names = True - -# The name of the Pygments (syntax highlighting) style to use. -pygments_style = 'sphinx' - -# -- Options for HTML output -------------------------------------------------- - -# The theme to use for HTML and HTML Help pages. Major themes that come with -# Sphinx are currently 'default' and 'sphinxdoc'. -# html_theme_path = ["."] -# html_theme = '_theme' -# html_static_path = ['static'] - -# Output file base name for HTML help builder. -htmlhelp_basename = '%sdoc' % project - -# Grouping the document tree into LaTeX files. List of tuples -# (source start file, target name, title, author, documentclass -# [howto/manual]). -latex_documents = [ - ('index', - '%s.tex' % project, - u'%s Documentation' % project, - u'OpenStack Foundation', 'manual'), -] - -# Example configuration for intersphinx: refer to the Python standard library. -#intersphinx_mapping = {'http://docs.python.org/': None} diff --git a/doc/source/development.rst b/doc/source/development.rst deleted file mode 100644 index 3982e78..0000000 --- a/doc/source/development.rst +++ /dev/null @@ -1,2 +0,0 @@ -TODO development -================ diff --git a/doc/source/index.rst b/doc/source/index.rst deleted file mode 100644 index ee8a183..0000000 --- a/doc/source/index.rst +++ /dev/null @@ -1,25 +0,0 @@ -Welcome to os-capacity's documentation! -======================================= - -.. include:: ../../README.rst - -Documentation -------------- - -.. note:: - - nothing to see here yet :( - -.. toctree:: - :maxdepth: 2 - - installation - usage - -Developer Documentation ------------------------ - -.. toctree:: - :maxdepth: 2 - - development diff --git a/doc/source/installation.rst b/doc/source/installation.rst deleted file mode 100644 index 30a8521..0000000 --- a/doc/source/installation.rst +++ /dev/null @@ -1,2 +0,0 @@ -TODO: Install -============= diff --git a/doc/source/usage.rst b/doc/source/usage.rst deleted file mode 100644 index 2adda45..0000000 --- a/doc/source/usage.rst +++ /dev/null @@ -1,2 +0,0 @@ -TODO: usage docs -================ diff --git a/horizon/_footer.html.example b/horizon/_footer.html.example deleted file mode 100644 index 735fdd2..0000000 --- a/horizon/_footer.html.example +++ /dev/null @@ -1,56 +0,0 @@ -

Capacity

- -

Note: this is stale data from Thu 7 Sep 13:04:05 BST 2017

- -
- - - - - - - -
FlavorsFreeUsedTotal
- - - - - diff --git a/horizon/config.json.example b/horizon/config.json.example deleted file mode 100644 index 7879b82..0000000 --- a/horizon/config.json.example +++ /dev/null @@ -1,17 +0,0 @@ -{ - "command": "/usr/sbin/httpd -DFOREGROUND", - "config_files": [ - { - "source": "/var/lib/kolla/config_files/horizon.conf", - "dest": "/etc/httpd/conf.d/horizon.conf", - "owner": "horizon", - "perm": "0600" - }, - { - "source": "/var/lib/kolla/config_files/_footer.html", - "dest": "/usr/share/openstack-dashboard/openstack_dashboard/templates/_login_footer.html", - "owner": "horizon", - "perm": "0600" - }, -... -} diff --git a/horizon/generate-footer.sh b/horizon/generate-footer.sh deleted file mode 100755 index 030aede..0000000 --- a/horizon/generate-footer.sh +++ /dev/null @@ -1,43 +0,0 @@ -set -ex - -CAPACITY=`os-capacity resources group -f json` -CURRENT_DATE=`date` - -cat >_footer.html <Capacity - -

Note: this is stale data from $CURRENT_DATE

- -
-
- - - - - - -
FlavorsFreeUsedTotal
- - - - - -EOF - -cat _footer.html diff --git a/os_capacity/prometheus.py b/os_capacity/prometheus.py index 8db0b18..309bf25 100755 --- a/os_capacity/prometheus.py +++ b/os_capacity/prometheus.py @@ -376,7 +376,7 @@ def collect(self): return guages -if __name__ == "__main__": +def main(): kwargs = { "port": int(os.environ.get("OS_CAPACITY_EXPORTER_PORT", 9000)), "addr": os.environ.get("OS_CAPACITY_EXPORTER_LISTEN_ADDRESS", "0.0.0.0"), @@ -387,3 +387,7 @@ def collect(self): # there must be a better way! while True: time.sleep(5000) + + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/setup.cfg b/setup.cfg index b1ce8f4..3600d32 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,10 +1,10 @@ [metadata] -name = kayobe +name = os_capacity summary = Deployment of Scientific OpenStack using OpenStack Kolla description-file = README.rst -author = Mark Goddard -author-email = mark@stackhpc.com +author = StackHPC +author-email = johng@stackhpc.com home-page = https://stackhpc.com classifier = Environment :: OpenStack @@ -12,17 +12,10 @@ classifier = Intended Audience :: System Administrators Operating System :: POSIX :: Linux Programming Language :: Python - Programming Language :: Python :: 2 - Programming Language :: Python :: 2.7 + Programming Language :: Python :: 3 + Programming Language :: Python :: 3.9 [files] packages = - kayobe + os_capacity -[build_sphinx] -all-files = 1 -source-dir = doc/source -build-dir = doc/build - -[upload_sphinx] -upload-dir = doc/build/html diff --git a/setup.py b/setup.py index 61272ae..a9061b6 100644 --- a/setup.py +++ b/setup.py @@ -19,7 +19,7 @@ PROJECT = 'os_capacity' -VERSION = '0.2' +VERSION = '0.4' try: long_description = open('README.md', 'rt').read() @@ -48,16 +48,7 @@ entry_points={ 'console_scripts': [ - 'os-capacity = os_capacity.shell:main', - ], - 'os_capacity.commands': [ - 'flavor_list = os_capacity.commands.commands:FlavorList', - 'resources_all = os_capacity.commands.commands:ListResourcesAll', - 'resources_group = os_capacity.commands' - '.commands:ListResourcesGroups', - 'usages_all = os_capacity.commands.commands:ListUsagesAll', - 'usages_group = os_capacity.commands.commands:ListUsagesGroup', - 'prometheus = os_capacity.commands.commands:PrometheusAll', + 'os-capacity = os_capacity.prometheus:main', ], }, ) diff --git a/tox.ini b/tox.ini index 87145c5..c817894 100644 --- a/tox.ini +++ b/tox.ini @@ -5,11 +5,10 @@ skipsdist = True [testenv] usedevelop = True -install_command = pip install -c{env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt?h=stable/yoga} {opts} {packages} +install_command = pip install {opts} {packages} setenv = VIRTUAL_ENV={envdir} PYTHONWARNINGS=default::DeprecationWarning - TESTS_DIR=./kayobe/tests/unit/ deps = -r{toxinidir}/test-requirements.txt commands = stestr run {posargs}