summaryrefslogtreecommitdiff
path: root/novaclient/v2/agents.py
diff options
context:
space:
mode:
Diffstat (limited to 'novaclient/v2/agents.py')
-rw-r--r--novaclient/v2/agents.py67
1 files changed, 67 insertions, 0 deletions
diff --git a/novaclient/v2/agents.py b/novaclient/v2/agents.py
new file mode 100644
index 0000000..b5372cb
--- /dev/null
+++ b/novaclient/v2/agents.py
@@ -0,0 +1,67 @@
1# Copyright 2012 IBM Corp.
2# All Rights Reserved.
3#
4# Licensed under the Apache License, Version 2.0 (the "License"); you may
5# not use this file except in compliance with the License. You may obtain
6# a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13# License for the specific language governing permissions and limitations
14# under the License.
15
16"""
17agent interface
18"""
19
20from novaclient import base
21
22
23class Agent(base.Resource):
24 def __repr__(self):
25 return "<Agent: %s>" % self.agent
26
27 def _add_details(self, info):
28 dico = 'resource' in info and info['resource'] or info
29 for (k, v) in dico.items():
30 setattr(self, k, v)
31
32
33class AgentsManager(base.ManagerWithFind):
34 resource_class = Agent
35
36 def list(self, hypervisor=None):
37 """List all agent builds."""
38 url = "/os-agents"
39 if hypervisor:
40 url = "/os-agents?hypervisor=%s" % hypervisor
41 return self._list(url, "agents")
42
43 def _build_update_body(self, version, url, md5hash):
44 return {'para': {'version': version,
45 'url': url,
46 'md5hash': md5hash}}
47
48 def update(self, id, version,
49 url, md5hash):
50 """Update an existing agent build."""
51 body = self._build_update_body(version, url, md5hash)
52 return self._update('/os-agents/%s' % id, body, 'agent')
53
54 def create(self, os, architecture, version,
55 url, md5hash, hypervisor):
56 """Create a new agent build."""
57 body = {'agent': {'hypervisor': hypervisor,
58 'os': os,
59 'architecture': architecture,
60 'version': version,
61 'url': url,
62 'md5hash': md5hash}}
63 return self._create('/os-agents', body, 'agent')
64
65 def delete(self, id):
66 """Deletes an existing agent build."""
67 self._delete('/os-agents/%s' % id)