from ganeti import runtime
from ganeti import compat
from ganeti import rpc_defs
+from ganeti import pathutils
+from ganeti import vcluster
# Special module generated at build time
from ganeti import _generated_rpc
import ganeti.http.client # pylint: disable=W0611
-# Timeout for connecting to nodes (seconds)
-_RPC_CONNECT_TIMEOUT = 5
-
_RPC_CLIENT_HEADERS = [
"Content-type: %s" % http.HTTP_APP_JSON,
"Expect:",
]
-# Various time constants for the timeout table
-_TMO_URGENT = 60 # one minute
-_TMO_FAST = 5 * 60 # five minutes
-_TMO_NORMAL = 15 * 60 # 15 minutes
-_TMO_SLOW = 3600 # one hour
-_TMO_4HRS = 4 * 3600
-_TMO_1DAY = 86400
-
#: Special value to describe an offline host
_OFFLINE = object()
def _ConfigRpcCurl(curl):
- noded_cert = str(constants.NODED_CERT_FILE)
+ noded_cert = str(pathutils.NODED_CERT_FILE)
curl.setopt(pycurl.FOLLOWLOCATION, False)
curl.setopt(pycurl.CAINFO, noded_cert)
curl.setopt(pycurl.SSLCERT, noded_cert)
curl.setopt(pycurl.SSLKEYTYPE, "PEM")
curl.setopt(pycurl.SSLKEY, noded_cert)
- curl.setopt(pycurl.CONNECTTIMEOUT, _RPC_CONNECT_TIMEOUT)
+ curl.setopt(pycurl.CONNECTTIMEOUT, constants.RPC_CONNECT_TIMEOUT)
def RunWithRPC(fn):
getents = getents_fn()
- return [filename, data, st.st_mode, getents.LookupUid(st.st_uid),
+ virt_filename = vcluster.MakeVirtualPath(filename)
+
+ return [virt_filename, data, st.st_mode, getents.LookupUid(st.st_uid),
getents.LookupGid(st.st_gid), st.st_atime, st.st_mtime]
return [(d.ToDict(), uid) for d, uid in value]
+def MakeLegacyNodeInfo(data):
+ """Formats the data returned by L{rpc.RpcRunner.call_node_info}.
+
+ Converts the data into a single dictionary. This is fine for most use cases,
+ but some require information from more than one volume group or hypervisor.
+
+ """
+ (bootid, (vg_info, ), (hv_info, )) = data
+
+ return utils.JoinDisjointDicts(utils.JoinDisjointDicts(vg_info, hv_info), {
+ "bootid": bootid,
+ })
+
+
def _AnnotateDParamsDRBD(disk, (drbd_params, data_params, meta_params)):
"""Annotates just DRBD disks layouts.
else:
annotation_fn = _AnnotateDParamsGeneric
- new_disks = []
- for disk in disks:
- new_disks.append(annotation_fn(disk.Copy(), ld_params))
-
- return new_disks
+ return [annotation_fn(disk.Copy(), ld_params) for disk in disks]
#: Generic encoders