summaryrefslogtreecommitdiff
path: root/novaclient/v1_1/hypervisors.py
diff options
context:
space:
mode:
Diffstat (limited to 'novaclient/v1_1/hypervisors.py')
-rw-r--r--novaclient/v1_1/hypervisors.py58
1 files changed, 58 insertions, 0 deletions
diff --git a/novaclient/v1_1/hypervisors.py b/novaclient/v1_1/hypervisors.py
new file mode 100644
index 00000000..9f56ae05
--- /dev/null
+++ b/novaclient/v1_1/hypervisors.py
@@ -0,0 +1,58 @@
+# Copyright 2012 OpenStack LLC.
+# All Rights Reserved.
+#
+# 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.
+
+"""
+Hypervisors interface (1.1 extension).
+"""
+
+import urllib
+
+from novaclient import base
+
+
+class Hypervisor(base.Resource):
+ def __repr__(self):
+ return "<Hypervisor: %s>" % self.id
+
+
+class HypervisorManager(base.Manager):
+ resource_class = Hypervisor
+
+ def list(self, detailed=True):
+ """
+ Get a list of hypervisors.
+ """
+ detail = ""
+ if detailed:
+ detail = "/detail"
+ return self._list('/os-hypervisors%s' % detail, 'hypervisors')
+
+ def search(self, hypervisor_match, servers=False):
+ """
+ Get a list of matching hypervisors.
+
+ :param servers: If True, server information is also retrieved.
+ """
+ target = 'servers' if servers else 'search'
+ url = ('/os-hypervisors/%s/%s' %
+ (urllib.quote(hypervisor_match, safe=''), target))
+ return self._list(url, 'hypervisors')
+
+ def get(self, hypervisor):
+ """
+ Get a specific hypervisor.
+ """
+ return self._get("/os-hypervisors/%s" % base.getid(hypervisor),
+ "hypervisor")