def test_default_matching(self):
        """
        Test the output of a fixture tfstate file which contains libvirt
        resources using matching
        """
        tfstate = os.path.join(os.path.dirname(__file__), "terraform.data",
                               "terraform.tfstate")
        pki_dir = os.path.abspath(
            os.path.join(os.path.dirname(__file__), "terraform.data"))

        with patch.dict(terraform.__opts__, {
                "roster_file": tfstate,
                "pki_dir": pki_dir
        }):
            expected_result = {
                "web0": {
                    "host": "192.168.122.106",
                    "user": "******",
                    "passwd": "linux",
                    "timeout": 22,
                    "priv": os.path.join(pki_dir, "ssh", "salt-ssh.rsa"),
                },
                "web1": {
                    "host": "192.168.122.235",
                    "user": "******",
                    "passwd": "linux",
                    "timeout": 22,
                    "priv": os.path.join(pki_dir, "ssh", "salt-ssh.rsa"),
                },
            }

            ret = terraform.targets("*web*")
            self.assertDictEqual(expected_result, ret)
示例#2
0
    def test_default_matching(self):
        '''
        Test the output of a fixture tfstate file wich contains libvirt
        resources using matching
        '''
        tfstate = os.path.join(os.path.dirname(__file__), 'terraform.data', 'terraform.tfstate')
        pki_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), 'terraform.data'))

        with patch.dict(terraform.__opts__, {'roster_file': tfstate, 'pki_dir': pki_dir}):
            expected_result = {
                'web0': {
                    'host': '192.168.122.106',
                    'user': '******',
                    'passwd': 'linux',
                    'timeout': 22,
                    'priv': os.path.join(pki_dir, 'ssh', 'salt-ssh.rsa')},
                'web1': {
                    'host': '192.168.122.235',
                    'user': '******',
                    'passwd': 'linux',
                    'timeout': 22,
                    'priv': os.path.join(pki_dir, 'ssh', 'salt-ssh.rsa')}
            }

            ret = terraform.targets('*web*')
            self.assertDictEqual(expected_result, ret)