mirror of
https://github.com/ceph/ceph
synced 2025-02-16 07:17:21 +00:00
Add Remote.arch
Returns the result of 'uname -p' Signed-off-by: Zack Cerza <zack.cerza@inktank.com>
This commit is contained in:
parent
9593534155
commit
d0630f7651
@ -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):
|
||||
"""
|
||||
|
@ -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("""
|
||||
|
Loading…
Reference in New Issue
Block a user