Introducing telemetry service

Includes the Capabilities resource, available for list only.

Change-Id: If8b9f54eaf97fc9de46b7d723ca15e4265469a34
This commit is contained in:
Steve Lewis 2014-08-08 10:26:04 -07:00
parent 2f11f38c18
commit 393052c030
8 changed files with 115 additions and 0 deletions

View File

View File

@ -0,0 +1,21 @@
# 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.
from openstack.auth import service_filter
class TelemetryService(service_filter.ServiceFilter):
"""The telemetry service."""
def __init__(self):
"""Create a telemetry service."""
super(TelemetryService, self).__init__(service_type='telemetry')

View File

View File

@ -0,0 +1,27 @@
# 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.
from openstack import resource
from openstack.telemetry import telemetry_service
class Capabilities(resource.Resource):
resource_key = 'capabilities'
resources_key = 'capabilities'
base_path = '/v2.0/capabilities'
service = telemetry_service.TelemetryService()
# Supported Operations
allow_list = True
# Properties
capabilities = resource.prop('api')

View File

View File

@ -0,0 +1,25 @@
# 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 testtools
from openstack.telemetry import telemetry_service
class TestTelemetryService(testtools.TestCase):
def test_service(self):
sot = telemetry_service.TelemetryService()
self.assertEqual('telemetry', sot.service_type)
self.assertEqual('public', sot.visibility)
self.assertIsNone(sot.region)
self.assertIsNone(sot.service_name)

View File

View File

@ -0,0 +1,42 @@
# 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 testtools
from openstack.telemetry.v2 import capabilities
EXAMPLE = {
"api": {"123": False,
"135": True,
"246": True, },
}
class TestMeter(testtools.TestCase):
def test_basic(self):
sot = capabilities.Capabilities()
self.assertEqual('capabilities', sot.resource_key)
self.assertEqual('capabilities', sot.resources_key)
self.assertEqual('/v2.0/capabilities', sot.base_path)
self.assertEqual('telemetry', sot.service.service_type)
self.assertFalse(sot.allow_create)
self.assertFalse(sot.allow_retrieve)
self.assertFalse(sot.allow_update)
self.assertFalse(sot.allow_delete)
self.assertTrue(sot.allow_list)
def test_make_it(self):
sot = capabilities.Capabilities(EXAMPLE)
self.assertEqual(EXAMPLE['api'], sot.capabilities)
self.assertFalse(sot.capabilities['123'])
self.assertTrue(sot.capabilities['135'])
self.assertTrue(sot.capabilities['246'])