def test_generate_ceph_authtool_cmd_non_container_no_auid(self): fake_cluster = "fake" fake_name = "client.fake" fake_secret = "super-secret" fake_caps = { 'mon': 'allow *', 'osd': 'allow rwx', } 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 = [ 'ceph-authtool', '--create-keyring', fake_file_destination, '--name', fake_name, '--add-key', fake_secret, '--cap', 'mon', 'allow *', '--cap', 'osd', 'allow rwx', ] result = ceph_key.generate_ceph_authtool_cmd( fake_cluster, fake_name, fake_secret, fake_caps, fake_file_destination) # noqa E501 assert result == expected_command_list
def test_generate_ceph_authtool_cmd_container(self): fake_cluster = "fake" fake_name = "client.fake" fake_secret = "super-secret" fake_caps = { 'mon': 'allow *', 'osd': 'allow rwx', } fake_dest = "/fake/ceph" fake_keyring_filename = fake_cluster + "." + fake_name + ".keyring" fake_file_destination = os.path.join(fake_dest, fake_keyring_filename) fake_container_image = "docker.io/ceph/daemon:latest-luminous" expected_command_list = [ 'docker', '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-authtool', 'docker.io/ceph/daemon:latest-luminous', '--create-keyring', fake_file_destination, '--name', fake_name, '--add-key', fake_secret, '--cap', 'mon', 'allow *', '--cap', 'osd', 'allow rwx' ] result = ceph_key.generate_ceph_authtool_cmd( fake_cluster, fake_name, fake_secret, fake_caps, fake_file_destination, fake_container_image) # noqa E501 assert result == expected_command_list