"""
+# pylint: disable-msg=C0103
+
+# C0103: Invalid name, since the R_* names are not conforming
+
from ganeti import opcodes
from ganeti import http
from ganeti import constants
from ganeti.rapi import baserlib
+_COMMON_FIELDS = ["ctime", "mtime", "uuid", "serial_no", "tags"]
I_FIELDS = ["name", "admin_state", "os",
"pnode", "snodes",
"disk_template",
- "nic.ips", "nic.macs", "nic.modes", "nic.links",
+ "nic.ips", "nic.macs", "nic.modes", "nic.links", "nic.bridges",
"network_port",
"disk.sizes", "disk_usage",
"beparams", "hvparams",
"oper_state", "oper_ram", "status",
- "tags"]
+ ] + _COMMON_FIELDS
N_FIELDS = ["name", "offline", "master_candidate", "drained",
"dtotal", "dfree",
"mtotal", "mnode", "mfree",
- "pinst_cnt", "sinst_cnt", "tags",
+ "pinst_cnt", "sinst_cnt",
"ctotal", "cnodes", "csockets",
- "pip", "sip", "serial_no", "role",
+ "pip", "sip", "role",
"pinst_list", "sinst_list",
- ]
+ ] + _COMMON_FIELDS
_NR_DRAINED = "drained"
_NR_MASTER_CANDIATE = "master-candidate"
to adapt clients accordingly.
"""
- def GET(self):
+ @staticmethod
+ def GET():
"""Returns the remote API version.
"""
"""Cluster info.
"""
- def GET(self):
+ @staticmethod
+ def GET():
"""Returns cluster information.
"""
"""/2/os resource.
"""
- def GET(self):
+ @staticmethod
+ def GET():
"""Return a list of all OSes.
Can return error 500 in case of a problem.
"""
cl = baserlib.GetClient()
- op = opcodes.OpDiagnoseOS(output_fields=["name", "valid"], names=[])
+ op = opcodes.OpDiagnoseOS(output_fields=["name", "valid", "variants"],
+ names=[])
job_id = baserlib.SubmitJob([op], cl)
# we use custom feedback function, instead of print we log the status
result = cli.PollJob(job_id, cl, feedback_fn=baserlib.FeedbackFn)
if not isinstance(diagnose_data, list):
raise http.HttpBadGateway(message="Can't get OS list")
- return [row[0] for row in diagnose_data if row[1]]
+ os_names = []
+ for (name, valid, variants) in diagnose_data:
+ if valid:
+ os_names.extend(cli.CalculateOSNames(name, variants))
+
+ return os_names
+
+
+class R_2_redist_config(baserlib.R_Generic):
+ """/2/redistribute-config resource.
+
+ """
+ @staticmethod
+ def PUT():
+ """Redistribute configuration to all nodes.
+
+ """
+ return baserlib.SubmitJob([opcodes.OpRedistributeConfig()])
class R_2_jobs(baserlib.R_Generic):
"""/2/jobs resource.
"""
- def GET(self):
+ @staticmethod
+ def GET():
"""Returns a dictionary of jobs.
@return: a dictionary with jobs id and uri.
for idx, d in enumerate(disk_data):
if not isinstance(d, int):
raise http.HttpBadRequest("Disk %d specification wrong: should"
- " be an integer")
+ " be an integer" % idx)
disks.append({"size": d})
# nic processing (one nic only)
nics = [{"mac": fn("mac", constants.VALUE_AUTO)}]
if fn("link", None) is not None:
nics[0]["link"] = fn("link")
if fn("bridge", None) is not None:
- nics[0]["bridge"] = fn("bridge")
+ nics[0]["bridge"] = fn("bridge")
op = opcodes.OpCreateInstance(
mode=constants.INSTANCE_CREATE,
nics=nics,
start=fn('start', True),
ip_check=fn('ip_check', True),
+ name_check=fn('name_check', True),
wait_for_sync=True,
hypervisor=fn('hypervisor', None),
hvparams=hvparams,
Example: ["tag1", "tag2", "tag3"]
"""
+ # pylint: disable-msg=W0212
return baserlib._Tags_GET(self.TAG_LEVEL, name=self.name)
def PUT(self):
you'll have back a job id.
"""
+ # pylint: disable-msg=W0212
if 'tag' not in self.queryargs:
raise http.HttpBadRequest("Please specify tag(s) to add using the"
" the 'tag' parameter")
/tags?tag=[tag]&tag=[tag]
"""
+ # pylint: disable-msg=W0212
if 'tag' not in self.queryargs:
# no we not gonna delete all tags
raise http.HttpBadRequest("Cannot delete all tags - please specify"