diff --git a/kolla_cli/api/exceptions.py b/kolla_cli/api/exceptions.py index 1c57e1f..d6f1999 100644 --- a/kolla_cli/api/exceptions.py +++ b/kolla_cli/api/exceptions.py @@ -69,16 +69,6 @@ class InvalidConfiguration(ClientException): pass -class InvalidHosts(ClientException): - """Invalid hosts""" - pass - - -class InvalidServices(ClientException): - """Invalid services""" - pass - - class FailedOperation(ClientException): pass diff --git a/kolla_cli/common/ansible/utils.py b/kolla_cli/common/ansible/utils.py index b98fa7d..b0495a0 100644 --- a/kolla_cli/common/ansible/utils.py +++ b/kolla_cli/common/ansible/utils.py @@ -12,10 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. -from kolla_cli.api.exceptions import InvalidHosts -from kolla_cli.api.exceptions import InvalidServices from kolla_cli.common.inventory import Inventory -import kolla_cli.i18n as u def check_kolla_args(hostnames=[], servicenames=[]): @@ -25,18 +22,7 @@ def check_kolla_args(hostnames=[], servicenames=[]): inventory = Inventory.load() if hostnames: - all_hosts = inventory.get_hostnames() - invalid_hosts = list(set(hostnames) - set(all_hosts)) - if invalid_hosts: - raise InvalidHosts( - u._('Hosts {hosts} are not valid.').format( - hosts=invalid_hosts)) + inventory.validate_hostnames(hostnames) if servicenames: - all_services = [service.name - for service in inventory.get_services()] - invalid_services = list(set(servicenames) - set(all_services)) - if invalid_services: - raise InvalidServices( - u._('Services {services} are not valid.').format( - services=invalid_services)) + inventory.validate_servicenames(servicenames)