mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-03 04:12:31 +01:00
cloudutils: fix adding rocky9 host failure due to missing /etc/sysconfig/libvirtd (#7779)
This commit is contained in:
parent
d958882282
commit
d89d40595c
@ -15,6 +15,7 @@
|
|||||||
# specific language governing permissions and limitations
|
# specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
import re
|
import re
|
||||||
|
import os
|
||||||
import tempfile
|
import tempfile
|
||||||
import shutil
|
import shutil
|
||||||
from .utilities import bash
|
from .utilities import bash
|
||||||
@ -59,8 +60,9 @@ class configFileOps:
|
|||||||
return ""
|
return ""
|
||||||
|
|
||||||
def save(self):
|
def save(self):
|
||||||
fp = open(self.fileName, "r")
|
|
||||||
newLines = []
|
newLines = []
|
||||||
|
if os.path.exists(self.fileName) and os.path.isfile(self.fileName):
|
||||||
|
fp = open(self.fileName, "r")
|
||||||
for line in fp.readlines():
|
for line in fp.readlines():
|
||||||
matched = False
|
matched = False
|
||||||
for entry in self.entries:
|
for entry in self.entries:
|
||||||
@ -93,6 +95,8 @@ class configFileOps:
|
|||||||
if not matched:
|
if not matched:
|
||||||
newLines.append(line)
|
newLines.append(line)
|
||||||
|
|
||||||
|
fp.close()
|
||||||
|
|
||||||
for entry in self.entries:
|
for entry in self.entries:
|
||||||
if entry.getState() != "set":
|
if entry.getState() != "set":
|
||||||
if entry.op == "add":
|
if entry.op == "add":
|
||||||
@ -101,8 +105,6 @@ class configFileOps:
|
|||||||
self.backups.append([None, newline])
|
self.backups.append([None, newline])
|
||||||
entry.setState("set")
|
entry.setState("set")
|
||||||
|
|
||||||
fp.close()
|
|
||||||
|
|
||||||
open(self.fileName, "w").writelines(newLines)
|
open(self.fileName, "w").writelines(newLines)
|
||||||
|
|
||||||
def replace_line(self, startswith,stanza,always_add=False):
|
def replace_line(self, startswith,stanza,always_add=False):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user