def ping_containers(ctx, container_paths): api_host = ctx['api_host'] headers = dl_lib.get_request_headers(ctx) host_mac = dl_lib.get_host_mac(ctx) host_name = str(socket.gethostname()) def create_request(path): id = dl_lib.get_container_id(path) details = { 'mac': host_mac, 'hostname': host_name, 'tags': '', 'os_name': 'docker', 'os_version': '', 'container_name': '', 'proc_list': dl_lib.get_processes(id), 'container_name': '001', 'ip': '', 'interfaces': dl_lib.get_network(id), 'mode': 'SOLO', 'name': id } finger = dl_lib.hash_id(path) url = "%s/api/agents/%s/ping" % (api_host, finger,) return grequests.post(url, json=details, headers=headers) reqs = map(create_request, container_paths) grequests.map(reqs)
def ping_containers(ctx, container_paths): api_host = ctx['api_host'] headers = dl_lib.get_request_headers(ctx) host_mac = dl_lib.get_host_mac(ctx) host_name = str(socket.gethostname()) def create_request(path): id = dl_lib.get_container_id(path) details = { 'mac': host_mac, 'hostname': host_name, 'os_name': 'docker', 'os_version': '', 'processes': dl_lib.get_processes(id), 'container': '001', 'interfaces': dl_lib.get_network(id), 'mode': 'SOLO', 'name': dl_lib.get_container_name(id) } finger = dl_lib.hash_id(path) url = "%s/agents/%s/ping" % ( api_host, finger, ) return grequests.post(url, json=details, headers=headers, timeout=2) reqs = map(create_request, container_paths) grequests.map(reqs, exception_handler=exception_handler)
def ping_containers(ctx, containers): api_host = ctx['api_host'] headers = dl_lib.get_request_headers(ctx) system_uuid = dl_lib.get_system_uuid() host_name = str(socket.gethostname()) def create_request(container): finger = dl_lib.get_container_hash(container) processes = dl_lib.get_container_processes(container) interfaces = dl_lib.get_container_network(container) details = { 'name': container.name, 'mac': system_uuid, 'hostname': host_name, 'os_name': 'docker', 'os_version': '', 'processes': processes, 'container': '001', 'interfaces': interfaces, 'mode': 'SOLO' } url = "%s/agents/%s/ping" % (api_host, finger) return grequests.post(url, json=details, headers=headers, timeout=2) reqs = map(create_request, containers) grequests.map(reqs, exception_handler=exception_handler)
def destroy_agents(ctx, agent_ids): api_host = ctx['api_host'] headers = dl_lib.get_request_headers(ctx) def create_request(id): url = "%s/api/agents/%s/deregister" % (api_host, id,) return grequests.post(url, headers=headers) reqs = map(create_request, agent_ids) grequests.map(reqs)
def destroy_agents(ctx, agent_ids): api_host = ctx['api_host'] headers = dl_lib.get_request_headers(ctx) def create_request(id): url = "%s/agents/%s/deregister" % ( api_host, id, ) return grequests.post(url, headers=headers) reqs = map(create_request, agent_ids) grequests.map(reqs)
def tag_containers(ctx, containers): api_host = ctx['api_host'] headers = dl_lib.get_request_headers(ctx) def create_request(container): tags = get_tags(ctx, container) data = {'tags': ','.join(tags)} finger = dl_lib.get_container_hash(container) url = "%s/agents/%s/tags" % (api_host, finger) return grequests.put(url, json=data, headers=headers) reqs = map(create_request, containers) grequests.map(reqs)
def tag_containers(ctx, container_paths): api_host = ctx["api_host"] headers = dl_lib.get_request_headers(ctx) def create_request(path): tags = get_tags(ctx, path) data = {"tags": ",".join(tags)} finger = dl_lib.hash_id(path) url = "%s/agents/%s/tags" % (api_host, finger) return grequests.put(url, json=data, headers=headers) reqs = map(create_request, container_paths) grequests.map(reqs)