コード例 #1
0
ファイル: test_pcp.py プロジェクト: Zhang-zezhu/teuthology
 def setup(self):
     self.ctx = FakeNamespace()
     self.ctx.cluster = Cluster()
     self.ctx.cluster.add(Remote('user@remote1'), ['role1'])
     self.ctx.cluster.add(Remote('user@remote2'), ['role2'])
     self.ctx.config = dict()
     self.task_config = dict()
     config.pcp_host = pcp_host
コード例 #2
0
 def setup(self):
     self.ctx = FakeNamespace()
     self.ctx.cluster = Cluster()
     self.ctx.cluster.add(Remote('user@remote1'), ['role1'])
     self.ctx.cluster.add(Remote('user@remote2'), ['role2'])
     self.ctx.config = dict()
     self.ctx.summary = dict()
     self.task_config = dict(playbook=[])
     self.start_patchers()
コード例 #3
0
 def setup(self):
     self.ctx = FakeNamespace()
     self.ctx.cluster = Cluster()
     self.ctx.cluster.add(Remote('user@remote1'), ['mon.0'])
     self.ctx.cluster.add(Remote('user@remote2'), ['mds.0'])
     self.ctx.cluster.add(Remote('user@remote3'), ['osd.0'])
     self.ctx.config = dict()
     self.task_config = dict()
     self.start_patchers()
コード例 #4
0
 def test_hosts_no_results(self):
     self.ctx.cluster = Cluster()
     self.ctx.cluster.add(Remote('user@remote1'), ['role1'])
     self.task_config.update(dict(hosts=['role2'], ))
     with patch.multiple(
             self.klass,
             begin=DEFAULT,
     ):
         with raises(RuntimeError):
             with self.klass(self.ctx, self.task_config):
                 pass
コード例 #5
0
 def setup(self):
     teuth_config.ipmi_domain = 'ipmi.domain'
     teuth_config.ipmi_user = '******'
     teuth_config.ipmi_password = '******'
     self.ctx = FakeNamespace()
     self.ctx.cluster = Cluster()
     self.ctx.cluster.add(Remote('user@remote1'), ['role1'])
     self.ctx.cluster.add(Remote('user@remote2'), ['role2'])
     self.ctx.config = dict()
     self.ctx.archive = '/fake/path'
     self.task_config = dict()
     self.start_patchers()
コード例 #6
0
 def test_hosts_one_role(self):
     self.ctx.cluster = Cluster()
     self.ctx.cluster.add(Remote('user@remote1'), ['role1'])
     self.ctx.cluster.add(Remote('user@remote2'), ['role2'])
     self.task_config.update(dict(hosts=['role1'], ))
     with patch.multiple(
             self.klass,
             begin=DEFAULT,
     ):
         with self.klass(self.ctx, self.task_config) as task:
             task_hosts = task.cluster.remotes.keys()
             assert len(task_hosts) == 1
             assert task_hosts[0].shortname == 'remote1'
コード例 #7
0
 def test_hosts_no_filter(self):
     self.ctx.cluster = Cluster()
     self.ctx.cluster.add(Remote('user@remote1'), ['role1'])
     self.ctx.cluster.add(Remote('user@remote2'), ['role2'])
     with patch.multiple(
             self.klass,
             begin=DEFAULT,
     ):
         with self.klass(self.ctx, self.task_config) as task:
             task_hosts = task.cluster.remotes.keys()
             assert len(task_hosts) == 2
             assert sorted(host.shortname for host in task_hosts) == \
                 ['remote1', 'remote2']
コード例 #8
0
 def test_hosts_two_roles(self):
     self.ctx.cluster = Cluster()
     self.ctx.cluster.add(Remote('user@remote1'), ['role1'])
     self.ctx.cluster.add(Remote('user@remote2'), ['role2'])
     self.ctx.cluster.add(Remote('user@remote3'), ['role3'])
     self.task_config.update(dict(hosts=['role1', 'role3'], ))
     with patch.multiple(
             self.klass,
             begin=DEFAULT,
     ):
         with self.klass(self.ctx, self.task_config) as task:
             task_hosts = task.cluster.remotes.keys()
             assert len(task_hosts) == 2
             hostnames = [host.shortname for host in task_hosts]
             assert sorted(hostnames) == ['remote1', 'remote3']
コード例 #9
0
ファイル: selinux.py プロジェクト: zhangrb/ceph-teuthology
 def filter_hosts(self):
     """
     Exclude any non-RPM-based hosts, and any downburst VMs
     """
     super(SELinux, self).filter_hosts()
     new_cluster = Cluster()
     for (remote, roles) in self.cluster.remotes.iteritems():
         if remote.is_vm:
             msg = "Excluding {host}: VMs are not yet supported"
             log.info(msg.format(host=remote.shortname))
         elif remote.os.package_type == 'rpm':
             new_cluster.add(remote, roles)
         else:
             msg = "Excluding {host}: OS '{os}' does not support SELinux"
             log.debug(msg.format(host=remote.shortname, os=remote.os.name))
     self.cluster = new_cluster
     return self.cluster
コード例 #10
0
 def test_hosts_one_role_one_hostname(self):
     self.ctx.cluster = Cluster()
     self.ctx.cluster.add(Remote('*****@*****.**'), ['role1'])
     self.ctx.cluster.add(Remote('*****@*****.**'), ['role2'])
     self.ctx.cluster.add(Remote('*****@*****.**'), ['role3'])
     self.task_config.update(dict(hosts=['role1', 'remote2.example.com'], ))
     with patch.multiple(
             self.klass,
             begin=DEFAULT,
             end=DEFAULT,
     ):
         with self.klass(self.ctx, self.task_config) as task:
             task_hosts = list(task.cluster.remotes)
             assert len(task_hosts) == 2
             hostnames = [host.hostname for host in task_hosts]
             assert sorted(hostnames) == [
                 'remote1.example.com', 'remote2.example.com'
             ]
コード例 #11
0
 def filter_hosts(self):
     super(ConsoleLog, self).filter_hosts()
     if not hasattr(self.ctx, 'cluster'):
         return
     new_cluster = Cluster()
     for (remote, roles) in self.cluster.remotes.iteritems():
         if not hasattr(remote.console, 'spawn_sol_log'):
             log.debug("%s does not support IPMI; excluding",
                       remote.shortname)
         elif not (remote.console.has_ipmi_credentials
                   or remote.console.has_conserver):
             log.debug(
                 "Cannot find IPMI credentials or conserver settings "
                 "for %s; excluding", remote.shortname)
         else:
             new_cluster.add(remote, roles)
     self.cluster = new_cluster
     return self.cluster
コード例 #12
0
 def test_host_exclusion(self):
     with patch.multiple(
             Remote,
             os=DEFAULT,
             run=DEFAULT,
     ):
         self.ctx.cluster = Cluster()
         remote1 = Remote('remote1')
         remote1.os = Mock()
         remote1.os.package_type = 'rpm'
         self.ctx.cluster.add(remote1, ['role1'])
         remote2 = Remote('remote1')
         remote2.os = Mock()
         remote2.os.package_type = 'deb'
         self.ctx.cluster.add(remote2, ['role2'])
         task_config = dict()
         with SELinux(self.ctx, task_config) as task:
             remotes = task.cluster.remotes.keys()
             assert remotes == [remote1]
コード例 #13
0
    def setup(self):
        self.ctx = FakeNamespace()
        self.ctx.cluster = Cluster()
        self.ctx.cluster.add(Remote('user@remote1'), ['role1'])
        self.ctx.cluster.add(Remote('user@remote2'), ['role2'])
        self.ctx.config = dict()
        self.task_config = dict()
        self.patcher_fetch_repo = patch('teuthology.task.ansible.fetch_repo')
        self.patcher_fetch_repo.return_value = 'PATH'
        self.patcher_fetch_repo.start()

        def fake_get_playbook(self):
            self.playbook_file = Mock()
            self.playbook_file.name = 'cephlab.yml'

        self.patcher_get_playbook = patch(
            'teuthology.task.ansible.CephLab.get_playbook',
            new=fake_get_playbook,
        )
        self.patcher_get_playbook.start()
コード例 #14
0
 def setup(self):
     self.ctx = FakeNamespace()
     self.ctx.cluster = Cluster()
     self.ctx.cluster.add(Remote('remote1'), ['mon.a', 'client.0'])
     self.ctx.cluster.add(Remote('remote2'), ['osd.0', 'osd.1', 'osd.2'])
     self.ctx.cluster.add(Remote('remote3'), ['client.1'])