Revision 38206f3c
b/lib/backend.py | ||
---|---|---|
1348 | 1348 |
config.set(constants.INISECT_INS, 'nic%d_mac' % |
1349 | 1349 |
nic_count, '%s' % nic.mac) |
1350 | 1350 |
config.set(constants.INISECT_INS, 'nic%d_ip' % nic_count, '%s' % nic.ip) |
1351 |
config.set(constants.INISECT_INS, 'nic%d_bridge' % nic_count, '%s' % nic.bridge) |
|
1351 |
config.set(constants.INISECT_INS, 'nic%d_bridge' % nic_count, |
|
1352 |
'%s' % nic.bridge) |
|
1352 | 1353 |
# TODO: redundant: on load can read nics until it doesn't exist |
1353 | 1354 |
config.set(constants.INISECT_INS, 'nic_count' , '%d' % nic_count) |
1354 | 1355 |
|
b/lib/cli.py | ||
---|---|---|
32 | 32 |
from ganeti import utils |
33 | 33 |
from ganeti import logger |
34 | 34 |
from ganeti import errors |
35 |
from ganeti import mcpu |
|
36 | 35 |
from ganeti import constants |
37 | 36 |
from ganeti import opcodes |
38 | 37 |
from ganeti import luxi |
39 | 38 |
|
40 | 39 |
from optparse import (OptionParser, make_option, TitledHelpFormatter, |
41 |
Option, OptionValueError, SUPPRESS_HELP)
|
|
40 |
Option, OptionValueError) |
|
42 | 41 |
|
43 | 42 |
__all__ = ["DEBUG_OPT", "NOHDR_OPT", "SEP_OPT", "GenericMain", |
44 | 43 |
"SubmitOpCode", "GetClient", |
b/lib/cmdlib.py | ||
---|---|---|
38 | 38 |
from ganeti import errors |
39 | 39 |
from ganeti import hypervisor |
40 | 40 |
from ganeti import locking |
41 |
from ganeti import config |
|
42 | 41 |
from ganeti import constants |
43 | 42 |
from ganeti import objects |
44 | 43 |
from ganeti import opcodes |
45 |
from ganeti import ssconf |
|
46 | 44 |
from ganeti import serializer |
47 | 45 |
|
48 | 46 |
|
... | ... | |
870 | 868 |
lu_result: previous Exec result |
871 | 869 |
|
872 | 870 |
""" |
873 |
# We only really run POST phase hooks, and are only interested in their results |
|
871 |
# We only really run POST phase hooks, and are only interested in |
|
872 |
# their results |
|
874 | 873 |
if phase == constants.HOOKS_PHASE_POST: |
875 | 874 |
# Used to change hooks' output to proper indentation |
876 | 875 |
indent_re = re.compile('^', re.M) |
... | ... | |
4395 | 4394 |
if self.op.shutdown: |
4396 | 4395 |
# shutdown the instance, but not the disks |
4397 | 4396 |
if not rpc.call_instance_shutdown(src_node, instance): |
4398 |
raise errors.OpExecError("Could not shutdown instance %s on node %s" %
|
|
4399 |
(instance.name, src_node))
|
|
4397 |
raise errors.OpExecError("Could not shutdown instance %s on node %s" % |
|
4398 |
(instance.name, src_node)) |
|
4400 | 4399 |
|
4401 | 4400 |
vgname = self.cfg.GetVGName() |
4402 | 4401 |
|
... | ... | |
4929 | 4928 |
if rcode == constants.IARUN_NOTFOUND: |
4930 | 4929 |
raise errors.OpExecError("Can't find allocator '%s'" % name) |
4931 | 4930 |
elif rcode == constants.IARUN_FAILURE: |
4932 |
raise errors.OpExecError("Instance allocator call failed: %s," |
|
4933 |
" output: %s" % |
|
4934 |
(fail, stdout+stderr)) |
|
4931 |
raise errors.OpExecError("Instance allocator call failed: %s," |
|
4932 |
" output: %s" % (fail, stdout+stderr)) |
|
4935 | 4933 |
self.out_text = stdout |
4936 | 4934 |
if validate: |
4937 | 4935 |
self._ValidateResult() |
b/lib/config.py | ||
---|---|---|
34 | 34 |
import os |
35 | 35 |
import tempfile |
36 | 36 |
import random |
37 |
import re |
|
38 | 37 |
|
39 | 38 |
from ganeti import errors |
40 | 39 |
from ganeti import locking |
b/lib/http.py | ||
---|---|---|
25 | 25 |
import time |
26 | 26 |
import logging |
27 | 27 |
|
28 |
from ganeti import errors |
|
29 | 28 |
from ganeti import logger |
30 | 29 |
from ganeti import serializer |
31 | 30 |
|
b/lib/jqueue.py | ||
---|---|---|
197 | 197 |
op.result = None |
198 | 198 |
queue.UpdateJobUnlocked(job) |
199 | 199 |
|
200 |
input = op.input |
|
200 |
input_opcode = op.input
|
|
201 | 201 |
finally: |
202 | 202 |
queue.release() |
203 | 203 |
|
204 |
result = proc.ExecOpCode(input, op.Log) |
|
204 |
result = proc.ExecOpCode(input_opcode, op.Log)
|
|
205 | 205 |
|
206 | 206 |
queue.acquire() |
207 | 207 |
try: |
b/lib/logger.py | ||
---|---|---|
30 | 30 |
|
31 | 31 |
import sys |
32 | 32 |
import logging |
33 |
import os, os.path |
|
34 |
|
|
35 |
from ganeti import constants |
|
36 | 33 |
|
37 | 34 |
|
38 | 35 |
def SetupLogging(logfile, debug=False, stderr_logging=False, program=""): |
b/lib/luxi.py | ||
---|---|---|
31 | 31 |
|
32 | 32 |
import socket |
33 | 33 |
import collections |
34 |
import simplejson |
|
35 | 34 |
import time |
36 | 35 |
import errno |
37 | 36 |
|
38 |
from ganeti import opcodes |
|
39 | 37 |
from ganeti import serializer |
40 | 38 |
from ganeti import constants |
41 | 39 |
|
b/lib/mcpu.py | ||
---|---|---|
34 | 34 |
from ganeti import errors |
35 | 35 |
from ganeti import rpc |
36 | 36 |
from ganeti import cmdlib |
37 |
from ganeti import config |
|
38 | 37 |
from ganeti import ssconf |
39 | 38 |
from ganeti import logger |
40 | 39 |
from ganeti import locking |
b/lib/rapi/rlib1.py | ||
---|---|---|
23 | 23 |
|
24 | 24 |
""" |
25 | 25 |
|
26 |
import re |
|
27 |
|
|
28 | 26 |
import ganeti.cli |
29 | 27 |
import ganeti.errors |
30 | 28 |
import ganeti.opcodes |
31 | 29 |
|
32 | 30 |
from ganeti import constants |
33 |
from ganeti import utils |
|
34 | 31 |
|
35 |
from ganeti.rapi import baserlib
|
|
36 |
from ganeti.rapi import httperror
|
|
32 |
from ganeti.rapi import baserlib |
|
33 |
from ganeti.rapi import httperror |
|
37 | 34 |
|
38 | 35 |
|
39 | 36 |
I_FIELDS = ["name", "os", "pnode", "snodes", |
... | ... | |
42 | 39 |
"sda_size", "sdb_size", "vcpus", |
43 | 40 |
"oper_state", "status", "tags"] |
44 | 41 |
|
45 |
N_FIELDS = ["name","dtotal", "dfree", |
|
42 |
N_FIELDS = ["name", "dtotal", "dfree",
|
|
46 | 43 |
"mtotal", "mnode", "mfree", |
47 | 44 |
"pinst_cnt", "sinst_cnt", "tags"] |
48 | 45 |
|
... | ... | |
114 | 111 |
|
115 | 112 |
""" |
116 | 113 |
DOC_URI = "/nodes" |
117 |
|
|
114 |
|
|
118 | 115 |
def GET(self): |
119 | 116 |
"""Returns a list of all nodes. |
120 |
|
|
117 |
|
|
121 | 118 |
Returns: |
122 | 119 |
A dictionary with 'name' and 'uri' keys for each of them. |
123 | 120 |
|
... | ... | |
131 | 128 |
"uri": "\/instances\/node2.example.com" |
132 | 129 |
}] |
133 | 130 |
|
134 |
If the optional 'bulk' argument is provided and set to 'true'
|
|
131 |
If the optional 'bulk' argument is provided and set to 'true' |
|
135 | 132 |
value (i.e '?bulk=1'), the output contains detailed |
136 | 133 |
information about nodes as a list. |
137 | 134 |
|
... | ... | |
153 | 150 |
""" |
154 | 151 |
op = ganeti.opcodes.OpQueryNodes(output_fields=["name"], names=[]) |
155 | 152 |
nodeslist = baserlib.ExtractField(ganeti.cli.SubmitOpCode(op), 0) |
156 |
|
|
153 |
|
|
157 | 154 |
if 'bulk' in self.queryargs: |
158 | 155 |
op = ganeti.opcodes.OpQueryNodes(output_fields=N_FIELDS, |
159 | 156 |
names=nodeslist) |
... | ... | |
170 | 167 |
DOC_URI = "/nodes/[node_name]" |
171 | 168 |
|
172 | 169 |
def GET(self): |
173 |
"""Send information about a node.
|
|
170 |
"""Send information about a node. |
|
174 | 171 |
|
175 | 172 |
""" |
176 | 173 |
node_name = self.items[0] |
... | ... | |
207 | 204 |
|
208 | 205 |
def GET(self): |
209 | 206 |
"""Returns a list of all available instances. |
210 |
|
|
207 |
|
|
211 | 208 |
Returns: |
212 | 209 |
A dictionary with 'name' and 'uri' keys for each of them. |
213 | 210 |
|
... | ... | |
221 | 218 |
"uri": "\/instances\/mail.example.com" |
222 | 219 |
}] |
223 | 220 |
|
224 |
If the optional 'bulk' argument is provided and set to 'true'
|
|
221 |
If the optional 'bulk' argument is provided and set to 'true' |
|
225 | 222 |
value (i.e '?bulk=1'), the output contains detailed |
226 | 223 |
information about instances as a list. |
227 | 224 |
|
... | ... | |
250 | 247 |
""" |
251 | 248 |
op = ganeti.opcodes.OpQueryInstances(output_fields=["name"], names=[]) |
252 | 249 |
instanceslist = baserlib.ExtractField(ganeti.cli.SubmitOpCode(op), 0) |
253 |
|
|
250 |
|
|
254 | 251 |
if 'bulk' in self.queryargs: |
255 | 252 |
op = ganeti.opcodes.OpQueryInstances(output_fields=I_FIELDS, |
256 | 253 |
names=instanceslist) |
b/lib/rapi/rlib2.py | ||
---|---|---|
23 | 23 |
|
24 | 24 |
""" |
25 | 25 |
|
26 |
import re |
|
27 |
|
|
28 | 26 |
import ganeti.opcodes |
29 | 27 |
|
30 |
from ganeti import constants |
|
31 | 28 |
from ganeti import luxi |
32 | 29 |
|
33 |
from ganeti.rapi import baserlib
|
|
30 |
from ganeti.rapi import baserlib |
|
34 | 31 |
|
35 | 32 |
from ganeti.rapi.rlib1 import I_FIELDS, N_FIELDS |
36 | 33 |
|
... | ... | |
46 | 43 |
|
47 | 44 |
Returns: |
48 | 45 |
A dictionary with jobs id and uri. |
49 |
|
|
46 |
|
|
50 | 47 |
""" |
51 | 48 |
fields = ["id"] |
52 | 49 |
# Convert the list of lists to the list of ids |
... | ... | |
63 | 60 |
def GET(self): |
64 | 61 |
"""Returns a job status. |
65 | 62 |
|
66 |
Returns:
|
|
63 |
Returns: |
|
67 | 64 |
A dictionary with job parameters. |
68 | 65 |
|
69 | 66 |
The result includes: |
70 | 67 |
id - job ID as a number |
71 | 68 |
status - current job status as a string |
72 |
ops - involved OpCodes as a list of dictionaries for each opcodes in
|
|
69 |
ops - involved OpCodes as a list of dictionaries for each opcodes in |
|
73 | 70 |
the job |
74 | 71 |
opstatus - OpCodes status as a list |
75 | 72 |
opresult - OpCodes results as a list of lists |
76 |
|
|
73 |
|
|
77 | 74 |
""" |
78 | 75 |
fields = ["id", "ops", "status", "opstatus", "opresult"] |
79 | 76 |
job_id = self.items[0] |
80 |
result = luxi.Client().QueryJobs([job_id,], fields)[0] |
|
77 |
result = luxi.Client().QueryJobs([job_id, ], fields)[0]
|
|
81 | 78 |
return baserlib.MapFields(fields, result) |
82 | 79 |
|
83 | 80 |
|
... | ... | |
86 | 83 |
|
87 | 84 |
""" |
88 | 85 |
DOC_URI = "/2/nodes" |
89 |
|
|
86 |
|
|
90 | 87 |
def GET(self): |
91 | 88 |
"""Returns a list of all nodes. |
92 |
|
|
89 |
|
|
93 | 90 |
Returns: |
94 | 91 |
A dictionary with 'name' and 'uri' keys for each of them. |
95 | 92 |
|
... | ... | |
103 | 100 |
"uri": "\/instances\/node2.example.com" |
104 | 101 |
}] |
105 | 102 |
|
106 |
If the optional 'bulk' argument is provided and set to 'true'
|
|
103 |
If the optional 'bulk' argument is provided and set to 'true' |
|
107 | 104 |
value (i.e '?bulk=1'), the output contains detailed |
108 | 105 |
information about nodes as a list. |
109 | 106 |
|
... | ... | |
125 | 122 |
""" |
126 | 123 |
op = ganeti.opcodes.OpQueryNodes(output_fields=["name"], names=[]) |
127 | 124 |
nodeslist = baserlib.ExtractField(ganeti.cli.SubmitOpCode(op), 0) |
128 |
|
|
125 |
|
|
129 | 126 |
if 'bulk' in self.queryargs: |
130 | 127 |
op = ganeti.opcodes.OpQueryNodes(output_fields=N_FIELDS, |
131 | 128 |
names=nodeslist) |
132 | 129 |
result = ganeti.cli.SubmitOpCode(op) |
133 | 130 |
return baserlib.MapBulkFields(result, N_FIELDS) |
134 | 131 |
|
135 |
return baserlib.BuildUriList(nodeslist, "/nodes/%s", uri_fields=("id", "uri")) |
|
132 |
return baserlib.BuildUriList(nodeslist, "/nodes/%s", |
|
133 |
uri_fields=("id", "uri")) |
b/lib/rpc.py | ||
---|---|---|
33 | 33 |
|
34 | 34 |
from ganeti import logger |
35 | 35 |
from ganeti import utils |
36 |
from ganeti import errors |
|
37 |
from ganeti import constants |
|
38 | 36 |
from ganeti import objects |
39 | 37 |
from ganeti import ssconf |
40 | 38 |
|
b/lib/utils.py | ||
---|---|---|
74 | 74 |
"failed", "fail_reason", "cmd"] |
75 | 75 |
|
76 | 76 |
|
77 |
def __init__(self, exit_code, signal, stdout, stderr, cmd): |
|
77 |
def __init__(self, exit_code, signal_, stdout, stderr, cmd):
|
|
78 | 78 |
self.cmd = cmd |
79 | 79 |
self.exit_code = exit_code |
80 |
self.signal = signal |
|
80 |
self.signal = signal_
|
|
81 | 81 |
self.stdout = stdout |
82 | 82 |
self.stderr = stderr |
83 |
self.failed = (signal is not None or exit_code != 0) |
|
83 |
self.failed = (signal_ is not None or exit_code != 0)
|
|
84 | 84 |
|
85 | 85 |
if self.signal is not None: |
86 | 86 |
self.fail_reason = "terminated by signal %s" % self.signal |
... | ... | |
168 | 168 |
status = child.wait() |
169 | 169 |
if status >= 0: |
170 | 170 |
exitcode = status |
171 |
signal = None |
|
171 |
signal_ = None
|
|
172 | 172 |
else: |
173 | 173 |
exitcode = None |
174 |
signal = -status |
|
174 |
signal_ = -status
|
|
175 | 175 |
|
176 |
return RunResult(exitcode, signal, out, err, strcmd) |
|
176 |
return RunResult(exitcode, signal_, out, err, strcmd)
|
|
177 | 177 |
|
178 | 178 |
|
179 | 179 |
def RemoveFile(filename): |
... | ... | |
1092 | 1092 |
pass |
1093 | 1093 |
|
1094 | 1094 |
|
1095 |
def KillProcess(pid, signal=signal.SIGTERM, timeout=30): |
|
1095 |
def KillProcess(pid, signal_=signal.SIGTERM, timeout=30):
|
|
1096 | 1096 |
"""Kill a process given by its pid. |
1097 | 1097 |
|
1098 | 1098 |
@type pid: int |
1099 | 1099 |
@param pid: The PID to terminate. |
1100 |
@type signal: int |
|
1101 |
@param signal: The signal to send, by default SIGTERM |
|
1100 |
@type signal_: int
|
|
1101 |
@param signal_: The signal to send, by default SIGTERM
|
|
1102 | 1102 |
@type timeout: int |
1103 | 1103 |
@param timeout: The timeout after which, if the process is still alive, |
1104 | 1104 |
a SIGKILL will be sent. If not positive, no such checking |
... | ... | |
1111 | 1111 |
|
1112 | 1112 |
if not IsProcessAlive(pid): |
1113 | 1113 |
return |
1114 |
os.kill(pid, signal) |
|
1114 |
os.kill(pid, signal_)
|
|
1115 | 1115 |
if timeout <= 0: |
1116 | 1116 |
return |
1117 | 1117 |
end = time.time() + timeout |
b/lib/workerpool.py | ||
---|---|---|
27 | 27 |
import logging |
28 | 28 |
import threading |
29 | 29 |
|
30 |
from ganeti import errors |
|
31 |
from ganeti import utils |
|
32 |
|
|
33 | 30 |
|
34 | 31 |
class BaseWorker(threading.Thread, object): |
35 | 32 |
"""Base worker class for worker pools. |
Also available in: Unified diff