Fix warning when setup cloudstack-common (#4523)

This commit is contained in:
Wei Zhou 2020-12-09 18:30:59 +01:00 committed by GitHub
parent cd356c0513
commit 74982c5e76
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -301,7 +301,7 @@ def check_kvm():
except CalledProcessError: except CalledProcessError:
raise CheckFailed("KVM is not correctly installed on this system, or support for it is not enabled in the BIOS") raise CheckFailed("KVM is not correctly installed on this system, or support for it is not enabled in the BIOS")
except OSError as e: except OSError as e:
if e.errno is errno.ENOENT: raise CheckFailed("KVM is not correctly installed on this system, or support for it is not enabled in the BIOS") if e.errno == errno.ENOENT: raise CheckFailed("KVM is not correctly installed on this system, or support for it is not enabled in the BIOS")
raise raise
return True return True
raise AssertionError("check_kvm() should have never reached this part") raise AssertionError("check_kvm() should have never reached this part")
@ -431,7 +431,7 @@ class SetupNetworking(ConfigTask):
alreadysetup = augtool.match("/files/etc/network/interfaces/iface",self.brname).stdout.strip() alreadysetup = augtool.match("/files/etc/network/interfaces/iface",self.brname).stdout.strip()
return alreadysetup return alreadysetup
except OSError as e: except OSError as e:
if e.errno is 2: raise TaskFailed("augtool has not been properly installed on this system") if e.errno == 2: raise TaskFailed("augtool has not been properly installed on this system")
raise raise
def restore_state(self): def restore_state(self):
@ -646,7 +646,7 @@ class SetupCgConfig(ConfigTask):
try: try:
return "group virt" in open("/etc/cgconfig.conf","r").read(-1) return "group virt" in open("/etc/cgconfig.conf","r").read(-1)
except IOError as e: except IOError as e:
if e.errno is 2: raise TaskFailed("cgconfig has not been properly installed on this system") if e.errno == 2: raise TaskFailed("cgconfig has not been properly installed on this system")
raise raise
def execute(self): def execute(self):
@ -672,7 +672,7 @@ class SetupCgRules(ConfigTask):
try: try:
return self.cfgline in open("/etc/cgrules.conf","r").read(-1) return self.cfgline in open("/etc/cgrules.conf","r").read(-1)
except IOError as e: except IOError as e:
if e.errno is 2: raise TaskFailed("cgrulesd has not been properly installed on this system") if e.errno == 2: raise TaskFailed("cgrulesd has not been properly installed on this system")
raise raise
def execute(self): def execute(self):
@ -693,7 +693,7 @@ class SetupSecurityDriver(ConfigTask):
try: try:
return self.cfgline in open(self.filename,"r").read(-1) return self.cfgline in open(self.filename,"r").read(-1)
except IOError as e: except IOError as e:
if e.errno is 2: raise TaskFailed("qemu has not been properly installed on this system") if e.errno == 2: raise TaskFailed("qemu has not been properly installed on this system")
raise raise
def execute(self): def execute(self):
@ -712,7 +712,7 @@ class SetupLibvirt(ConfigTask):
else: raise AssertionError("We should not reach this") else: raise AssertionError("We should not reach this")
return self.cfgline in open(libvirtfile,"r").read(-1) return self.cfgline in open(libvirtfile,"r").read(-1)
except IOError as e: except IOError as e:
if e.errno is 2: raise TaskFailed("libvirt has not been properly installed on this system") if e.errno == 2: raise TaskFailed("libvirt has not been properly installed on this system")
raise raise
def execute(self): def execute(self):
@ -742,7 +742,7 @@ class SetupLiveMigration(ConfigTask):
lines = [ s.strip() for s in open("/etc/libvirt/libvirtd.conf").readlines() ] lines = [ s.strip() for s in open("/etc/libvirt/libvirtd.conf").readlines() ]
if all( [ stanza in lines for stanza in self.stanzas ] ): return True if all( [ stanza in lines for stanza in self.stanzas ] ): return True
except IOError as e: except IOError as e:
if e.errno is 2: raise TaskFailed("libvirt has not been properly installed on this system") if e.errno == 2: raise TaskFailed("libvirt has not been properly installed on this system")
raise raise
def execute(self): def execute(self):