Commit 8075ce7e authored by Oleksiy Mishchenko's avatar Oleksiy Mishchenko
Browse files

Breath life in to RAPI for trunk

Reviewed-by: imsnah
parent 761ce945
......@@ -126,6 +126,14 @@ def StartMaster(master_netdev, master_ip, debug):
result = utils.RunCmd(["arping", "-q", "-U", "-c 3", "-I", master_netdev,
"-s", master_ip, master_ip])
# we'll ignore the exit code of arping
if constants.RAPI_ENABLE:
# Start remote API
result = utils.RunCmd(["ganeti-rapi", "--port=%s" % constants.RAPI_PORT])
if debug and result.failed:
sys.stderr.write("Failed to start ganeti-rapi, error: %s\n" %
result.output)
return EXIT_OK
......@@ -133,6 +141,14 @@ def StopMaster(master_netdev, master_ip, debug):
"""Stops the master.
"""
if constants.RAPI_ENABLE:
# Stop remote API
result = utils.RunCmd(["fuser", "-k", "-TERM", "-n", "tcp",
str(constants.RAPI_PORT)])
if debug and result.failed:
sys.stderr.write("Failed to stop ganeti-rapi, error: %s\n" %
result.output)
result = utils.RunCmd(["ip", "address", "del", "%s/32" % master_ip,
"dev", master_netdev])
if result.failed:
......
......@@ -85,34 +85,6 @@ def MapFields(names, data):
return dict([(names[i], data[i]) for i in range(len(names))])
def RequireLock(name='cmd'):
"""Function decorator to automatically acquire locks.
PEP-318 style function decorator.
"""
def wrapper(fn):
def new_f(*args, **kwargs):
try:
utils.Lock(name, max_retries=15)
try:
# Call real function
return fn(*args, **kwargs)
finally:
utils.Unlock(name)
utils.LockCleanup()
except ganeti.errors.LockError, err:
raise httperror.HTTPServiceUnavailable(message=str(err))
# Override function metadata
new_f.func_name = fn.func_name
new_f.func_doc = fn.func_doc
return new_f
return wrapper
def _Tags_GET(kind, name=None):
"""Helper function to retrieve tags.
......@@ -293,7 +265,6 @@ class R_nodes(R_Generic):
"""
DOC_URI = "/nodes"
@RequireLock()
def _GetDetails(self, nodeslist):
"""Returns detailed instance data for bulk output.
......@@ -336,7 +307,7 @@ class R_nodes(R_Generic):
If the optional 'bulk' argument is provided and set to 'true'
value (i.e '?bulk=1'), the output contains detailed
information about nodes as a list. Note: Lock required.
information about nodes as a list.
Example: [
{
......@@ -369,7 +340,6 @@ class R_nodes_name(R_Generic):
"""
DOC_URI = "/nodes/[node_name]"
@RequireLock()
def GET(self):
"""Send information about a node.
......@@ -409,7 +379,6 @@ class R_instances(R_Generic):
"""
DOC_URI = "/instances"
@RequireLock()
def _GetDetails(self, instanceslist):
"""Returns detailed instance data for bulk output.
......@@ -454,7 +423,7 @@ class R_instances(R_Generic):
If the optional 'bulk' argument is provided and set to 'true'
value (i.e '?bulk=1'), the output contains detailed
information about instances as a list. Note: Lock required.
information about instances as a list.
Example: [
{
......@@ -495,7 +464,6 @@ class R_instances_name(R_Generic):
"""
DOC_URI = "/instances/[instance_name]"
@RequireLock()
def GET(self):
"""Send information about an instance.
......@@ -537,7 +505,6 @@ class R_os(R_Generic):
"""
DOC_URI = "/os"
@RequireLock()
def GET(self):
"""Return a list of all OSes.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment