mirror of https://github.com/apache/cloudstack.git
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
|
||||
# under the License.
|
||||
import re
|
||||
import os
|
||||
import tempfile
|
||||
import shutil
|
||||
from .utilities import bash
|
||||
|
|
@ -59,8 +60,9 @@ class configFileOps:
|
|||
return ""
|
||||
|
||||
def save(self):
|
||||
fp = open(self.fileName, "r")
|
||||
newLines = []
|
||||
if os.path.exists(self.fileName) and os.path.isfile(self.fileName):
|
||||
fp = open(self.fileName, "r")
|
||||
for line in fp.readlines():
|
||||
matched = False
|
||||
for entry in self.entries:
|
||||
|
|
@ -93,6 +95,8 @@ class configFileOps:
|
|||
if not matched:
|
||||
newLines.append(line)
|
||||
|
||||
fp.close()
|
||||
|
||||
for entry in self.entries:
|
||||
if entry.getState() != "set":
|
||||
if entry.op == "add":
|
||||
|
|
@ -101,8 +105,6 @@ class configFileOps:
|
|||
self.backups.append([None, newline])
|
||||
entry.setState("set")
|
||||
|
||||
fp.close()
|
||||
|
||||
open(self.fileName, "w").writelines(newLines)
|
||||
|
||||
def replace_line(self, startswith,stanza,always_add=False):
|
||||
|
|
|
|||
Loading…
Reference in New Issue