Merge "guestagent contract for packages should be a list"
This commit is contained in:
commit
3d5ece0d8a
@ -230,6 +230,7 @@ class API(proxy.RpcProxy):
|
|||||||
as a database container optionally includes a backup id for restores
|
as a database container optionally includes a backup id for restores
|
||||||
"""
|
"""
|
||||||
LOG.debug("Sending the call to prepare the Guest")
|
LOG.debug("Sending the call to prepare the Guest")
|
||||||
|
packages = packages.split()
|
||||||
self._cast_with_consumer(
|
self._cast_with_consumer(
|
||||||
"prepare", packages=packages, databases=databases,
|
"prepare", packages=packages, databases=databases,
|
||||||
memory_mb=memory_mb, users=users, device_path=device_path,
|
memory_mb=memory_mb, users=users, device_path=device_path,
|
||||||
|
@ -178,11 +178,11 @@ class RedhatPackagerMixin(BasePackagerMixin):
|
|||||||
raise PkgPackageStateError("Cannot install packages.")
|
raise PkgPackageStateError("Cannot install packages.")
|
||||||
|
|
||||||
def pkg_is_installed(self, packages):
|
def pkg_is_installed(self, packages):
|
||||||
pkg_list = packages.split()
|
packages = packages if isinstance(packages, list) else packages.split()
|
||||||
cmd = "rpm -qa"
|
cmd = "rpm -qa"
|
||||||
p = commands.getstatusoutput(cmd)
|
p = commands.getstatusoutput(cmd)
|
||||||
std_out = p[1]
|
std_out = p[1]
|
||||||
for pkg in pkg_list:
|
for pkg in packages:
|
||||||
found = False
|
found = False
|
||||||
for line in std_out.split("\n"):
|
for line in std_out.split("\n"):
|
||||||
if line.find(pkg) != -1:
|
if line.find(pkg) != -1:
|
||||||
@ -271,7 +271,7 @@ class DebianPackagerMixin(BasePackagerMixin):
|
|||||||
cmd = "sudo -E DEBIAN_FRONTEND=noninteractive apt-get -y " \
|
cmd = "sudo -E DEBIAN_FRONTEND=noninteractive apt-get -y " \
|
||||||
"--force-yes --allow-unauthenticated -o " \
|
"--force-yes --allow-unauthenticated -o " \
|
||||||
"DPkg::options::=--force-confmiss --reinstall " \
|
"DPkg::options::=--force-confmiss --reinstall " \
|
||||||
"install %s" % packages
|
"install %s" % " ".join(packages)
|
||||||
output_expects = ['.*password*',
|
output_expects = ['.*password*',
|
||||||
'E: Unable to locate package (.*)',
|
'E: Unable to locate package (.*)',
|
||||||
"Couldn't find package (.*)",
|
"Couldn't find package (.*)",
|
||||||
@ -361,8 +361,8 @@ class DebianPackagerMixin(BasePackagerMixin):
|
|||||||
return version
|
return version
|
||||||
|
|
||||||
def pkg_is_installed(self, packages):
|
def pkg_is_installed(self, packages):
|
||||||
pkg_list = packages.split()
|
packages = packages if isinstance(packages, list) else packages.split()
|
||||||
for pkg in pkg_list:
|
for pkg in packages:
|
||||||
m = re.match('(.+)=(.+)', pkg)
|
m = re.match('(.+)=(.+)', pkg)
|
||||||
if m:
|
if m:
|
||||||
package_name = m.group(1)
|
package_name = m.group(1)
|
||||||
|
@ -52,16 +52,16 @@ class PkgDEBInstallTestCase(testtools.TestCase):
|
|||||||
self.pkg._fix_package_selections = self.pkg_fix_package_selections
|
self.pkg._fix_package_selections = self.pkg_fix_package_selections
|
||||||
|
|
||||||
def test_pkg_is_instaled_no_packages(self):
|
def test_pkg_is_instaled_no_packages(self):
|
||||||
packages = ""
|
packages = []
|
||||||
self.assertTrue(self.pkg.pkg_is_installed(packages))
|
self.assertTrue(self.pkg.pkg_is_installed(packages))
|
||||||
|
|
||||||
def test_pkg_is_instaled_yes(self):
|
def test_pkg_is_instaled_yes(self):
|
||||||
packages = "package1=1.0 package2"
|
packages = ["package1=1.0", "package2"]
|
||||||
self.pkg.pkg_version = MagicMock(side_effect=["1.0", "2.0"])
|
self.pkg.pkg_version = MagicMock(side_effect=["1.0", "2.0"])
|
||||||
self.assertTrue(self.pkg.pkg_is_installed(packages))
|
self.assertTrue(self.pkg.pkg_is_installed(packages))
|
||||||
|
|
||||||
def test_pkg_is_instaled_no(self):
|
def test_pkg_is_instaled_no(self):
|
||||||
packages = "package1=1.0 package2 package3=3.1"
|
packages = ["package1=1.0", "package2", "package3=3.1"]
|
||||||
self.pkg.pkg_version = MagicMock(side_effect=["1.0", "2.0", "3.0"])
|
self.pkg.pkg_version = MagicMock(side_effect=["1.0", "2.0", "3.0"])
|
||||||
self.assertFalse(self.pkg.pkg_is_installed(packages))
|
self.assertFalse(self.pkg.pkg_is_installed(packages))
|
||||||
|
|
||||||
@ -302,17 +302,17 @@ class PkgRPMInstallTestCase(testtools.TestCase):
|
|||||||
pexpect.spawn.close = self.pexpect_spawn_closed
|
pexpect.spawn.close = self.pexpect_spawn_closed
|
||||||
|
|
||||||
def test_pkg_is_instaled_no_packages(self):
|
def test_pkg_is_instaled_no_packages(self):
|
||||||
packages = ""
|
packages = []
|
||||||
self.assertTrue(self.pkg.pkg_is_installed(packages))
|
self.assertTrue(self.pkg.pkg_is_installed(packages))
|
||||||
|
|
||||||
def test_pkg_is_instaled_yes(self):
|
def test_pkg_is_instaled_yes(self):
|
||||||
packages = "package1=1.0 package2"
|
packages = ["package1=1.0", "package2"]
|
||||||
commands.getstatusoutput = MagicMock(return_value={1: "package1=1.0\n"
|
commands.getstatusoutput = MagicMock(return_value={1: "package1=1.0\n"
|
||||||
"package2=2.0"})
|
"package2=2.0"})
|
||||||
self.assertTrue(self.pkg.pkg_is_installed(packages))
|
self.assertTrue(self.pkg.pkg_is_installed(packages))
|
||||||
|
|
||||||
def test_pkg_is_instaled_no(self):
|
def test_pkg_is_instaled_no(self):
|
||||||
packages = "package1=1.0 package2 package3=3.0"
|
packages = ["package1=1.0", "package2", "package3=3.0"]
|
||||||
commands.getstatusoutput = MagicMock(return_value={1: "package1=1.0\n"
|
commands.getstatusoutput = MagicMock(return_value={1: "package1=1.0\n"
|
||||||
"package2=2.0"})
|
"package2=2.0"})
|
||||||
self.assertFalse(self.pkg.pkg_is_installed(packages))
|
self.assertFalse(self.pkg.pkg_is_installed(packages))
|
||||||
|
Loading…
Reference in New Issue
Block a user