Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 9a9cbda9 authored by SIMONIN Matthieu's avatar SIMONIN Matthieu
Browse files

api/objects: a single host is also a RolesLike

parent 899636e1
No related merge requests found
......@@ -57,7 +57,7 @@ RolesNetworks = Tuple["Roles", "Networks"]
# List[Host] (e.g. coming from Roles filtering)
# in order to make those actions more convenient to use we'd like to allow
# some flexible inputs to be used.
RolesLike = Union["Roles", List["Host"]]
RolesLike = Union["Roles", List["Host"], "Host"]
class Roles(UserDict):
......
# -*- coding: utf-8 -*-
from collections import defaultdict
from typing import Optional
from enoslib.objects import RolesLike, Roles
from enoslib.objects import Host, RolesLike, Roles
import os
from enoslib.errors import EnosFilePathError
......@@ -52,4 +52,6 @@ def _hostslike_to_roles(input: Optional[RolesLike]) -> Optional[Roles]:
return None
if isinstance(input, Roles):
return input
if isinstance(input, Host):
return Roles(all=[input])
return Roles(all=input)
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment