]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
Add Remote.arch
authorZack Cerza <zack.cerza@inktank.com>
Fri, 5 Sep 2014 15:32:33 +0000 (09:32 -0600)
committerZack Cerza <zack.cerza@inktank.com>
Thu, 11 Sep 2014 21:12:52 +0000 (15:12 -0600)
Returns the result of 'uname -p'

Signed-off-by: Zack Cerza <zack.cerza@inktank.com>
teuthology/orchestra/remote.py
teuthology/orchestra/test/test_remote.py

index 6d683657299e5b08d17d6bd4c60e24ea4d22cc76..e7f7a61ac34ff51bcad786f69eb96ce386d346b7 100644 (file)
@@ -245,6 +245,14 @@ class Remote(object):
             self._distro = Distribution(lsb_info.stdout.getvalue().strip())
         return self._distro
 
+    @property
+    def arch(self):
+        if not hasattr(self, '_arch'):
+            proc = self.run(args=['uname', '-p'], stdout=StringIO())
+            proc.wait()
+            self._arch = proc.stdout.getvalue().strip()
+        return self._arch
+
 
 class Distribution(object):
     """
index a2a32676d772bbe751e9a3cf95e6fd1141d204ed..8dd00191d6604481e7550fafb6e045e8fb28fa46 100644 (file)
@@ -1,6 +1,7 @@
 import fudge
 import fudge.inspector
 
+from cStringIO import StringIO, OutputType
 from textwrap import dedent
 
 from .. import remote
@@ -57,6 +58,40 @@ class TestRemote(object):
         assert got is ret
         assert got.remote is r
 
+    @fudge.with_fakes
+    def test_arch(self):
+        fudge.clear_expectations()
+        ssh = fudge.Fake('SSHConnection')
+        ssh.expects('get_transport').returns_fake().expects('getpeername')\
+            .returns(('name', 22))
+        run = fudge.Fake('run')
+        args = [
+            'uname',
+            '-p',
+            ]
+        stdout = StringIO('test_arch')
+        stdout.seek(0)
+        ret = RemoteProcess(
+            client=ssh,
+            args='fakey',
+            )
+        # status = self._stdout_buf.channel.recv_exit_status()
+        ret._stdout_buf = fudge.Fake()
+        ret._stdout_buf.channel = fudge.Fake()
+        ret._stdout_buf.channel.expects('recv_exit_status').returns(0)
+        ret.stdout = stdout
+        r = remote.Remote(name='jdoe@xyzzy.example.com', ssh=ssh)
+        run.expects_call().with_args(
+            client=ssh,
+            args=args,
+            stdout=fudge.inspector.arg.passes_test(
+                lambda v: isinstance(v, OutputType)),
+            name=r.shortname,
+            ).returns(ret)
+        # monkey patch ook ook
+        r._runner = run
+        assert r.arch == 'test_arch'
+
 
 class TestDistribution(object):
     lsb_centos = dedent("""