renaming monclient to monascaclient, alarm-update fix
Change-Id: I6027b3dbb5c75046181daa2bf2a94842e57300f9
This commit is contained in:
parent
f259f45095
commit
1a7232e105
|
@ -1,4 +1,4 @@
|
|||
python-monclient Style Commandments
|
||||
python-monascaclient Style Commandments
|
||||
===============================================
|
||||
|
||||
Read the OpenStack Style Commandments http://docs.openstack.org/developer/hacking/
|
102
README.rst
102
README.rst
|
@ -1,11 +1,11 @@
|
|||
Python bindings to the Monitoring API
|
||||
Python bindings to the Monasca API
|
||||
=======================================
|
||||
|
||||
This is a client library for Monitoring built to interface with the Monitoring API. It
|
||||
provides a Python API (the ``monclient`` module) and a command-line tool
|
||||
(``mon``).
|
||||
This is a client library for Monasca built to interface with the Monasca API. It
|
||||
provides a Python API (the ``monascaclient`` module) and a command-line tool
|
||||
(``monasca``).
|
||||
|
||||
The Monitoring Client was written using the OpenStack Heat Python client as a framework.
|
||||
The Monasca Client was written using the OpenStack Heat Python client as a framework.
|
||||
|
||||
.. contents:: Contents:
|
||||
:local:
|
||||
|
@ -16,32 +16,32 @@ Requires:
|
|||
- pip - version >= 1.4. python get-pip.py
|
||||
|
||||
Install It:
|
||||
- sudo pip install python-monclient
|
||||
- sudo pip install python-monascaclient
|
||||
|
||||
Alternative Manual Install Steps:
|
||||
- cd to your python-monclient repo
|
||||
- cd to your python-monascaclient repo
|
||||
- sudo pip install -r requirements.txt
|
||||
- python setup.py install
|
||||
|
||||
Command-line API
|
||||
----------------
|
||||
Installing this distribution gets you a shell command, ``mon``, that you
|
||||
Installing this distribution gets you a shell command, ``monasca``, that you
|
||||
can use to interact with the Monitoring API server.
|
||||
|
||||
Usage:
|
||||
mon
|
||||
monasca
|
||||
|
||||
mon help
|
||||
monasca help
|
||||
|
||||
mon help <command>
|
||||
monasca help <command>
|
||||
|
||||
mon -j <command>
|
||||
monasca -j <command>
|
||||
|
||||
This outputs the results in jason format. Normally output is in table format.
|
||||
|
||||
|
||||
The monclient CLI needs the Monitoring API endpoint url and the OS_AUTH_TOKEN to pass to the
|
||||
Monitoring API RESTful interface. This is provided through environment or CLI
|
||||
The monascaclient CLI needs the Monasca API endpoint url and the OS_AUTH_TOKEN to pass to the
|
||||
Monasca API RESTful interface. This is provided through environment or CLI
|
||||
parameters.
|
||||
|
||||
Environmental Variables
|
||||
|
@ -53,7 +53,7 @@ It is easiest to source them first and then use the CLI.
|
|||
When token and endpoint are known::
|
||||
|
||||
export OS_AUTH_TOKEN=XXX
|
||||
export MON_API_URL=http://192.168.10.4:8080/v2.0/
|
||||
export MONASCA_API_URL=http://192.168.10.4:8080/v2.0/
|
||||
|
||||
When using Keystone to obtain the token and endpoint::
|
||||
|
||||
|
@ -63,29 +63,29 @@ When using Keystone to obtain the token and endpoint::
|
|||
export OS_AUTH_URL=
|
||||
export OS_REGION_NAME=
|
||||
|
||||
When using Vagrant Environment for test which doesn't use Keystone::
|
||||
When using Vagrant Environment with middleware disabled::
|
||||
|
||||
export OS_AUTH_TOKEN=82510970543135
|
||||
export OS_NO_CLIENT_AUTH=1
|
||||
export MON_API_URL=http://192.168.10.4:8080/v2.0/
|
||||
export MONASCA_API_URL=http://192.168.10.4:8080/v2.0/
|
||||
|
||||
The Monitoring API will treat the auth token as the tenant ID when Keystone is not enabled, which is the case for the Vagrant develpment environment.
|
||||
The Monasca API will treat the auth token as the tenant ID when Keystone is not enabled.
|
||||
|
||||
You'll find complete documentation on the shell by running
|
||||
``mon help``::
|
||||
``monasca help``::
|
||||
|
||||
usage: mon [-j] [--version] [-d] [-v] [-k] [--cert-file CERT_FILE]
|
||||
usage: monasca [-j] [--version] [-d] [-v] [-k] [--cert-file CERT_FILE]
|
||||
[--key-file KEY_FILE] [--ca-file CA_FILE] [--timeout TIMEOUT]
|
||||
[--os-username OS_USERNAME] [--os-password OS_PASSWORD]
|
||||
[--os-tenant-id OS_TENANT_ID] [--os-tenant-name OS_TENANT_NAME]
|
||||
[--os-auth-url OS_AUTH_URL] [--os-region-name OS_REGION_NAME]
|
||||
[--os-auth-token OS_AUTH_TOKEN] [--os-no-client-auth]
|
||||
[--mon-api-url MON_API_URL] [--mon-api-version MON_API_VERSION]
|
||||
[--mon-api-url MONASCA_API_URL] [--mon-api-version MONASCA_API_VERSION]
|
||||
[--os-service-type OS_SERVICE_TYPE]
|
||||
[--os-endpoint-type OS_ENDPOINT_TYPE]
|
||||
<subcommand> ...
|
||||
|
||||
Command-line interface to the mon-client API.
|
||||
Command-line interface to the monasca-client API.
|
||||
|
||||
positional arguments:
|
||||
<subcommand>
|
||||
|
@ -114,7 +114,7 @@ You'll find complete documentation on the shell by running
|
|||
optional arguments:
|
||||
-j, --json output raw json response
|
||||
--version Shows the client version and exits.
|
||||
-d, --debug Defaults to env[MON_DEBUG].
|
||||
-d, --debug Defaults to env[MONASCA_DEBUG].
|
||||
-v, --verbose Print more verbose output.
|
||||
-k, --insecure Explicitly allow the client to perform "insecure" SSL
|
||||
(https) requests. The server's certificate will not
|
||||
|
@ -146,10 +146,10 @@ You'll find complete documentation on the shell by running
|
|||
Defaults to env[OS_AUTH_TOKEN].
|
||||
--os-no-client-auth Do not contact keystone for a token. Defaults to
|
||||
env[OS_NO_CLIENT_AUTH].
|
||||
--mon-api-url MON_API_URL
|
||||
Defaults to env[MON_API_URL].
|
||||
--mon-api-version MON_API_VERSION
|
||||
Defaults to env[MON_API_VERSION] or 2_0
|
||||
--mon-api-url MONASCA_API_URL
|
||||
Defaults to env[MONASCA_API_URL].
|
||||
--mon-api-version MONASCA_API_VERSION
|
||||
Defaults to env[MONASCA_API_VERSION] or 2_0
|
||||
--os-service-type OS_SERVICE_TYPE
|
||||
Defaults to env[OS_SERVICE_TYPE].
|
||||
--os-endpoint-type OS_ENDPOINT_TYPE
|
||||
|
@ -163,7 +163,7 @@ Bash Completion
|
|||
Basic command tab completion can be enabled by sourcing the bash completion script.
|
||||
::
|
||||
|
||||
source /usr/local/share/mon.bash_completion
|
||||
source /usr/local/share/monasca.bash_completion
|
||||
|
||||
|
||||
Metrics Examples
|
||||
|
@ -172,14 +172,14 @@ Note: this is not meant to be a complete list.
|
|||
|
||||
metric-create::
|
||||
|
||||
mon metric-create cpu1 123.40
|
||||
mon metric-create metric1 1234.56 --dimensions instance_id=123,service=ourservice
|
||||
mon metric-create metric1 2222.22 --dimensions instance_id=123,service=ourservice
|
||||
mon metric-create metric1 3333.33 --dimensions instance_id=222,service=ourservice
|
||||
monasca metric-create cpu1 123.40
|
||||
monasca metric-create metric1 1234.56 --dimensions instance_id=123,service=ourservice
|
||||
monasca metric-create metric1 2222.22 --dimensions instance_id=123,service=ourservice
|
||||
monasca metric-create metric1 3333.33 --dimensions instance_id=222,service=ourservice
|
||||
|
||||
metric-list::
|
||||
|
||||
mon metric-list
|
||||
monasca metric-list
|
||||
+---------+--------------------+
|
||||
| name | dimensions |
|
||||
+---------+--------------------+
|
||||
|
@ -190,7 +190,7 @@ metric-list::
|
|||
|
||||
measurement-list::
|
||||
|
||||
mon measurement-list metric1 2014-01-01T00:00:00Z
|
||||
monasca measurement-list metric1 2014-01-01T00:00:00Z
|
||||
+---------+--------------------+----------------+----------------------+--------------+
|
||||
| name | dimensions | measurement_id | timestamp | value |
|
||||
+---------+--------------------+----------------+----------------------+--------------+
|
||||
|
@ -200,7 +200,7 @@ measurement-list::
|
|||
| | service:ourservice | | | |
|
||||
+---------+--------------------+----------------+----------------------+--------------+
|
||||
|
||||
mon measurement-list metric1 2014-01-01T00:00:00Z --dimensions instance_id=123
|
||||
monasca measurement-list metric1 2014-01-01T00:00:00Z --dimensions instance_id=123
|
||||
+---------+--------------------+----------------+----------------------+--------------+
|
||||
| name | dimensions | measurement_id | timestamp | value |
|
||||
+---------+--------------------+----------------+----------------------+--------------+
|
||||
|
@ -215,11 +215,11 @@ Note: this is not meant to be a complete list.
|
|||
|
||||
notification-create::
|
||||
|
||||
mon notification-create cindyemail1 EMAIL cindy.employee@hp.com
|
||||
monasca notification-create cindyemail1 EMAIL cindy.employee@hp.com
|
||||
|
||||
notification-list::
|
||||
|
||||
mon notification-list
|
||||
monasca notification-list
|
||||
+---------------+--------------------------------------+-------+----------------------+
|
||||
| name | id | type | address |
|
||||
+---------------+--------------------------------------+-------+----------------------+
|
||||
|
@ -233,13 +233,13 @@ Note: this is not meant to be a complete list.
|
|||
|
||||
alarm-create::
|
||||
|
||||
mon alarm-create cpu1alarm 'cpu1>10'
|
||||
mon alarm-create cpu2alarm 'cpu1>99' --severity HIGH
|
||||
mon alarm-create test1alarm1 'avg(metric1{instance_id=123)>=10' --severity CRITICAL --description 'avg greater than thresh' --alarm-actions 5651406c-447d-40bd-b868-b2b3e6b59e32
|
||||
monasca alarm-create cpu1alarm 'cpu1>10'
|
||||
monasca alarm-create cpu2alarm 'cpu1>99' --severity HIGH
|
||||
monasca alarm-create test1alarm1 'avg(metric1{instance_id=123)>=10' --severity CRITICAL --description 'avg greater than thresh' --alarm-actions 5651406c-447d-40bd-b868-b2b3e6b59e32
|
||||
|
||||
alarm-list::
|
||||
|
||||
mon alarm-list
|
||||
monasca alarm-list
|
||||
+-------------+--------------------------------------+------------------------------------+--------------+-----------------+
|
||||
| name | id | expression | state | actions_enabled |
|
||||
+-------------+--------------------------------------+------------------------------------+--------------+-----------------+
|
||||
|
@ -250,7 +250,7 @@ alarm-list::
|
|||
|
||||
alarm-show::
|
||||
|
||||
mon alarm-show c81e1d40-2115-4557-96f4-eda6b8823fd6
|
||||
monasca alarm-show c81e1d40-2115-4557-96f4-eda6b8823fd6
|
||||
+----------------------+----------------------------------------------------------------------------------------------------+
|
||||
| Property | Value |
|
||||
+----------------------+----------------------------------------------------------------------------------------------------+
|
||||
|
@ -281,7 +281,7 @@ alarm-show::
|
|||
|
||||
alarm-patch::
|
||||
|
||||
mon alarm-patch c81e1d40-2115-4557-96f4-eda6b8823fd6 --state OK
|
||||
monasca alarm-patch c81e1d40-2115-4557-96f4-eda6b8823fd6 --state OK
|
||||
|
||||
|
||||
Python API
|
||||
|
@ -290,17 +290,17 @@ Python API
|
|||
There's also a complete Python API.
|
||||
|
||||
In order to use the python api directly, you must first obtain an auth token and
|
||||
identify the monitoring api endpoint.
|
||||
identify the monasca api endpoint.
|
||||
|
||||
The api_version matches the version of the Monitoring API. Currently it is 'v2_0'.
|
||||
The api_version matches the version of the Monasca API. Currently it is 'v2_0'.
|
||||
|
||||
When calling the commands, refer to monclient.v2_0.shell.py 'do_<command>'
|
||||
When calling the commands, refer to monascaclient.v2_0.shell.py 'do_<command>'
|
||||
to see the required and optional fields for each command.
|
||||
|
||||
Refer to this example in python-monclient/client_api_example.py::
|
||||
Refer to this example in python-monascaclient/client_api_example.py::
|
||||
|
||||
from monclient import client
|
||||
import monclient.exc as exc
|
||||
from monascaclient import client
|
||||
import monascaclient.exc as exc
|
||||
import time
|
||||
|
||||
api_version = '2_0'
|
||||
|
@ -310,7 +310,7 @@ Refer to this example in python-monclient/client_api_example.py::
|
|||
}
|
||||
|
||||
# construct the mon client
|
||||
mon_client = client.Client(api_version, endpoint, **kwargs)
|
||||
monasca_client = client.Client(api_version, endpoint, **kwargs)
|
||||
|
||||
# call the metric-create command
|
||||
dimensions = {'instance_id': '12345', 'service': 'hello'}
|
||||
|
@ -320,7 +320,7 @@ Refer to this example in python-monclient/client_api_example.py::
|
|||
fields['timestamp'] = time.time()
|
||||
fields['value'] = 222.333
|
||||
try:
|
||||
resp = mon_client.metrics.create(**fields)
|
||||
resp = monasca_client.metrics.create(**fields)
|
||||
except exc.HTTPException as he:
|
||||
print(he.code)
|
||||
print(he.message)
|
||||
|
|
|
@ -13,32 +13,32 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
""" An example using monclient via the Python API """
|
||||
""" An example using monascaclient via the Python API """
|
||||
|
||||
from monclient import client
|
||||
import monclient.exc as exc
|
||||
from monascaclient import client
|
||||
import monascaclient.exc as exc
|
||||
import time
|
||||
|
||||
# In order to use the python api directly, you must first obtain an
|
||||
# auth token and identify which endpoint you wish to speak to.
|
||||
endpoint = 'http://192.168.10.4:8080/v2.0'
|
||||
|
||||
# The api version of mon-api
|
||||
# The api version of monasca-api
|
||||
api_version = '2_0'
|
||||
|
||||
# There are other kwarg options (ca files) used for http request.
|
||||
# Refer to monclient.shell.py for other kwargs supported.
|
||||
# Refer to monascaclient.shell.py for other kwargs supported.
|
||||
kwargs = {}
|
||||
|
||||
kwargs['token'] = 'Mehi789blahblahblah'
|
||||
# construct the mon client
|
||||
mon_client = client.Client(api_version, endpoint, **kwargs)
|
||||
# construct the monasca client
|
||||
monasca_client = client.Client(api_version, endpoint, **kwargs)
|
||||
|
||||
# simulating token expired, call replace_token after initial construction
|
||||
token = 'MIIPtAYJKoZIhvcNAQcCoIIPpTCCD6ECAQblahblahblah'
|
||||
mon_client.replace_token(token)
|
||||
monasca_client.replace_token(token)
|
||||
|
||||
# you can reference the monclient.v2_0.shell.py
|
||||
# you can reference the monascaclient.v2_0.shell.py
|
||||
# do_commands for command fields
|
||||
|
||||
# post a metric
|
||||
|
@ -49,7 +49,7 @@ fields['dimensions'] = dimensions
|
|||
fields['timestamp'] = time.time()
|
||||
fields['value'] = 222.333
|
||||
try:
|
||||
resp = mon_client.metrics.create(**fields)
|
||||
resp = monasca_client.metrics.create(**fields)
|
||||
except exc.HTTPException as he:
|
||||
print('HTTPException code=%s message=%s' % (he.code, he.message))
|
||||
else:
|
||||
|
@ -66,7 +66,7 @@ if name:
|
|||
if dimensions:
|
||||
fields['dimensions'] = dimensions
|
||||
try:
|
||||
body = mon_client.metrics.list(**fields)
|
||||
body = monasca_client.metrics.list(**fields)
|
||||
except exc.HTTPException as he:
|
||||
print('HTTPException code=%s message=%s' % (he.code, he.message))
|
||||
else:
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from monclient.common import utils
|
||||
from monascaclient.common import utils
|
||||
|
||||
|
||||
def Client(version, *args, **kwargs):
|
|
@ -21,15 +21,15 @@ import socket
|
|||
import requests
|
||||
import six
|
||||
|
||||
from monclient import exc
|
||||
from monclient.openstack.common import jsonutils
|
||||
from monclient.openstack.common.py3kcompat import urlutils
|
||||
from monclient.openstack.common import strutils
|
||||
from monascaclient import exc
|
||||
from monascaclient.openstack.common import jsonutils
|
||||
from monascaclient.openstack.common.py3kcompat import urlutils
|
||||
from monascaclient.openstack.common import strutils
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
if not LOG.handlers:
|
||||
LOG.addHandler(logging.StreamHandler())
|
||||
USER_AGENT = 'python-monclient'
|
||||
USER_AGENT = 'python-monascaclient'
|
||||
CHUNKSIZE = 1024 * 64 # 64kB
|
||||
|
||||
|
||||
|
@ -185,7 +185,7 @@ class HTTPClient(object):
|
|||
raise exc.HTTPUnauthorized("Authentication failed. Please try"
|
||||
" again with option "
|
||||
"--include-password or export "
|
||||
"MON_INCLUDE_PASSWORD=1\n%s"
|
||||
"MONASCA_INCLUDE_PASSWORD=1\n%s"
|
||||
% resp.content)
|
||||
elif 400 <= resp.status_code < 600:
|
||||
raise exc.from_response(resp)
|
|
@ -13,13 +13,13 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from monclient.openstack.common.apiclient import base
|
||||
from monascaclient.openstack.common.apiclient import base
|
||||
|
||||
|
||||
class MonManager(base.BaseManager):
|
||||
class MonascaManager(base.BaseManager):
|
||||
|
||||
def __init__(self, client, **kwargs):
|
||||
super(MonManager, self).__init__(client)
|
||||
super(MonascaManager, self).__init__(client)
|
||||
|
||||
def get_headers(self):
|
||||
headers = self.client.credentials_headers()
|
|
@ -22,9 +22,9 @@ import textwrap
|
|||
import uuid
|
||||
import yaml
|
||||
|
||||
from monclient import exc
|
||||
from monclient.openstack.common import importutils
|
||||
from monclient.openstack.common import jsonutils
|
||||
from monascaclient import exc
|
||||
from monascaclient.openstack.common import importutils
|
||||
from monascaclient.openstack.common import jsonutils
|
||||
|
||||
supported_formats = {
|
||||
"json": lambda x: jsonutils.dumps(x, indent=2),
|
||||
|
@ -131,7 +131,7 @@ def env(*vars, **kwargs):
|
|||
|
||||
|
||||
def import_versioned_module(version, submodule=None):
|
||||
module = 'monclient.v%s' % version
|
||||
module = 'monascaclient.v%s' % version
|
||||
if submodule:
|
||||
module = '.'.join((module, submodule))
|
||||
return importutils.import_module(module)
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
import sys
|
||||
|
||||
from monclient.openstack.common import jsonutils
|
||||
from monascaclient.openstack.common import jsonutils
|
||||
|
||||
verbose = 0
|
||||
|
||||
|
@ -80,7 +80,7 @@ class HTTPMultipleChoices(HTTPException):
|
|||
code = 300
|
||||
|
||||
def __str__(self):
|
||||
self.details = ("Requested version of Mon API is not"
|
||||
self.details = ("Requested version of Monasca API is not"
|
||||
"available.")
|
||||
return "%s (HTTP %s) %s" % (self.__class__.__name__, self.code,
|
||||
self.details)
|
|
@ -28,9 +28,9 @@ import copy
|
|||
|
||||
import six
|
||||
|
||||
from monclient.openstack.common.apiclient import exceptions
|
||||
from monclient.openstack.common.py3kcompat import urlutils
|
||||
from monclient.openstack.common import strutils
|
||||
from monascaclient.openstack.common.apiclient import exceptions
|
||||
from monascaclient.openstack.common.py3kcompat import urlutils
|
||||
from monascaclient.openstack.common import strutils
|
||||
|
||||
|
||||
def getid(obj):
|
|
@ -21,7 +21,7 @@ gettext for openstack-common modules.
|
|||
|
||||
Usual usage in an openstack.common module:
|
||||
|
||||
from monclient.openstack.common.gettextutils import _
|
||||
from monascaclient.openstack.common.gettextutils import _
|
||||
"""
|
||||
|
||||
import copy
|
||||
|
@ -37,8 +37,8 @@ except ImportError:
|
|||
from babel import localedata
|
||||
import six
|
||||
|
||||
_localedir = os.environ.get('monclient'.upper() + '_LOCALEDIR')
|
||||
_t = gettext.translation('monclient', localedir=_localedir, fallback=True)
|
||||
_localedir = os.environ.get('monascaclient'.upper() + '_LOCALEDIR')
|
||||
_t = gettext.translation('monascaclient', localedir=_localedir, fallback=True)
|
||||
|
||||
_AVAILABLE_LANGUAGES = {}
|
||||
USE_LAZY = False
|
||||
|
@ -58,7 +58,7 @@ def enable_lazy():
|
|||
|
||||
def _(msg):
|
||||
if USE_LAZY:
|
||||
return Message(msg, 'monclient')
|
||||
return Message(msg, 'monascaclient')
|
||||
else:
|
||||
if six.PY3:
|
||||
return _t.gettext(msg)
|
|
@ -48,9 +48,9 @@ except ImportError:
|
|||
|
||||
import six
|
||||
|
||||
from monclient.openstack.common import gettextutils
|
||||
from monclient.openstack.common import importutils
|
||||
from monclient.openstack.common import timeutils
|
||||
from monascaclient.openstack.common import gettextutils
|
||||
from monascaclient.openstack.common import importutils
|
||||
from monascaclient.openstack.common import timeutils
|
||||
|
||||
netaddr = importutils.try_import("netaddr")
|
||||
|
|
@ -23,7 +23,7 @@ import unicodedata
|
|||
|
||||
import six
|
||||
|
||||
from monclient.openstack.common.gettextutils import _ # noqa
|
||||
from monascaclient.openstack.common.gettextutils import _ # noqa
|
||||
|
||||
|
||||
# Used for looking up extensions of text
|
|
@ -14,7 +14,7 @@
|
|||
# limitations under the License.
|
||||
|
||||
"""
|
||||
Command-line interface to the mon-client API.
|
||||
Command-line interface to the monasca-client API.
|
||||
"""
|
||||
|
||||
from __future__ import print_function
|
||||
|
@ -26,21 +26,21 @@ import sys
|
|||
|
||||
from keystoneclient.v2_0 import client as ksclient
|
||||
|
||||
from monclient import client as mon_client
|
||||
from monclient.common import utils
|
||||
from monclient import exc
|
||||
from monclient.openstack.common import strutils
|
||||
from monascaclient import client as monasca_client
|
||||
from monascaclient.common import utils
|
||||
from monascaclient import exc
|
||||
from monascaclient.openstack.common import strutils
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class MonShell(object):
|
||||
class MonascaShell(object):
|
||||
|
||||
def get_base_parser(self):
|
||||
parser = argparse.ArgumentParser(
|
||||
prog='mon',
|
||||
prog='monasca',
|
||||
description=__doc__.strip(),
|
||||
epilog='See "mon help COMMAND" '
|
||||
epilog='See "monasca help COMMAND" '
|
||||
'for help on a specific command.',
|
||||
add_help=False,
|
||||
# formatter_class=HelpFormatter,
|
||||
|
@ -64,9 +64,9 @@ class MonShell(object):
|
|||
help="Shows the client version and exits.")
|
||||
|
||||
parser.add_argument('-d', '--debug',
|
||||
default=bool(utils.env('MON_DEBUG')),
|
||||
default=bool(utils.env('MONASCA_DEBUG')),
|
||||
action='store_true',
|
||||
help='Defaults to env[MON_DEBUG].')
|
||||
help='Defaults to env[MONASCA_DEBUG].')
|
||||
|
||||
parser.add_argument('-v', '--verbose',
|
||||
default=False, action="store_true",
|
||||
|
@ -156,20 +156,20 @@ class MonShell(object):
|
|||
help="Do not contact keystone for a token. "
|
||||
"Defaults to env[OS_NO_CLIENT_AUTH].")
|
||||
|
||||
parser.add_argument('--mon-api-url',
|
||||
default=utils.env('MON_API_URL'),
|
||||
help='Defaults to env[MON_API_URL].')
|
||||
parser.add_argument('--monasca-api-url',
|
||||
default=utils.env('MONASCA_API_URL'),
|
||||
help='Defaults to env[MONASCA_API_URL].')
|
||||
|
||||
parser.add_argument('--mon_api_url',
|
||||
parser.add_argument('--monasca_api_url',
|
||||
help=argparse.SUPPRESS)
|
||||
|
||||
parser.add_argument('--mon-api-version',
|
||||
parser.add_argument('--monasca-api-version',
|
||||
default=utils.env(
|
||||
'MON_API_VERSION',
|
||||
'MONASCA_API_VERSION',
|
||||
default='2_0'),
|
||||
help='Defaults to env[MON_API_VERSION] or 2_0')
|
||||
help='Defaults to env[MONASCA_API_VERSION] or 2_0')
|
||||
|
||||
parser.add_argument('--mon_api_version',
|
||||
parser.add_argument('--monasca_api_version',
|
||||
help=argparse.SUPPRESS)
|
||||
|
||||
parser.add_argument('--os-service-type',
|
||||
|
@ -287,7 +287,7 @@ class MonShell(object):
|
|||
self._setup_verbose(options.verbose)
|
||||
|
||||
# build available subcommands based on version
|
||||
api_version = options.mon_api_version
|
||||
api_version = options.monasca_api_version
|
||||
subcommand_parser = self.get_subcommand_parser(api_version)
|
||||
self.parser = subcommand_parser
|
||||
|
||||
|
@ -321,11 +321,11 @@ class MonShell(object):
|
|||
" env[OS_AUTH_TOKEN]")
|
||||
|
||||
if args.os_no_client_auth:
|
||||
if not args.mon_api_url:
|
||||
if not args.monasca_api_url:
|
||||
raise exc.CommandError("If you specify --os-no-client-auth"
|
||||
" you must specify a Monitoring API URL"
|
||||
" via either --mon-api-url or"
|
||||
" env[MON_API_URL]")
|
||||
" you must specify a Monasca API URL"
|
||||
" via either --monasca-api-url or"
|
||||
" env[MONASCA_API_URL]")
|
||||
else:
|
||||
# Tenant name or ID is needed to make keystoneclient retrieve a
|
||||
# service catalog, it's not required if os_no_client_auth is
|
||||
|
@ -352,7 +352,7 @@ class MonShell(object):
|
|||
'insecure': args.insecure
|
||||
}
|
||||
|
||||
endpoint = args.mon_api_url
|
||||
endpoint = args.monasca_api_url
|
||||
if endpoint.endswith('/'):
|
||||
endpoint = endpoint[:-1]
|
||||
|
||||
|
@ -378,14 +378,14 @@ class MonShell(object):
|
|||
if not endpoint:
|
||||
endpoint = self._get_endpoint(_ksclient, **kwargs)
|
||||
|
||||
client = mon_client.Client(api_version, endpoint, **kwargs)
|
||||
client = monasca_client.Client(api_version, endpoint, **kwargs)
|
||||
|
||||
args.func(client, args)
|
||||
|
||||
def do_bash_completion(self, args):
|
||||
"""Prints all of the commands and options to stdout.
|
||||
|
||||
The mon.bash_completion script doesn't have to hard code them.
|
||||
The monasca.bash_completion script doesn't have to hard code them.
|
||||
"""
|
||||
commands = set()
|
||||
options = set()
|
||||
|
@ -425,7 +425,7 @@ def main(args=None):
|
|||
if args is None:
|
||||
args = sys.argv[1:]
|
||||
|
||||
MonShell().main(args)
|
||||
MonascaShell().main(args)
|
||||
except Exception as e:
|
||||
if '--debug' in args or '-d' in args:
|
||||
raise
|
|
@ -14,7 +14,7 @@
|
|||
# limitations under the License.
|
||||
|
||||
from keystoneclient.v2_0 import client as ksclient
|
||||
from monclient.openstack.common import jsonutils
|
||||
from monascaclient.openstack.common import jsonutils
|
||||
|
||||
|
||||
def script_keystone_client(token=None):
|
||||
|
@ -36,7 +36,7 @@ def fake_headers():
|
|||
return {'X-Auth-Token': 'abcd1234',
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json',
|
||||
'User-Agent': 'python-monclient'}
|
||||
'User-Agent': 'python-monascaclient'}
|
||||
|
||||
|
||||
class FakeServiceCatalog():
|
|
@ -21,10 +21,10 @@ import fixtures
|
|||
import testtools
|
||||
|
||||
from keystoneclient.v2_0 import client as ksclient
|
||||
from monclient.common import http
|
||||
from monclient import exc
|
||||
import monclient.shell
|
||||
from monclient.tests import fakes
|
||||
from monascaclient.common import http
|
||||
from monascaclient import exc
|
||||
import monascaclient.shell
|
||||
from monascaclient.tests import fakes
|
||||
from mox3 import mox
|
||||
|
||||
|
||||
|
@ -34,7 +34,7 @@ class TestCase(testtools.TestCase):
|
|||
client_env = ('OS_USERNAME', 'OS_PASSWORD', 'OS_TENANT_ID',
|
||||
'OS_TENANT_NAME', 'OS_AUTH_URL', 'OS_REGION_NAME',
|
||||
'OS_AUTH_TOKEN', 'OS_NO_CLIENT_AUTH', 'OS_SERVICE_TYPE',
|
||||
'OS_ENDPOINT_TYPE', 'MON_API_URL')
|
||||
'OS_ENDPOINT_TYPE', 'MONASCA_API_URL')
|
||||
|
||||
for key in client_env:
|
||||
self.useFixture(
|
||||
|
@ -54,7 +54,7 @@ class TestCase(testtools.TestCase):
|
|||
def shell_error(self, argstr, error_match):
|
||||
orig = sys.stderr
|
||||
sys.stderr = six.StringIO()
|
||||
_shell = monclient.shell.MonShell()
|
||||
_shell = monascaclient.shell.MonascaShell()
|
||||
e = self.assertRaises(Exception, _shell.main, argstr.split())
|
||||
self.assertRegexpMatches(e.__str__(), error_match)
|
||||
err = sys.stderr.getvalue()
|
||||
|
@ -84,7 +84,7 @@ class ShellBase(TestCase):
|
|||
orig = sys.stdout
|
||||
try:
|
||||
sys.stdout = six.StringIO()
|
||||
_shell = monclient.shell.MonShell()
|
||||
_shell = monascaclient.shell.MonascaShell()
|
||||
_shell.main(argstr.split())
|
||||
self.subcommands = _shell.subcommands.keys()
|
||||
except SystemExit:
|
||||
|
@ -108,8 +108,8 @@ class ShellTestCommon(ShellBase):
|
|||
|
||||
def test_help(self):
|
||||
required = [
|
||||
'^usage: mon',
|
||||
'(?m)^See "mon help COMMAND" for help on a specific command',
|
||||
'^usage: monasca',
|
||||
'(?m)^See "monasca help COMMAND" for help on a specific command',
|
||||
]
|
||||
for argstr in ['--help', 'help']:
|
||||
help_text = self.shell(argstr)
|
||||
|
@ -118,7 +118,7 @@ class ShellTestCommon(ShellBase):
|
|||
|
||||
def test_command_help(self):
|
||||
output = self.shell('help help')
|
||||
self.assertIn('usage: mon help [<subcommand>]', output)
|
||||
self.assertIn('usage: monasca help [<subcommand>]', output)
|
||||
subcommands = list(self.subcommands)
|
||||
for command in subcommands:
|
||||
if command.replace('_', '-') == 'bash-completion':
|
||||
|
@ -126,11 +126,11 @@ class ShellTestCommon(ShellBase):
|
|||
output1 = self.shell('help %s' % command)
|
||||
output2 = self.shell('%s --help' % command)
|
||||
self.assertEqual(output1, output2)
|
||||
self.assertRegexpMatches(output1, '^usage: mon %s' % command)
|
||||
self.assertRegexpMatches(output1, '^usage: monasca %s' % command)
|
||||
|
||||
def test_help_on_subcommand(self):
|
||||
required = [
|
||||
'^usage: mon metric-create',
|
||||
'^usage: monasca metric-create',
|
||||
"(?m)^Create metric",
|
||||
]
|
||||
argstrings = [
|
||||
|
@ -142,10 +142,10 @@ class ShellTestCommon(ShellBase):
|
|||
self.assertRegexpMatches(help_text, r)
|
||||
|
||||
|
||||
class ShellTestMonCommands(ShellBase):
|
||||
class ShellTestMonascaCommands(ShellBase):
|
||||
|
||||
def setUp(self):
|
||||
super(ShellTestMonCommands, self).setUp()
|
||||
super(ShellTestMonascaCommands, self).setUp()
|
||||
self._set_fake_env()
|
||||
|
||||
def _set_fake_env(self):
|
||||
|
@ -166,7 +166,7 @@ class ShellTestMonCommands(ShellBase):
|
|||
'metric-create 123',
|
||||
'metric-create',
|
||||
]
|
||||
_shell = monclient.shell.MonShell()
|
||||
_shell = monascaclient.shell.MonascaShell()
|
||||
for argstr in argstrings:
|
||||
self.assertRaises(SystemExit, _shell.main, argstr.split())
|
||||
|
||||
|
@ -201,7 +201,7 @@ class ShellTestMonCommands(ShellBase):
|
|||
argstrings = [
|
||||
'notification-create email1 metric1@hp.com',
|
||||
]
|
||||
_shell = monclient.shell.MonShell()
|
||||
_shell = monascaclient.shell.MonascaShell()
|
||||
for argstr in argstrings:
|
||||
self.assertRaises(SystemExit, _shell.main, argstr.split())
|
||||
|
|
@ -15,4 +15,4 @@
|
|||
|
||||
__all__ = ['Client']
|
||||
|
||||
from monclient.v2_0.client import Client
|
||||
from monascaclient.v2_0.client import Client
|
|
@ -13,9 +13,9 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from monclient.common import mon_manager
|
||||
from monclient.openstack.common.apiclient import base
|
||||
from monclient.openstack.common.py3kcompat import urlutils
|
||||
from monascaclient.common import monasca_manager
|
||||
from monascaclient.openstack.common.apiclient import base
|
||||
from monascaclient.openstack.common.py3kcompat import urlutils
|
||||
|
||||
|
||||
class Alarms(base.Resource):
|
||||
|
@ -24,7 +24,7 @@ class Alarms(base.Resource):
|
|||
return "<Alarms %s>" % self._info
|
||||
|
||||
|
||||
class AlarmsManager(mon_manager.MonManager):
|
||||
class AlarmsManager(monasca_manager.MonascaManager):
|
||||
resource_class = Alarms
|
||||
base_url = '/alarms'
|
||||
|
|
@ -13,17 +13,17 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from monclient.common import http
|
||||
from monclient.v2_0 import alarms
|
||||
from monclient.v2_0 import metrics
|
||||
from monclient.v2_0 import notifications
|
||||
from monascaclient.common import http
|
||||
from monascaclient.v2_0 import alarms
|
||||
from monascaclient.v2_0 import metrics
|
||||
from monascaclient.v2_0 import notifications
|
||||
|
||||
|
||||
class Client(object):
|
||||
|
||||
"""Client for the Mon v2_0 API.
|
||||
"""Client for the Monasca v2_0 API.
|
||||
|
||||
:param string endpoint: A user-supplied endpoint URL for the monitoring api
|
||||
:param string endpoint: A user-supplied endpoint URL for the monasca api
|
||||
service.
|
||||
:param string token: Token for authentication.
|
||||
:param integer timeout: Allows customization of the timeout for client
|
||||
|
@ -31,7 +31,7 @@ class Client(object):
|
|||
"""
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
"""Initialize a new http client for the mon API."""
|
||||
"""Initialize a new http client for the monasca API."""
|
||||
self.http_client = http.HTTPClient(*args, **kwargs)
|
||||
self.metrics = metrics.MetricsManager(self.http_client)
|
||||
self.notifications = notifications.NotificationsManager(
|
|
@ -13,9 +13,9 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from monclient.common import mon_manager
|
||||
from monclient.openstack.common.apiclient import base
|
||||
from monclient.openstack.common.py3kcompat import urlutils
|
||||
from monascaclient.common import monasca_manager
|
||||
from monascaclient.openstack.common.apiclient import base
|
||||
from monascaclient.openstack.common.py3kcompat import urlutils
|
||||
|
||||
|
||||
class Metrics(base.Resource):
|
||||
|
@ -24,7 +24,7 @@ class Metrics(base.Resource):
|
|||
return "<Metrics %s>" % self._info
|
||||
|
||||
|
||||
class MetricsManager(mon_manager.MonManager):
|
||||
class MetricsManager(monasca_manager.MonascaManager):
|
||||
resource_class = Metrics
|
||||
base_url = '/metrics'
|
||||
|
|
@ -13,8 +13,8 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from monclient.common import mon_manager
|
||||
from monclient.openstack.common.apiclient import base
|
||||
from monascaclient.common import monasca_manager
|
||||
from monascaclient.openstack.common.apiclient import base
|
||||
|
||||
|
||||
class Notifications(base.Resource):
|
||||
|
@ -23,7 +23,7 @@ class Notifications(base.Resource):
|
|||
return "<Notifications %s>" % self._info
|
||||
|
||||
|
||||
class NotificationsManager(mon_manager.MonManager):
|
||||
class NotificationsManager(monasca_manager.MonascaManager):
|
||||
resource_class = Notifications
|
||||
base_url = '/notification-methods'
|
||||
|
|
@ -14,9 +14,9 @@
|
|||
# limitations under the License.
|
||||
|
||||
import json
|
||||
from monclient.common import utils
|
||||
import monclient.exc as exc
|
||||
from monclient.openstack.common import jsonutils
|
||||
from monascaclient.common import utils
|
||||
import monascaclient.exc as exc
|
||||
from monascaclient.openstack.common import jsonutils
|
||||
import time
|
||||
|
||||
|
||||
|
@ -614,7 +614,7 @@ def do_alarm_delete(mc, args):
|
|||
help='The notification method to use when an alarm state is '
|
||||
'UNDETERMINED. This param may be specified multiple times.',
|
||||
action='append')
|
||||
@utils.arg('actions-enabled', metavar='<ACTIONS-ENABLED>',
|
||||
@utils.arg('actions_enabled', metavar='<ACTIONS-ENABLED>',
|
||||
help='The actions-enabled boolean is one of [true,false]')
|
||||
@utils.arg('state', metavar='<STATE>',
|
||||
help='The alarm state. State is one of [UNDETERMINED,ALARM,OK]')
|
|
@ -5,4 +5,4 @@ modules=importutils,gettextutils,strutils,apiclient.base,apiclient.exceptions
|
|||
module=py3kcompat
|
||||
|
||||
# The base module to hold the copy of openstack.common
|
||||
base=monclient
|
||||
base=monascaclient
|
||||
|
|
|
@ -4,7 +4,7 @@ BASE_DIR=`dirname $0`
|
|||
|
||||
function usage {
|
||||
echo "Usage: $0 [OPTION]..."
|
||||
echo "Run monclient test suite(s)"
|
||||
echo "Run monascaclient test suite(s)"
|
||||
echo ""
|
||||
echo " -V, --virtual-env Use virtualenv. Install automatically if not present."
|
||||
echo " (Default is to run tests in local environment)"
|
||||
|
@ -49,7 +49,7 @@ function run_tests {
|
|||
if [ "$args" = "" ]; then
|
||||
# Default to running all tests if specific test is not
|
||||
# provided.
|
||||
testrargs="discover ./monclient/tests"
|
||||
testrargs="discover ./monascaclient/tests"
|
||||
fi
|
||||
${wrapper} python -m testtools.run $args $testrargs
|
||||
|
||||
|
|
|
@ -18,13 +18,13 @@ classifier =
|
|||
Programming Language :: Python :: 3.3
|
||||
|
||||
[files]
|
||||
packages = monclient
|
||||
packages = monascaclient
|
||||
data_files =
|
||||
/usr/local/share = tools/mon.bash_completion
|
||||
/usr/local/share = tools/monasca.bash_completion
|
||||
|
||||
[entry_points]
|
||||
console_scripts =
|
||||
mon = monclient.shell:main
|
||||
monasca = monascaclient.shell:main
|
||||
|
||||
[pbr]
|
||||
autodoc_index_modules = True
|
||||
|
|
|
@ -1,27 +0,0 @@
|
|||
# bash completion for openstack mon
|
||||
|
||||
_mon_opts="" # lazy init
|
||||
_mon_flags="" # lazy init
|
||||
_mon_opts_exp="" # lazy init
|
||||
_mon()
|
||||
{
|
||||
local cur prev kbc
|
||||
COMPREPLY=()
|
||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||
|
||||
if [ "x$_mon_opts" == "x" ] ; then
|
||||
kbc="`mon bash-completion | sed -e "s/ -h / /"`"
|
||||
_mon_opts="`echo "$kbc" | sed -e "s/--[a-z0-9_-]*//g" -e "s/[ ][ ]*/ /g"`"
|
||||
_mon_flags="`echo " $kbc" | sed -e "s/ [^-][^-][a-z0-9_-]*//g" -e "s/[ ][ ]*/ /g"`"
|
||||
_mon_opts_exp="`echo $_mon_opts | sed -e "s/[ ]/|/g"`"
|
||||
fi
|
||||
|
||||
if [[ " ${COMP_WORDS[@]} " =~ " "($_mon_opts_exp)" " && "$prev" != "help" ]] ; then
|
||||
COMPREPLY=($(compgen -W "${_mon_flags}" -- ${cur}))
|
||||
else
|
||||
COMPREPLY=($(compgen -W "${_mon_opts}" -- ${cur}))
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
complete -o default -F _mon mon
|
|
@ -0,0 +1,27 @@
|
|||
# bash completion for openstack monasca
|
||||
|
||||
_monasca_opts="" # lazy init
|
||||
_monasca_flags="" # lazy init
|
||||
_monasca_opts_exp="" # lazy init
|
||||
_monasca()
|
||||
{
|
||||
local cur prev kbc
|
||||
COMPREPLY=()
|
||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||
|
||||
if [ "x$_monasca_opts" == "x" ] ; then
|
||||
kbc="`monasca bash-completion | sed -e "s/ -h / /"`"
|
||||
_monasca_opts="`echo "$kbc" | sed -e "s/--[a-z0-9_-]*//g" -e "s/[ ][ ]*/ /g"`"
|
||||
_monasca_flags="`echo " $kbc" | sed -e "s/ [^-][^-][a-z0-9_-]*//g" -e "s/[ ][ ]*/ /g"`"
|
||||
_monasca_opts_exp="`echo $_monasca_opts | sed -e "s/[ ]/|/g"`"
|
||||
fi
|
||||
|
||||
if [[ " ${COMP_WORDS[@]} " =~ " "($_monasca_opts_exp)" " && "$prev" != "help" ]] ; then
|
||||
COMPREPLY=($(compgen -W "${_monasca_flags}" -- ${cur}))
|
||||
else
|
||||
COMPREPLY=($(compgen -W "${_monasca_opts}" -- ${cur}))
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
complete -o default -F _monasca monasca
|
Loading…
Reference in New Issue