Merge "guestagent contract for packages should be a list"

This commit is contained in:
Jenkins 2014-07-23 00:45:01 +00:00 committed by Gerrit Code Review
commit 3d5ece0d8a
3 changed files with 12 additions and 11 deletions

View File

@ -230,6 +230,7 @@ class API(proxy.RpcProxy):
as a database container optionally includes a backup id for restores
"""
LOG.debug("Sending the call to prepare the Guest")
packages = packages.split()
self._cast_with_consumer(
"prepare", packages=packages, databases=databases,
memory_mb=memory_mb, users=users, device_path=device_path,

View File

@ -178,11 +178,11 @@ class RedhatPackagerMixin(BasePackagerMixin):
raise PkgPackageStateError("Cannot install packages.")
def pkg_is_installed(self, packages):
pkg_list = packages.split()
packages = packages if isinstance(packages, list) else packages.split()
cmd = "rpm -qa"
p = commands.getstatusoutput(cmd)
std_out = p[1]
for pkg in pkg_list:
for pkg in packages:
found = False
for line in std_out.split("\n"):
if line.find(pkg) != -1:
@ -271,7 +271,7 @@ class DebianPackagerMixin(BasePackagerMixin):
cmd = "sudo -E DEBIAN_FRONTEND=noninteractive apt-get -y " \
"--force-yes --allow-unauthenticated -o " \
"DPkg::options::=--force-confmiss --reinstall " \
"install %s" % packages
"install %s" % " ".join(packages)
output_expects = ['.*password*',
'E: Unable to locate package (.*)',
"Couldn't find package (.*)",
@ -361,8 +361,8 @@ class DebianPackagerMixin(BasePackagerMixin):
return version
def pkg_is_installed(self, packages):
pkg_list = packages.split()
for pkg in pkg_list:
packages = packages if isinstance(packages, list) else packages.split()
for pkg in packages:
m = re.match('(.+)=(.+)', pkg)
if m:
package_name = m.group(1)

View File

@ -52,16 +52,16 @@ class PkgDEBInstallTestCase(testtools.TestCase):
self.pkg._fix_package_selections = self.pkg_fix_package_selections
def test_pkg_is_instaled_no_packages(self):
packages = ""
packages = []
self.assertTrue(self.pkg.pkg_is_installed(packages))
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.assertTrue(self.pkg.pkg_is_installed(packages))
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.assertFalse(self.pkg.pkg_is_installed(packages))
@ -302,17 +302,17 @@ class PkgRPMInstallTestCase(testtools.TestCase):
pexpect.spawn.close = self.pexpect_spawn_closed
def test_pkg_is_instaled_no_packages(self):
packages = ""
packages = []
self.assertTrue(self.pkg.pkg_is_installed(packages))
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"
"package2=2.0"})
self.assertTrue(self.pkg.pkg_is_installed(packages))
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"
"package2=2.0"})
self.assertFalse(self.pkg.pkg_is_installed(packages))