def test_get_key_non_container(self): fake_cluster = "fake" fake_dest = "/fake/ceph" fake_name = "client.fake" fake_keyring_filename = fake_cluster + "." + fake_name + ".keyring" fake_file_destination = os.path.join(fake_dest, fake_keyring_filename) expected_command_list = [ [ 'ceph', '-n', "client.admin", '-k', "/etc/ceph/fake.client.admin.keyring", # noqa E501 '--cluster', fake_cluster, 'auth', 'get', fake_name, '-o', fake_file_destination ], # noqa E501 ] result = ceph_key.get_key(fake_cluster, fake_name, fake_file_destination) # noqa E501 assert result == expected_command_list
def test_get_key_container(self): fake_cluster = "fake" fake_name = "client.fake" fake_container_image = "docker.io/ceph/daemon:latest-luminous" fake_dest = "/fake/ceph" fake_keyring_filename = fake_cluster + "." + fake_name + ".keyring" fake_file_destination = os.path.join(fake_dest, fake_keyring_filename) expected_command_list = [['docker', # noqa E128 'run', '--rm', '--net=host', '-v', '/etc/ceph:/etc/ceph:z', '-v', '/var/lib/ceph/:/var/lib/ceph/:z', '-v', '/var/log/ceph/:/var/log/ceph/:z', '--entrypoint=ceph', 'docker.io/ceph/daemon:latest-luminous', '-n', "client.admin", '-k', "/etc/ceph/fake.client.admin.keyring", # noqa E501 '--cluster', fake_cluster, 'auth', 'get', fake_name, '-o', fake_file_destination], ] result = ceph_key.get_key( fake_cluster, fake_name, fake_file_destination, fake_container_image) # noqa E501 assert result == expected_command_list