From fe478bd49f031d4f9edaa8def9737af85aef6be6 Mon Sep 17 00:00:00 2001 From: Johannes Erdfelt Date: Wed, 26 Sep 2012 15:33:52 +0000 Subject: xenapi: increase timeout for resetnetwork agent request Windows can take longer than the default 30 seconds for resetnetwork requests. Double the timeout for the command to 60 seconds, but add a flag so it can be changed without code changes in the future. At the same time, add a flag for all other agent requests too. Change-Id: Iba91c37fd5596ea0dd63c20f74925972df1ca715 --- nova/virt/xenapi/agent.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'nova') diff --git a/nova/virt/xenapi/agent.py b/nova/virt/xenapi/agent.py index 39705e112..1186692ef 100644 --- a/nova/virt/xenapi/agent.py +++ b/nova/virt/xenapi/agent.py @@ -31,26 +31,37 @@ from nova import utils LOG = logging.getLogger(__name__) xenapi_agent_opts = [ + cfg.IntOpt('agent_timeout', + default=30, + help='number of seconds to wait for agent reply'), cfg.IntOpt('agent_version_timeout', default=300, help='number of seconds to wait for agent ' 'to be fully operational'), + cfg.IntOpt('agent_resetnetwork_timeout', + default=60, + help='number of seconds to wait for agent reply ' + 'to resetnetwork request'), ] FLAGS = flags.FLAGS FLAGS.register_opts(xenapi_agent_opts) -def _call_agent(session, instance, vm_ref, method, addl_args=None): +def _call_agent(session, instance, vm_ref, method, addl_args=None, + timeout=None): """Abstracts out the interaction with the agent xenapi plugin.""" if addl_args is None: addl_args = {} + if timeout is None: + timeout = FLAGS.agent_timeout vm_rec = session.call_xenapi("VM.get_record", vm_ref) args = { 'id': str(uuid.uuid4()), 'dom_id': vm_rec['domid'], + 'timeout': str(timeout), } args.update(addl_args) @@ -204,7 +215,8 @@ def inject_file(session, instance, vm_ref, path, contents): def resetnetwork(session, instance, vm_ref): LOG.debug(_('Resetting network'), instance=instance) - resp = _call_agent(session, instance, vm_ref, 'resetnetwork') + resp = _call_agent(session, instance, vm_ref, 'resetnetwork', + timeout=FLAGS.agent_resetnetwork_timeout) if resp['returncode'] != '0': LOG.error(_('Failed to reset network: %(resp)r'), locals(), instance=instance) -- cgit