Commit 2fd4e86d authored by Jose A. Lopes's avatar Jose A. Lopes
Browse files

Use RPC transport to pass OS params to the metadata daemon

* Use RPC transport to pass OS params to the metadata daemon, using
  the Luxi protocol
* Fix comment in 'ganeti.rpc.transport'
Signed-off-by: default avatarJose A. Lopes <>
Reviewed-by: default avatarHrvoje Ribicic <>
parent acc1eb23
......@@ -47,6 +47,7 @@ import random
import re
import shutil
import signal
import socket
import stat
import tempfile
import time
......@@ -73,6 +74,8 @@ from ganeti import ht
from import BlockDev
from import DRBD8
from ganeti import hooksmaster
from ganeti.rpc import transport
from ganeti.rpc.errors import NoMasterError, TimeoutError
_BOOT_ID_PATH = "/proc/sys/kernel/random/boot_id"
......@@ -2170,6 +2173,47 @@ def HotplugSupported(instance):
_Fail("Hotplug is not supported: %s", err)
def ModifyInstanceMetadata(metadata):
"""Sends instance data to the metadata daemon.
Uses the Luxi transport layer to communicate with the metadata
daemon configuration server. It starts the metadata daemon if it is
not running.
@type metadata: dict
@param metadata: instance metadata obtained by calling
L{objects.Instance.ToDict} on an instance object
if not utils.IsDaemonAlive(constants.METAD):
result = utils.RunCmd(constants.METAD)
if result.failed:
raise errors.HypervisorError("Failed to start metadata daemon")
def _Connect():
return transport.Transport(pathutils.SOCKET_DIR + "/ganeti-metad")
retries = 5
while True:
trans = utils.Retry(_Connect, 1.0, constants.LUXI_DEF_CTMO)
except utils.RetryTimeout:
raise TimeoutError("Connection to metadata daemon timed out")
except (socket.error, NoMasterError), err:
if retries == 0:
raise TimeoutError("Failed to connect to metadata daemon: %s" % err)
retries -= 1
data = serializer.DumpJson(metadata,
def BlockdevCreate(disk, size, owner, on_primary, info, excl_stor):
"""Creates a block device for an instance.
# Copyright (C) 2013 Google Inc.
# Copyright (C) 2013, 2014 Google Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......@@ -44,7 +44,7 @@ class Transport:
This is used on the client side.
This could be replace by any other class that provides the same
This could be replaced by any other class that provides the same
semantics to the Client. This means:
- can send messages and receive messages
- safe for multithreading
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