def _is_type(role):
"""
- Return type based on the starting role name. This should
- probably be improved in the future.
+ Return type based on the starting role name.
+
+ If there is more than one period, strip the first part
+ (ostensibly a cluster name) and check the remainder for the prefix.
"""
- return role.startswith(prefix)
+ if role.startswith(prefix):
+ return True
+ return (role.count('.') > 1 and
+ role[role.find('.') + 1:].startswith(prefix))
return _is_type
assert path == "http://qa-proxy.ceph.com/teuthology/teuthology-2013-09-12_11:49:50-ceph-deploy-master-testing-basic-vps/"
+def test_is_type():
+ is_client = misc.is_type('client')
+ assert is_client('client.0')
+ assert is_client('ceph.client.0')
+ assert is_client('foo.client.0')
+ assert is_client('foo.client.bar.baz')
+
+ assert not is_client('')
+ assert not is_client('foo.bar.baz')
+ assert not is_client('ceph.client')
+ assert not is_client('client')
+ assert not is_client('hadoop.master.0')
+
+
class TestHostnames(object):
def setup(self):
config._conf = dict()