def get(self, search_term): result = common.getSearchHosts(search_term) if result: data = {"hosts": [host["hostname"] for host in result]} else: data = {"hosts": ""} return data
def post(self): args = parser.parse_args() hostname = args['hostname'] ansiblevars = args['vars'] groups = args['groups'] exists = [str(item) for item in common.getSearchHosts(hostname)] if exists: return 'Host already exists', 201 add_host(hostname, ansiblevars) add_host_togroups(hostname, groups) return '', 200