Add Resource and Usage objects
Add Resource and Usage objects to Delimiter. Change-Id: Ia8517fc36954f1bb982d532d98aed41a2b132eae
This commit is contained in:
parent
656fa5f13c
commit
047acde202
33
delimiter/objects/resource.py
Normal file
33
delimiter/objects/resource.py
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
#
|
||||||
|
# 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.
|
||||||
|
|
||||||
|
|
||||||
|
class Resource(object):
|
||||||
|
"""Represent a resource.
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(self, service, name, params=None):
|
||||||
|
"""Initialize a Resource
|
||||||
|
|
||||||
|
:param service: The Service object the resource is associated
|
||||||
|
with.
|
||||||
|
:param name: The name of the resource, as a string; e.g.,
|
||||||
|
"instances", "vcpus", "images", etc.
|
||||||
|
:param params: The names of the parameters necessary to
|
||||||
|
identify the resource.
|
||||||
|
|
||||||
|
"""
|
||||||
|
self.service = service
|
||||||
|
self.name = name
|
||||||
|
self.params = set(params) if params else set()
|
33
delimiter/objects/usage.py
Normal file
33
delimiter/objects/usage.py
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
#
|
||||||
|
# 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.
|
||||||
|
|
||||||
|
|
||||||
|
class Usage(object):
|
||||||
|
"""Represent a resource usage.
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(self, resource, category, usage=0):
|
||||||
|
"""Initialize a Usage.
|
||||||
|
|
||||||
|
:param resource: The Resource the usage is for.
|
||||||
|
:param category: The category of the Usage.
|
||||||
|
relevant to service users.
|
||||||
|
:param usage: The current amount of the resource which is in
|
||||||
|
use by the user.
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
self.resource = resource
|
||||||
|
self.category = category
|
||||||
|
self.usage = usage
|
Loading…
x
Reference in New Issue
Block a user