class Ceph(object):
- daemons = ['mon', 'mgr', 'mds', 'osd', 'rgw', 'rbd-mirror']
+ daemons = ('mon', 'mgr', 'mds', 'osd', 'rgw', 'rbd-mirror')
class Monitoring(object):
# type: () -> None
(daemon_type, daemon_id) = args.name.split('.', 1)
- supported_daemons = Ceph.daemons.copy()
+ supported_daemons = list(Ceph.daemons)
supported_daemons.extend(Monitoring.components)
if daemon_type not in supported_daemons:
class CustomValidation(argparse.Action):
def _check_name(self, values):
-
try:
(daemon_type, daemon_id) = values.split('.', 1)
except ValueError:
raise argparse.ArgumentError(self,
"must be of the format <type>.<id>. For example, osd.1 or prometheus.myhost.com")
- daemons = Ceph.daemons.copy()
+ daemons = list(Ceph.daemons)
daemons.extend(Monitoring.components.keys())
if daemon_type not in daemons:
+import argparse
import mock
import os
import sys
import unittest
+import pytest
+
if sys.version_info >= (3, 3):
from importlib.machinery import SourceFileLoader
cd = SourceFileLoader('cephadm', 'cephadm').load_module()
p = cd._get_parser()
args = p.parse_args(['version'])
assert args.image == 'bar'
+
+ def test_CustomValidation(self):
+ p = cd._get_parser()
+ assert p.parse_args(['deploy', '--name', 'mon.a', '--fsid', 'fsid'])
+
+ with pytest.raises(SystemExit):
+ p.parse_args(['deploy', '--name', 'wrong', '--fsid', 'fsid'])