import json
import os
from . import ceph_key
+import mock
+@mock.patch.dict(os.environ, {'CEPH_CONTAINER_BINARY': 'docker'})
class TestCephKeyModule(object):
def test_generate_secret(self):
'allow rwx',
]
result = ceph_key.generate_ceph_authtool_cmd(
- fake_cluster, fake_name, fake_secret, fake_caps, fake_dest) # noqa E501
+ 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):
'osd',
'allow rwx']
result = ceph_key.generate_ceph_authtool_cmd(
- fake_cluster, fake_name, fake_secret, fake_caps, fake_dest, fake_container_image) # noqa E501
+ fake_cluster, fake_name, fake_secret, fake_caps, fake_file_destination, fake_container_image) # noqa E501
assert result == expected_command_list
def test_create_key_non_container(self):
'import', '-i', fake_file_destination],
]
result = ceph_key.create_key(fake_module, fake_result, fake_cluster,
- fake_name, fake_secret, fake_caps, fake_import_key, fake_dest) # noqa E501
+ fake_name, fake_secret, fake_caps, fake_import_key, fake_file_destination) # noqa E501
assert result == expected_command_list
def test_create_key_container(self):
'-i', fake_file_destination]
]
result = ceph_key.create_key(fake_module, fake_result, fake_cluster, fake_name, # noqa E501
- fake_secret, fake_caps, fake_import_key, fake_dest, fake_container_image) # noqa E501
+ fake_secret, fake_caps, fake_import_key, fake_file_destination, fake_container_image) # noqa E501
assert result == expected_command_list
def test_create_key_non_container_no_import(self):
'allow rwx', ]
]
result = ceph_key.create_key(fake_module, fake_result, fake_cluster,
- fake_name, fake_secret, fake_caps, fake_import_key, fake_dest) # noqa E501
+ fake_name, fake_secret, fake_caps, fake_import_key, fake_file_destination) # noqa E501
assert result == expected_command_list
def test_create_key_container_no_import(self):
'osd',
'allow rwx']]
result = ceph_key.create_key(fake_module, fake_result, fake_cluster, fake_name, # noqa E501
- fake_secret, fake_caps, fake_import_key, fake_dest, fake_container_image) # noqa E501
+ fake_secret, fake_caps, fake_import_key, fake_file_destination, fake_container_image) # noqa E501
assert result == expected_command_list
def test_update_key_non_container(self):
def test_get_key_container(self):
fake_cluster = "fake"
fake_name = "client.fake"
- fake_containerized = "docker exec -ti ceph-mon"
+ fake_container_image = "docker.io/ceph/daemon:latest-luminous"
fake_dest = "/fake/ceph"
fake_file_destination = os.path.join(
fake_dest + "/" + fake_cluster + "." + fake_name + ".keyring")
- expected_command_list = [
- ['docker', 'exec', '-ti', 'ceph-mon', 'ceph', '-n', "client.admin", '-k', "/etc/ceph/fake.client.admin.keyring", '--cluster', # noqa E501
- fake_cluster, 'auth', 'get', fake_name, '-o', fake_file_destination], # noqa E501
+ 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_containerized) # noqa E501
+ fake_cluster, fake_name, fake_file_destination, fake_container_image) # noqa E501
assert result == expected_command_list
def test_get_key_non_container(self):