Ejemplo n.º 1
0
    def test_make_names_data_with_options(self):
        data = make_names_data()

        assert data == [
            (
                '@vagrant/ubuntu16',
                {
                    'ssh_port': '2222',
                    'ssh_user': '******',
                    'ssh_hostname': '127.0.0.1',
                    'ssh_key': 'path/to/key',
                },
                ['mygroup', '@vagrant'],
            ),
            (
                '@vagrant/centos7',
                {
                    'ssh_port': '2200',
                    'ssh_user': '******',
                    'ssh_hostname': '127.0.0.1',
                    'ssh_key': 'path/to/key',
                    'somedata': 'somevalue',
                },
                ['@vagrant'],
            ),
            (
                '@vagrant/centos6',
                {
                    'ssh_hostname': '127.0.0.1',
                },
                ['@vagrant'],
            ),
        ]
Ejemplo n.º 2
0
    def test_make_names_data_with_limit(self):
        data = make_names_data(limit=('ubuntu16', ))

        assert data == [
            (
                '@vagrant/ubuntu16',
                {
                    'ssh_port': '2222',
                    'ssh_user': '******',
                    'ssh_hostname': '127.0.0.1',
                    'ssh_key': 'path/to/key',
                },
                ['@vagrant'],
            ),
        ]
Ejemplo n.º 3
0
    def operation_start(self, state, op_hash):
        print('Start operation: {0}'.format(op_hash))

    def operation_end(self, state, op_hash):
        print('End operation: {0}'.format(op_hash))


logging.basicConfig(level=logging.CRITICAL)

# Make our hosts and groups data (using the Vagrant connector in this case)
print('Loading Vagrant config...')
hosts = []
groups = defaultdict(lambda: ([], {}))

for name, data, group_names in make_names_data():
    hosts.append((name, data))
    for group_name in group_names:
        if name not in groups[group_name][0]:
            groups[group_name][0].append(name)

# First we setup some inventory we want to target
# the first argument is a tuple of (list all all hosts, global/ALL data)
inventory = Inventory((hosts, {}), **groups)

# Now we create a new config (w/optional args)
config = Config(
    FAIL_PERCENT=81,
    CONNECT_TIMEOUT=5,
)
Ejemplo n.º 4
0
 def test_make_names_data_no_matches(self):
     with self.assertRaises(InventoryError):
         make_names_data(limit='nope')