Trees | Indices | Help |
|
---|
|
1 # 2 # 3 4 # Copyright (C) 2010 Google Inc. 5 # All rights reserved. 6 # 7 # Redistribution and use in source and binary forms, with or without 8 # modification, are permitted provided that the following conditions are 9 # met: 10 # 11 # 1. Redistributions of source code must retain the above copyright notice, 12 # this list of conditions and the following disclaimer. 13 # 14 # 2. Redistributions in binary form must reproduce the above copyright 15 # notice, this list of conditions and the following disclaimer in the 16 # documentation and/or other materials provided with the distribution. 17 # 18 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 19 # IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 20 # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 22 # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 23 # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 30 31 """RAPI client utilities. 32 33 """ 34 35 from ganeti import constants 36 from ganeti import cli 37 38 from ganeti.rapi import client 39 40 # Local constant to avoid importing ganeti.http 41 HTTP_NOT_FOUND = 404 42 4395 9646 """Initializes this class. 47 48 @param cl: RAPI client instance 49 50 """ 51 cli.JobPollCbBase.__init__(self) 52 53 self.cl = cl5457 """Waits for changes on a job. 58 59 """ 60 try: 61 result = self.cl.WaitForJobChange(job_id, fields, 62 prev_job_info, prev_log_serial) 63 except client.GanetiApiError, err: 64 if err.code == HTTP_NOT_FOUND: 65 return None 66 67 raise 68 69 if result is None: 70 return constants.JOB_NOTCHANGED 71 72 return (result["job_info"], result["log_entries"])7375 """Returns the given fields for the selected job IDs. 76 77 @type job_ids: list of numbers 78 @param job_ids: Job IDs 79 @type fields: list of strings 80 @param fields: Fields 81 82 """ 83 if len(job_ids) != 1: 84 raise NotImplementedError("Only one job supported at this time") 85 86 try: 87 result = self.cl.GetJobStatus(job_ids[0]) 88 except client.GanetiApiError, err: 89 if err.code == HTTP_NOT_FOUND: 90 return [None] 91 92 raise 93 94 return [[result[name] for name in fields], ]98 """Function to poll for the result of a job. 99 100 @param rapi_client: RAPI client instance 101 @type job_id: number 102 @param job_id: Job ID 103 @type reporter: L{cli.JobPollReportCbBase} 104 @param reporter: PollJob reporter instance 105 106 @return: The opresult of the job 107 @raise errors.JobLost: If job can't be found 108 @raise errors.OpExecError: if job didn't succeed 109 110 @see: L{ganeti.cli.GenericPollJob} 111 112 """ 113 return cli.GenericPollJob(job_id, RapiJobPollCb(rapi_client), reporter)114
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Mon Apr 4 13:44:13 2016 | http://epydoc.sourceforge.net |