Skip to content
Snippets Groups Projects
Commit 8580cdaf authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

Migrate lib/cmdlib.py from constants to pathutils


File system paths moved from constants to pathutils.

Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent 78e706bb
No related branches found
No related tags found
No related merge requests found
...@@ -59,6 +59,7 @@ from ganeti import opcodes ...@@ -59,6 +59,7 @@ from ganeti import opcodes
from ganeti import ht from ganeti import ht
from ganeti import rpc from ganeti import rpc
from ganeti import runtime from ganeti import runtime
from ganeti import pathutils
from ganeti.masterd import iallocator from ganeti.masterd import iallocator
   
import ganeti.masterd.instance # pylint: disable=W0611 import ganeti.masterd.instance # pylint: disable=W0611
...@@ -1071,7 +1072,7 @@ def _GetClusterDomainSecret(): ...@@ -1071,7 +1072,7 @@ def _GetClusterDomainSecret():
"""Reads the cluster domain secret. """Reads the cluster domain secret.
   
""" """
return utils.ReadOneLineFile(constants.CLUSTER_DOMAIN_SECRET_FILE, return utils.ReadOneLineFile(pathutils.CLUSTER_DOMAIN_SECRET_FILE,
strict=True) strict=True)
   
   
...@@ -1964,7 +1965,7 @@ class LUClusterVerifyConfig(NoHooksLU, _VerifyErrors): ...@@ -1964,7 +1965,7 @@ class LUClusterVerifyConfig(NoHooksLU, _VerifyErrors):
   
feedback_fn("* Verifying cluster certificate files") feedback_fn("* Verifying cluster certificate files")
   
for cert_filename in constants.ALL_CERT_FILES: for cert_filename in pathutils.ALL_CERT_FILES:
(errcode, msg) = _VerifyCertificate(cert_filename) (errcode, msg) = _VerifyCertificate(cert_filename)
self._ErrorIf(errcode, constants.CV_ECLUSTERCERT, None, msg, code=errcode) self._ErrorIf(errcode, constants.CV_ECLUSTERCERT, None, msg, code=errcode)
   
...@@ -3068,7 +3069,7 @@ class LUClusterVerifyGroup(LogicalUnit, _VerifyErrors): ...@@ -3068,7 +3069,7 @@ class LUClusterVerifyGroup(LogicalUnit, _VerifyErrors):
   
user_scripts = [] user_scripts = []
if self.cfg.GetUseExternalMipScript(): if self.cfg.GetUseExternalMipScript():
user_scripts.append(constants.EXTERNAL_MASTER_SETUP_SCRIPT) user_scripts.append(pathutils.EXTERNAL_MASTER_SETUP_SCRIPT)
   
node_verify_param = { node_verify_param = {
constants.NV_FILELIST: constants.NV_FILELIST:
...@@ -3776,13 +3777,13 @@ class LUClusterRename(LogicalUnit): ...@@ -3776,13 +3777,13 @@ class LUClusterRename(LogicalUnit):
self.cfg.Update(cluster, feedback_fn) self.cfg.Update(cluster, feedback_fn)
   
# update the known hosts file # update the known hosts file
ssh.WriteKnownHostsFile(self.cfg, constants.SSH_KNOWN_HOSTS_FILE) ssh.WriteKnownHostsFile(self.cfg, pathutils.SSH_KNOWN_HOSTS_FILE)
node_list = self.cfg.GetOnlineNodeList() node_list = self.cfg.GetOnlineNodeList()
try: try:
node_list.remove(master_params.name) node_list.remove(master_params.name)
except ValueError: except ValueError:
pass pass
_UploadHelper(self, node_list, constants.SSH_KNOWN_HOSTS_FILE) _UploadHelper(self, node_list, pathutils.SSH_KNOWN_HOSTS_FILE)
finally: finally:
master_params.ip = new_ip master_params.ip = new_ip
result = self.rpc.call_node_activate_master_ip(master_params.name, result = self.rpc.call_node_activate_master_ip(master_params.name,
...@@ -4278,39 +4279,39 @@ def _ComputeAncillaryFiles(cluster, redist): ...@@ -4278,39 +4279,39 @@ def _ComputeAncillaryFiles(cluster, redist):
""" """
# Compute files for all nodes # Compute files for all nodes
files_all = set([ files_all = set([
constants.SSH_KNOWN_HOSTS_FILE, pathutils.SSH_KNOWN_HOSTS_FILE,
constants.CONFD_HMAC_KEY, pathutils.CONFD_HMAC_KEY,
constants.CLUSTER_DOMAIN_SECRET_FILE, pathutils.CLUSTER_DOMAIN_SECRET_FILE,
constants.SPICE_CERT_FILE, pathutils.SPICE_CERT_FILE,
constants.SPICE_CACERT_FILE, pathutils.SPICE_CACERT_FILE,
constants.RAPI_USERS_FILE, pathutils.RAPI_USERS_FILE,
]) ])
   
if not redist: if not redist:
files_all.update(constants.ALL_CERT_FILES) files_all.update(pathutils.ALL_CERT_FILES)
files_all.update(ssconf.SimpleStore().GetFileList()) files_all.update(ssconf.SimpleStore().GetFileList())
else: else:
# we need to ship at least the RAPI certificate # we need to ship at least the RAPI certificate
files_all.add(constants.RAPI_CERT_FILE) files_all.add(pathutils.RAPI_CERT_FILE)
   
if cluster.modify_etc_hosts: if cluster.modify_etc_hosts:
files_all.add(constants.ETC_HOSTS) files_all.add(constants.ETC_HOSTS)
   
if cluster.use_external_mip_script: if cluster.use_external_mip_script:
files_all.add(constants.EXTERNAL_MASTER_SETUP_SCRIPT) files_all.add(pathutils.EXTERNAL_MASTER_SETUP_SCRIPT)
   
# Files which are optional, these must: # Files which are optional, these must:
# - be present in one other category as well # - be present in one other category as well
# - either exist or not exist on all nodes of that category (mc, vm all) # - either exist or not exist on all nodes of that category (mc, vm all)
files_opt = set([ files_opt = set([
constants.RAPI_USERS_FILE, pathutils.RAPI_USERS_FILE,
]) ])
   
# Files which should only be on master candidates # Files which should only be on master candidates
files_mc = set() files_mc = set()
   
if not redist: if not redist:
files_mc.add(constants.CLUSTER_CONF_FILE) files_mc.add(pathutils.CLUSTER_CONF_FILE)
   
# Files which should only be on VM-capable nodes # Files which should only be on VM-capable nodes
files_vm = set( files_vm = set(
...@@ -4372,8 +4373,8 @@ def _RedistributeAncillaryFiles(lu, additional_nodes=None, additional_vm=True): ...@@ -4372,8 +4373,8 @@ def _RedistributeAncillaryFiles(lu, additional_nodes=None, additional_vm=True):
_ComputeAncillaryFiles(cluster, True) _ComputeAncillaryFiles(cluster, True)
   
# Never re-distribute configuration file from here # Never re-distribute configuration file from here
assert not (constants.CLUSTER_CONF_FILE in files_all or assert not (pathutils.CLUSTER_CONF_FILE in files_all or
constants.CLUSTER_CONF_FILE in files_vm) pathutils.CLUSTER_CONF_FILE in files_vm)
assert not files_mc, "Master candidates not handled in this function" assert not files_mc, "Master candidates not handled in this function"
   
filemap = [ filemap = [
...@@ -6284,12 +6285,12 @@ class _ClusterQuery(_QueryBase): ...@@ -6284,12 +6285,12 @@ class _ClusterQuery(_QueryBase):
cluster = NotImplemented cluster = NotImplemented
   
if query.CQ_QUEUE_DRAINED in self.requested_data: if query.CQ_QUEUE_DRAINED in self.requested_data:
drain_flag = os.path.exists(constants.JOB_QUEUE_DRAIN_FILE) drain_flag = os.path.exists(pathutils.JOB_QUEUE_DRAIN_FILE)
else: else:
drain_flag = NotImplemented drain_flag = NotImplemented
   
if query.CQ_WATCHER_PAUSE in self.requested_data: if query.CQ_WATCHER_PAUSE in self.requested_data:
watcher_pause = utils.ReadWatcherPauseFile(constants.WATCHER_PAUSEFILE) watcher_pause = utils.ReadWatcherPauseFile(pathutils.WATCHER_PAUSEFILE)
else: else:
watcher_pause = NotImplemented watcher_pause = NotImplemented
   
...@@ -9478,7 +9479,7 @@ class LUInstanceCreate(LogicalUnit): ...@@ -9478,7 +9479,7 @@ class LUInstanceCreate(LogicalUnit):
self.needed_locks[locking.LEVEL_NODE].append(src_node) self.needed_locks[locking.LEVEL_NODE].append(src_node)
if not os.path.isabs(src_path): if not os.path.isabs(src_path):
self.op.src_path = src_path = \ self.op.src_path = src_path = \
utils.PathJoin(constants.EXPORT_DIR, src_path) utils.PathJoin(pathutils.EXPORT_DIR, src_path)
   
def _RunAllocator(self): def _RunAllocator(self):
"""Run the allocator based on input opcode. """Run the allocator based on input opcode.
...@@ -9582,7 +9583,7 @@ class LUInstanceCreate(LogicalUnit): ...@@ -9582,7 +9583,7 @@ class LUInstanceCreate(LogicalUnit):
if src_path in exp_list[node].payload: if src_path in exp_list[node].payload:
found = True found = True
self.op.src_node = src_node = node self.op.src_node = src_node = node
self.op.src_path = src_path = utils.PathJoin(constants.EXPORT_DIR, self.op.src_path = src_path = utils.PathJoin(pathutils.EXPORT_DIR,
src_path) src_path)
break break
if not found: if not found:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment