|
|
@ -203,15 +203,19 @@ class RedHatStrategy(GenericStrategy):
|
|
|
|
def set_permanent_hostname(self, name):
|
|
|
|
def set_permanent_hostname(self, name):
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
lines = []
|
|
|
|
lines = []
|
|
|
|
|
|
|
|
found = False
|
|
|
|
f = open(self.NETWORK_FILE, 'rb')
|
|
|
|
f = open(self.NETWORK_FILE, 'rb')
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
for line in f.readlines():
|
|
|
|
for line in f.readlines():
|
|
|
|
if line.startswith('HOSTNAME'):
|
|
|
|
if line.startswith('HOSTNAME'):
|
|
|
|
lines.append("HOSTNAME=%s\n" % name)
|
|
|
|
lines.append("HOSTNAME=%s\n" % name)
|
|
|
|
|
|
|
|
found = True
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
lines.append(line)
|
|
|
|
lines.append(line)
|
|
|
|
finally:
|
|
|
|
finally:
|
|
|
|
f.close()
|
|
|
|
f.close()
|
|
|
|
|
|
|
|
if not found:
|
|
|
|
|
|
|
|
lines.append("HOSTNAME=%s\n" % name)
|
|
|
|
f = open(self.NETWORK_FILE, 'w+')
|
|
|
|
f = open(self.NETWORK_FILE, 'w+')
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
f.writelines(lines)
|
|
|
|
f.writelines(lines)
|
|
|
|