1 |
1 |
#
|
2 |
2 |
#
|
3 |
3 |
|
4 |
|
# Copyright (C) 2006, 2007, 2008, 2010 Google Inc.
|
|
4 |
# Copyright (C) 2006, 2007, 2008, 2010, 2011 Google Inc.
|
5 |
5 |
#
|
6 |
6 |
# This program is free software; you can redistribute it and/or modify
|
7 |
7 |
# it under the terms of the GNU General Public License as published by
|
... | ... | |
245 |
245 |
return file_storage_dir
|
246 |
246 |
|
247 |
247 |
|
|
248 |
def _InitSharedFileStorage(shared_file_storage_dir):
|
|
249 |
"""Initialize if needed the shared file storage.
|
|
250 |
|
|
251 |
@param shared_file_storage_dir: the user-supplied value
|
|
252 |
@return: either empty string (if file storage was disabled at build
|
|
253 |
time) or the normalized path to the storage directory
|
|
254 |
|
|
255 |
"""
|
|
256 |
if not constants.ENABLE_SHARED_FILE_STORAGE:
|
|
257 |
return ""
|
|
258 |
|
|
259 |
shared_file_storage_dir = os.path.normpath(shared_file_storage_dir)
|
|
260 |
|
|
261 |
if not os.path.isabs(shared_file_storage_dir):
|
|
262 |
raise errors.OpPrereqError("The shared file storage directory you"
|
|
263 |
" passed is not an absolute path.",
|
|
264 |
errors.ECODE_INVAL)
|
|
265 |
|
|
266 |
if not os.path.exists(shared_file_storage_dir):
|
|
267 |
try:
|
|
268 |
os.makedirs(shared_file_storage_dir, 0750)
|
|
269 |
except OSError, err:
|
|
270 |
raise errors.OpPrereqError("Cannot create file storage directory"
|
|
271 |
" '%s': %s" % (shared_file_storage_dir, err),
|
|
272 |
errors.ECODE_ENVIRON)
|
|
273 |
|
|
274 |
if not os.path.isdir(shared_file_storage_dir):
|
|
275 |
raise errors.OpPrereqError("The file storage directory '%s' is not"
|
|
276 |
" a directory." % shared_file_storage_dir,
|
|
277 |
errors.ECODE_ENVIRON)
|
|
278 |
return shared_file_storage_dir
|
|
279 |
|
|
280 |
|
248 |
281 |
def InitCluster(cluster_name, mac_prefix, # pylint: disable-msg=R0913
|
249 |
|
master_netdev, file_storage_dir, candidate_pool_size,
|
250 |
|
secondary_ip=None, vg_name=None, beparams=None,
|
251 |
|
nicparams=None, ndparams=None, hvparams=None,
|
|
282 |
master_netdev, file_storage_dir, shared_file_storage_dir,
|
|
283 |
candidate_pool_size, secondary_ip=None, vg_name=None,
|
|
284 |
beparams=None, nicparams=None, ndparams=None, hvparams=None,
|
252 |
285 |
enabled_hypervisors=None, modify_etc_hosts=True,
|
253 |
286 |
modify_ssh_setup=True, maintain_node_health=False,
|
254 |
287 |
drbd_helper=None, uid_pool=None, default_iallocator=None,
|
... | ... | |
347 |
380 |
errors.ECODE_INVAL)
|
348 |
381 |
|
349 |
382 |
file_storage_dir = _InitFileStorage(file_storage_dir)
|
|
383 |
shared_file_storage_dir = _InitSharedFileStorage(shared_file_storage_dir)
|
350 |
384 |
|
351 |
385 |
if not re.match("^[0-9a-z]{2}:[0-9a-z]{2}:[0-9a-z]{2}$", mac_prefix):
|
352 |
386 |
raise errors.OpPrereqError("Invalid mac prefix given '%s'" % mac_prefix,
|