diff --git a/daemons/ganeti-master b/daemons/ganeti-master index b24f43f54331d71632dca8ed064e46bdcdc0b3e2..653da757f0ec76523d0b0c8aab90105c0ae04185 100755 --- a/daemons/ganeti-master +++ b/daemons/ganeti-master @@ -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: diff --git a/lib/rapi/resources.py b/lib/rapi/resources.py index 3d5ce246b1130a5df253ea61ee60676f766fe172..509801317a933ba49500060b38717952bfdad886 100644 --- a/lib/rapi/resources.py +++ b/lib/rapi/resources.py @@ -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.