return mgr.mon_command(command)
def create_mds(mgr, fs_name, placement):
- spec = ServiceSpec(service_type='mds',
- service_id=fs_name,
- placement=PlacementSpec.from_string(placement))
+ try:
+ spec = ServiceSpec(service_type='mds',
+ service_id=fs_name,
+ placement=PlacementSpec.from_string(placement))
+ except Exception as e:
+ return -errno.EINVAL, "", str(e)
try:
completion = mgr.apply([spec], no_overwrite=True)
orchestrator.raise_if_exception(completion)
def assert_valid_host(name: str) -> None:
p = re.compile('^[a-zA-Z0-9-]+$')
- try:
- assert len(name) <= 250, 'name is too long (max 250 chars)'
- for part in name.split('.'):
- assert len(part) > 0, '.-delimited name component must not be empty'
- assert len(part) <= 63, '.-delimited name component must not be more than 63 chars'
- assert p.match(part), 'name component must include only a-z, 0-9, and -'
- except AssertionError as e:
- raise SpecValidationError(str(e) + f'. Got "{name}"')
+ if len(name) > 250:
+ raise AssertionError(f'{name}: name is too long (max 250 chars)') from None
+ for part in name.split('.'):
+ if len(part) == 0:
+ raise AssertionError('.-delimited name component must not be empty '
+ f'but got {name}') from None
+ if len(part) > 63:
+ raise AssertionError('.-delimited name component must not be more '
+ f'than 63 chars but got {name}') from None
+ if not p.match(part):
+ raise AssertionError('name component must include only a-z, 0-9, '
+ f'and - but got {name}') from None
def assert_valid_oob(oob: Dict[str, str]) -> None: