~ubuntu-branches/ubuntu/raring/nova/raring-proposed

« back to all changes in this revision

Viewing changes to plugins/xenserver/xenapi/etc/xapi.d/plugins/agent

  • Committer: Package Import Robot
  • Author(s): Chuck Short, Adam Gandelman, Chuck Short
  • Date: 2012-11-23 09:04:58 UTC
  • mfrom: (1.1.66)
  • Revision ID: package-import@ubuntu.com-20121123090458-91565o7aev1i1h71
Tags: 2013.1~g1-0ubuntu1
[ Adam Gandelman ]
* debian/control: Ensure novaclient is upgraded with nova,
  require python-keystoneclient >= 1:2.9.0. (LP: #1073289)
* debian/patches/{ubuntu/*, rbd-security.patch}: Dropped, applied
  upstream.
* debian/control: Add python-testtools to Build-Depends.

[ Chuck Short ]
* New upstream version.
* Refreshed debian/patches/avoid_setuptools_git_dependency.patch.
* debian/rules: FTBFS if missing binaries.
* debian/nova-scheudler.install: Add missing rabbit-queues and
  nova-rpc-zmq-receiver.
* Remove nova-volume since it doesnt exist anymore, transition to cinder-*.
* debian/rules: install apport hook in the right place.
* debian/patches/ubuntu-show-tests.patch: Display test failures.
* debian/control: Add depends on genisoimage
* debian/control: Suggest guestmount.
* debian/control: Suggest websockify. (LP: #1076442)
* debian/nova.conf: Disable nova-volume service.
* debian/control: Depend on xen-system-* rather than the hypervisor.
* debian/control, debian/mans/nova-conductor.8, debian/nova-conductor.init,
  debian/nova-conductor.install, debian/nova-conductor.logrotate
  debian/nova-conductor.manpages, debian/nova-conductor.postrm
  debian/nova-conductor.upstart.in: Add nova-conductor service.
* debian/control: Add python-fixtures as a build deps.

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
configure_logging("agent")
41
41
import xenstore
42
42
 
43
 
AGENT_TIMEOUT = 30
 
43
DEFAULT_TIMEOUT = 30
44
44
 
45
45
 
46
46
class TimeoutError(StandardError):
49
49
 
50
50
def version(self, arg_dict):
51
51
    """Get version of agent."""
 
52
    timeout = int(arg_dict.pop('timeout', DEFAULT_TIMEOUT))
52
53
    arg_dict["value"] = json.dumps({"name": "version", "value": "agent"})
53
54
    request_id = arg_dict["id"]
54
55
    arg_dict["path"] = "data/host/%s" % request_id
55
56
    xenstore.write_record(self, arg_dict)
56
57
    try:
57
 
        resp = _wait_for_agent(self, request_id, arg_dict)
 
58
        resp = _wait_for_agent(self, request_id, arg_dict, timeout)
58
59
    except TimeoutError, e:
59
60
        raise PluginError(e)
60
61
    return resp
66
67
    info to be passed, such as passwords. Returns the shared
67
68
    secret key value.
68
69
    """
 
70
    timeout = int(arg_dict.pop('timeout', DEFAULT_TIMEOUT))
69
71
    # WARNING: Some older Windows agents will crash if the public key isn't
70
72
    # a string
71
73
    pub = arg_dict["pub"]
74
76
    arg_dict["path"] = "data/host/%s" % request_id
75
77
    xenstore.write_record(self, arg_dict)
76
78
    try:
77
 
        resp = _wait_for_agent(self, request_id, arg_dict)
 
79
        resp = _wait_for_agent(self, request_id, arg_dict, timeout)
78
80
    except TimeoutError, e:
79
81
        raise PluginError(e)
80
82
    return resp
87
89
    previous call to key_init. The encrypted password value should
88
90
    be passed as the value for the 'enc_pass' key in arg_dict.
89
91
    """
 
92
    timeout = int(arg_dict.pop('timeout', DEFAULT_TIMEOUT))
90
93
    enc_pass = arg_dict["enc_pass"]
91
94
    arg_dict["value"] = json.dumps({"name": "password", "value": enc_pass})
92
95
    request_id = arg_dict["id"]
93
96
    arg_dict["path"] = "data/host/%s" % request_id
94
97
    xenstore.write_record(self, arg_dict)
95
98
    try:
96
 
        resp = _wait_for_agent(self, request_id, arg_dict)
 
99
        resp = _wait_for_agent(self, request_id, arg_dict, timeout)
97
100
    except TimeoutError, e:
98
101
        raise PluginError(e)
99
102
    return resp
103
106
    """Writes a resquest to xenstore that tells the agent
104
107
    to reset networking.
105
108
    """
 
109
    timeout = int(arg_dict.pop('timeout', DEFAULT_TIMEOUT))
106
110
    arg_dict['value'] = json.dumps({'name': 'resetnetwork', 'value': ''})
107
111
    request_id = arg_dict['id']
108
112
    arg_dict['path'] = "data/host/%s" % request_id
109
113
    xenstore.write_record(self, arg_dict)
110
114
    try:
111
 
        resp = _wait_for_agent(self, request_id, arg_dict)
 
115
        resp = _wait_for_agent(self, request_id, arg_dict, timeout)
112
116
    except TimeoutError, e:
113
117
        raise PluginError(e)
114
118
    return resp
125
129
    need to test to determine if the file injection method on the agent has
126
130
    been disabled, and raise a NotImplemented error if that is the case.
127
131
    """
 
132
    timeout = int(arg_dict.pop('timeout', DEFAULT_TIMEOUT))
128
133
    b64_path = arg_dict["b64_path"]
129
134
    b64_file = arg_dict["b64_contents"]
130
135
    request_id = arg_dict["id"]
151
156
    arg_dict["path"] = "data/host/%s" % request_id
152
157
    xenstore.write_record(self, arg_dict)
153
158
    try:
154
 
        resp = _wait_for_agent(self, request_id, arg_dict)
 
159
        resp = _wait_for_agent(self, request_id, arg_dict, timeout)
155
160
    except TimeoutError, e:
156
161
        raise PluginError(e)
157
162
    return resp
160
165
def agent_update(self, arg_dict):
161
166
    """Expects an URL and md5sum of the contents, then directs the agent to
162
167
    update itself."""
 
168
    timeout = int(arg_dict.pop('timeout', DEFAULT_TIMEOUT))
163
169
    request_id = arg_dict["id"]
164
170
    url = arg_dict["url"]
165
171
    md5sum = arg_dict["md5sum"]
168
174
    arg_dict["path"] = "data/host/%s" % request_id
169
175
    xenstore.write_record(self, arg_dict)
170
176
    try:
171
 
        resp = _wait_for_agent(self, request_id, arg_dict)
 
177
        resp = _wait_for_agent(self, request_id, arg_dict, timeout)
172
178
    except TimeoutError, e:
173
179
        raise PluginError(e)
174
180
    return resp
176
182
 
177
183
def _get_agent_features(self, arg_dict):
178
184
    """Return an array of features that an agent supports."""
 
185
    timeout = int(arg_dict.pop('timeout', DEFAULT_TIMEOUT))
179
186
    tmp_id = commands.getoutput("uuidgen")
180
187
    dct = {}
181
188
    dct.update(arg_dict)
183
190
    dct["path"] = "data/host/%s" % tmp_id
184
191
    xenstore.write_record(self, dct)
185
192
    try:
186
 
        resp = _wait_for_agent(self, tmp_id, dct)
 
193
        resp = _wait_for_agent(self, tmp_id, dct, timeout)
187
194
    except TimeoutError, e:
188
195
        raise PluginError(e)
189
196
    response = json.loads(resp)
193
200
        return {}
194
201
 
195
202
 
196
 
def _wait_for_agent(self, request_id, arg_dict):
 
203
def _wait_for_agent(self, request_id, arg_dict, timeout):
197
204
    """Periodically checks xenstore for a response from the agent.
198
205
    The request is always written to 'data/host/{id}', and
199
206
    the agent's response for that request will be in 'data/guest/{id}'.
200
 
    If no value appears from the agent within the time specified by
201
 
    AGENT_TIMEOUT, the original request is deleted and a TimeoutError
202
 
    is returned.
 
207
    If no value appears from the agent within the timeout specified,
 
208
    the original request is deleted and a TimeoutError is raised.
203
209
    """
204
210
    arg_dict["path"] = "data/guest/%s" % request_id
205
211
    arg_dict["ignore_missing_path"] = True
206
212
    start = time.time()
207
 
    while time.time() - start < AGENT_TIMEOUT:
 
213
    while time.time() - start < timeout:
208
214
        ret = xenstore.read_record(self, arg_dict)
209
215
        # Note: the response for None with be a string that includes
210
216
        # double quotes.
219
225
    arg_dict["path"] = "data/host/%s" % request_id
220
226
    xenstore.delete_record(self, arg_dict)
221
227
    raise TimeoutError(_("TIMEOUT: No response from agent within"
222
 
                         " %s seconds.") % AGENT_TIMEOUT)
 
228
                         " %s seconds.") % timeout)
223
229
 
224
230
 
225
231
if __name__ == "__main__":