Revision 880478f8 lib/backend.py
b/lib/backend.py | ||
---|---|---|
40 | 40 |
from ganeti import constants |
41 | 41 |
from ganeti import bdev |
42 | 42 |
from ganeti import objects |
43 |
from ganeti import ssconf |
|
43 | 44 |
|
44 | 45 |
|
45 | 46 |
def ListConfigFiles(): |
... | ... | |
63 | 64 |
"""Activate local node as master node. |
64 | 65 |
|
65 | 66 |
There are two needed steps for this: |
66 |
- register the master init script, and also run it now
|
|
67 |
- run the master script
|
|
67 | 68 |
- register the cron script |
68 | 69 |
|
69 | 70 |
""" |
70 |
result = utils.RunCmd(["update-rc.d", constants.MASTER_INITD_NAME, |
|
71 |
"defaults", "21", "79"]) |
|
72 |
|
|
73 |
if result.failed: |
|
74 |
logger.Error("could not register the master init.d script with command" |
|
75 |
" %s, error %s" % (result.cmd, result.output)) |
|
76 |
return False |
|
77 |
|
|
78 |
result = utils.RunCmd([constants.MASTER_INITD_SCRIPT, "start"]) |
|
71 |
result = utils.RunCmd([constants.MASTER_SCRIPT, "-d", "start"]) |
|
79 | 72 |
|
80 | 73 |
if result.failed: |
81 | 74 |
logger.Error("could not activate cluster interface with command %s," |
82 |
" error %s" % (result.cmd, result.output))
|
|
75 |
" error: '%s'" % (result.cmd, result.output))
|
|
83 | 76 |
return False |
84 | 77 |
|
85 | 78 |
utils.RemoveFile(constants.MASTER_CRON_LINK) |
... | ... | |
91 | 84 |
"""Deactivate this node as master. |
92 | 85 |
|
93 | 86 |
This does two things: |
94 |
- remove links to master's startup script
|
|
87 |
- run the master stop script
|
|
95 | 88 |
- remove link to master cron script. |
96 | 89 |
|
97 | 90 |
""" |
98 |
result = utils.RunCmd(["update-rc.d", "-f", |
|
99 |
constants.MASTER_INITD_NAME, "remove"]) |
|
100 |
if result.failed: |
|
101 |
logger.Error("could not unregister the master script with command" |
|
102 |
" %s, error %s" % (result.cmd, result.output)) |
|
103 |
return False |
|
104 |
|
|
105 |
output = utils.RunCmd([constants.MASTER_INITD_SCRIPT, "stop"]) |
|
91 |
result = utils.RunCmd([constants.MASTER_SCRIPT, "-d", "stop"]) |
|
106 | 92 |
|
107 | 93 |
if result.failed: |
108 | 94 |
logger.Error("could not deactivate cluster interface with command %s," |
109 |
" error %s" % (result.cmd, result.output))
|
|
95 |
" error: '%s'" % (result.cmd, result.output))
|
|
110 | 96 |
return False |
111 | 97 |
|
112 | 98 |
utils.RemoveFile(constants.MASTER_CRON_LINK) |
... | ... | |
170 | 156 |
if dirpath == constants.DATA_DIR: |
171 | 157 |
for i in filenames: |
172 | 158 |
os.unlink(os.path.join(dirpath, i)) |
173 |
utils.RemoveFile(constants.CLUSTER_NAME_FILE) |
|
174 | 159 |
|
175 | 160 |
f = open('/root/.ssh/id_dsa.pub', 'r') |
176 | 161 |
try: |
... | ... | |
794 | 779 |
file_name) |
795 | 780 |
return False |
796 | 781 |
|
797 |
if file_name not in [constants.CLUSTER_CONF_FILE, "/etc/hosts", |
|
798 |
"/etc/ssh/ssh_known_hosts"]: |
|
782 |
allowed_files = [constants.CLUSTER_CONF_FILE, "/etc/hosts", |
|
783 |
"/etc/ssh/ssh_known_hosts"] |
|
784 |
allowed_files.extend(ssconf.SimpleStore().GetFileList()) |
|
785 |
if file_name not in allowed_files: |
|
799 | 786 |
logger.Error("Filename passed to UploadFile not in allowed" |
800 | 787 |
" upload targets: '%s'" % file_name) |
801 | 788 |
return False |
Also available in: Unified diff