integrate-ai 9.18.0__tar.gz → 9.19.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. {integrate_ai-9.18.0 → integrate_ai-9.19.0}/PKG-INFO +1 -1
  2. {integrate_ai-9.18.0 → integrate_ai-9.19.0}/integrate_ai/onprem_node.py +103 -11
  3. {integrate_ai-9.18.0 → integrate_ai-9.19.0}/integrate_ai/utils/rest_client.py +16 -0
  4. {integrate_ai-9.18.0 → integrate_ai-9.19.0}/integrate_ai.egg-info/PKG-INFO +1 -1
  5. {integrate_ai-9.18.0 → integrate_ai-9.19.0}/setup.py +1 -1
  6. {integrate_ai-9.18.0 → integrate_ai-9.19.0}/MANIFEST.in +0 -0
  7. {integrate_ai-9.18.0 → integrate_ai-9.19.0}/backend_shim.py +0 -0
  8. {integrate_ai-9.18.0 → integrate_ai-9.19.0}/integrate_ai/__init__.py +0 -0
  9. {integrate_ai-9.18.0 → integrate_ai-9.19.0}/integrate_ai/cli.py +0 -0
  10. {integrate_ai-9.18.0 → integrate_ai-9.19.0}/integrate_ai/client.py +0 -0
  11. {integrate_ai-9.18.0 → integrate_ai-9.19.0}/integrate_ai/main.py +0 -0
  12. {integrate_ai-9.18.0 → integrate_ai-9.19.0}/integrate_ai/sdk.py +0 -0
  13. {integrate_ai-9.18.0 → integrate_ai-9.19.0}/integrate_ai/server.py +0 -0
  14. {integrate_ai-9.18.0 → integrate_ai-9.19.0}/integrate_ai/utils/__init__.py +0 -0
  15. {integrate_ai-9.18.0 → integrate_ai-9.19.0}/integrate_ai/utils/docker_client.py +0 -0
  16. {integrate_ai-9.18.0 → integrate_ai-9.19.0}/integrate_ai/utils/error_handling.py +0 -0
  17. {integrate_ai-9.18.0 → integrate_ai-9.19.0}/integrate_ai/utils/logger.py +0 -0
  18. {integrate_ai-9.18.0 → integrate_ai-9.19.0}/integrate_ai/utils/path_utils.py +0 -0
  19. {integrate_ai-9.18.0 → integrate_ai-9.19.0}/integrate_ai/utils/typer_utils.py +0 -0
  20. {integrate_ai-9.18.0 → integrate_ai-9.19.0}/integrate_ai.egg-info/SOURCES.txt +0 -0
  21. {integrate_ai-9.18.0 → integrate_ai-9.19.0}/integrate_ai.egg-info/dependency_links.txt +0 -0
  22. {integrate_ai-9.18.0 → integrate_ai-9.19.0}/integrate_ai.egg-info/entry_points.txt +0 -0
  23. {integrate_ai-9.18.0 → integrate_ai-9.19.0}/integrate_ai.egg-info/namespace_packages.txt +0 -0
  24. {integrate_ai-9.18.0 → integrate_ai-9.19.0}/integrate_ai.egg-info/requires.txt +0 -0
  25. {integrate_ai-9.18.0 → integrate_ai-9.19.0}/integrate_ai.egg-info/top_level.txt +0 -0
  26. {integrate_ai-9.18.0 → integrate_ai-9.19.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: integrate_ai
3
- Version: 9.18.0
3
+ Version: 9.19.0
4
4
  Summary: integrate.ai
5
5
  Author: integrate.ai
6
6
  License: Copyright (C) 2022 integrate.ai, Inc. All rights reserved.
@@ -11,8 +11,9 @@ from integrate_ai.utils.typer_utils import (
11
11
  TogglePromptOption,
12
12
  )
13
13
 
14
-
15
14
  app = typer.Typer(no_args_is_help=True)
15
+ # Default white list for AWS addr to query EC2 metadata
16
+ no_proxy_addr = "169.254.169.254,169.254.170.2,/var/run/docker.sock"
16
17
 
17
18
 
18
19
  @app.command()
@@ -36,15 +37,39 @@ def install(
36
37
  if os.geteuid() != 0:
37
38
  rich.print("This command must be run as root.")
38
39
  sys.exit(1)
40
+ try:
41
+ # clean up rm /tmp/ecs-anywhere-install.sh if there is any
42
+ if os.path.exists("/tmp/ecs-anywhere-install.sh"):
43
+ subprocess.run("rm /tmp/ecs-anywhere-install.sh", shell=True, check=True, text=True, capture_output=True)
44
+
45
+ # register taskrunner id
46
+ client = RestClient(token=token)
47
+ response = client.register_on_prem_taskrunner(taskrunner_name)
48
+
49
+ # install ecs anywhere
50
+ rich.print("Installing ECS Agent..")
51
+ install_ecs_agent(response)
52
+ rich.print("---ECS Agent Installed---")
53
+ taskrunners = client.get_taskrunner_info(taskrunner_name=taskrunner_name)
54
+ prov_info = taskrunners[0].get("provisioning_info")
55
+ runtime_info = prov_info.get("runtime_info")
56
+ if runtime_info:
57
+ proxy_addr = runtime_info.get("iai_forward_proxy_http_url")
58
+ rich.print(f"Proxy info from API : {proxy_addr}")
59
+ # configure proxy
60
+ if proxy_addr:
61
+ rich.print(f"Configuring proxy {proxy_addr}")
62
+ if proxy_addr:
63
+ configure_proxy(proxy_addr=proxy_addr)
64
+ rich.print("OnPrem node installed successfully!")
65
+ except Exception as e:
66
+ rich.print(
67
+ f"On-Prem register command failed with error: {e}, Logs can be found in ecsanywhere_output.txt and proxy_config.txt"
68
+ )
69
+ raise e
39
70
 
40
- # clean up rm /tmp/ecs-anywhere-install.sh if there is any
41
- if os.path.exists("/tmp/ecs-anywhere-install.sh"):
42
- subprocess.run("rm /tmp/ecs-anywhere-install.sh", shell=True, check=True, text=True, capture_output=True)
43
-
44
- # register taskrunner id
45
- client = RestClient(token=token)
46
- response = client.register_on_prem_taskrunner(taskrunner_name)
47
71
 
72
+ def install_ecs_agent(response):
48
73
  # install ecs anywhere
49
74
  cmd = 'sudo curl --proto "https" -o "/tmp/ecs-anywhere-install.sh" "https://amazon-ecs-agent.s3.amazonaws.com/ecs-anywhere-install-latest.sh"'
50
75
  cmd += " && sudo bash /tmp/ecs-anywhere-install.sh"
@@ -53,14 +78,75 @@ def install(
53
78
  cmd += f' --activation-id "{response["activation_id"]}"'
54
79
  cmd += f' --activation-code "{response["activation_code"]}"'
55
80
  cmd += "> ecsanywhere_output.txt"
56
-
57
81
  try:
58
82
  rich.print("Registering...")
59
- subprocess.run(cmd, shell=True, check=True)
83
+ subprocess.run(cmd, shell=True, check=True, timeout=1200)
60
84
  rich.print("Agent registered successfully.")
61
85
  rich.print("Output is saved in ecsanywhere_output.txt. The file contains instance id, please do not delete.")
62
86
  except subprocess.CalledProcessError as e:
63
- rich.print(f"Command failed with error: {e.stderr}, Logs can be found in ecsanywhere_output.txt.")
87
+ message = f"ECS Installation command failed with error: {e.stderr}, Logs can be found in ecsanywhere_output.txt"
88
+ rich.print(message)
89
+ raise Exception(message) from e
90
+
91
+
92
+ # Add proxy addresses to the ecs config so traffic can go through the proxy by default
93
+ # See : https://docs.aws.amazon.com/AmazonECS/latest/developerguide/http_proxy_config.html
94
+ def configure_proxy(proxy_addr: str):
95
+ rich.print("Configuring Proxy config in the host")
96
+ # proxy ssm agent
97
+ ssm_config_cmd = "sudo mkdir -p /etc/systemd/system/amazon-ssm-agent.service.d"
98
+ ssm_config_cmd += "&& { cat > /etc/systemd/system/amazon-ssm-agent.service.d/http-proxy.conf <<-EOF \n"
99
+ ssm_config_cmd += "[Service] \n"
100
+ ssm_config_cmd += f"Environment=HTTPS_PROXY={proxy_addr} \n"
101
+ ssm_config_cmd += f"Environment=NO_PROXY={no_proxy_addr} \n"
102
+ ssm_config_cmd += "EOF\n"
103
+ ssm_config_cmd += "}"
104
+
105
+ # proxy docker service
106
+ docker_svc_cmd = "sudo mkdir -p /etc/systemd/system/docker.service.d"
107
+ docker_svc_cmd += "&& { cat > /etc/systemd/system/docker.service.d/http-proxy.conf <<-EOF \n"
108
+ docker_svc_cmd += "[Service] \n"
109
+ docker_svc_cmd += f"Environment=HTTPS_PROXY={proxy_addr} \n"
110
+ docker_svc_cmd += f"Environment=NO_PROXY={no_proxy_addr} \n"
111
+ docker_svc_cmd += "EOF\n"
112
+ docker_svc_cmd += "}"
113
+
114
+ # proxy ecs-init
115
+ ecs_init_config_cmd = "sudo mkdir -p /etc/systemd/system/ecs.service.d"
116
+ ecs_init_config_cmd += "&& { cat > /etc/systemd/system/ecs.service.d/http-proxy.conf <<-EOF \n"
117
+ ecs_init_config_cmd += "[Service] \n"
118
+ ecs_init_config_cmd += f"Environment=HTTPS_PROXY={proxy_addr} \n"
119
+ ecs_init_config_cmd += f"Environment=NO_PROXY={no_proxy_addr} \n"
120
+ ecs_init_config_cmd += "EOF\n"
121
+ ecs_init_config_cmd += "}"
122
+
123
+ # proxy ecs
124
+ ecs_config_cmd = "echo patching ecs config"
125
+ ecs_config_cmd += "&& { cat >> /etc/ecs/ecs.config <<-EOF \n"
126
+ ecs_config_cmd += "[Service] \n"
127
+ ecs_config_cmd += f"HTTPS_PROXY={proxy_addr} \n"
128
+ ecs_config_cmd += f"NO_PROXY={no_proxy_addr} \n"
129
+ ecs_config_cmd += "EOF\n"
130
+ ecs_config_cmd += "}"
131
+
132
+ # restart all affected services
133
+ restart_cmd = (
134
+ "sudo systemctl daemon-reload && sudo systemctl restart docker.service && sudo systemctl restart "
135
+ "amazon-ssm-agent && sudo systemctl restart ecs"
136
+ )
137
+
138
+ # completion_command
139
+ completion_command = "echo proxy config successfully updated"
140
+
141
+ command_to_execute = f"{ssm_config_cmd} && {docker_svc_cmd} && {ecs_init_config_cmd} && {ecs_config_cmd} && {restart_cmd} && {completion_command}"
142
+ try:
143
+ # rich.print(f"Configuring Proxy command : {command_to_execute}")
144
+ subprocess.run(command_to_execute, shell=True, check=True, timeout=1200)
145
+ rich.print("Proxy configured successfully")
146
+ except subprocess.CalledProcessError as e:
147
+ message = f"Proxy configuration failed with error: {e.stderr}"
148
+ rich.print(message)
149
+ raise Exception(message) from e
64
150
 
65
151
 
66
152
  @app.command()
@@ -121,6 +207,11 @@ def uninstall(
121
207
  remove_directories_cmd = (
122
208
  "sudo rm -rf /var/lib/ecs /etc/ecs /var/lib/amazon/ssm /var/log/ecs /var/log/amazon/ssm"
123
209
  )
210
+ remove_directories_cmd += " && sudo rm -rf /etc/systemd/system/amazon-ssm-agent.service.d/http-proxy.conf"
211
+ remove_directories_cmd += " && sudo rm -rf /etc/systemd/system/docker.service.d/http-proxy.conf"
212
+ remove_directories_cmd += " && sudo rm -rf /etc/systemd/system/ecs.service.d/http-proxy.conf"
213
+ remove_directories_cmd += " && sudo rm -rf /etc/ecs/ecs.config"
214
+
124
215
  subprocess.run(remove_directories_cmd, shell=True, check=True, text=True)
125
216
  rich.print("Leftover directories removed")
126
217
 
@@ -128,6 +219,7 @@ def uninstall(
128
219
  remove_output_cmd = "sudo rm ecsanywhere_output.txt"
129
220
  subprocess.run(remove_output_cmd, shell=True, check=True, text=True)
130
221
  rich.print("ecsanywhere_output.txt removed")
222
+ rich.print("proxy entries removed")
131
223
 
132
224
  except subprocess.CalledProcessError as e:
133
225
  rich.print(f"Command failed with error: {e.stderr}")
@@ -174,6 +174,21 @@ class RestClient:
174
174
 
175
175
  return response.json()
176
176
 
177
+ def get_taskrunner_info(self, taskrunner_name) -> Dict[str, Any]:
178
+ """Get taskrunner info.
179
+ Args:
180
+ taskrunner_name (str): Name of the taskrunner
181
+ Returns:
182
+ List of Taskrunner info
183
+ Raises:
184
+ IntegrateAIException: Customized IntegrateAI exception for the HTTP Exception.
185
+ """
186
+ url = f"{self.api_url}/taskrunners"
187
+ params = {"name": taskrunner_name}
188
+ response = requests.get(url, headers=self._headers(), params=params)
189
+ check_for_IntegrateAIException(response=response)
190
+ return response.json()
191
+
177
192
  def register_on_prem_taskrunner(self, taskrunner_name) -> Dict[str, Any]:
178
193
  """Get package versions.
179
194
  Args:
@@ -182,6 +197,7 @@ class RestClient:
182
197
  A Dict of the form
183
198
  ```
184
199
  {
200
+ "proxy_info" : {"iai_forward_proxy_http_url" : "http://iai-proxy-ca-central-1-prod.integrateai.net:8888"}
185
201
  "activation_id": <activation_id>,
186
202
  "activation_code": <activation_code>,
187
203
  "region": <region>,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: integrate-ai
3
- Version: 9.18.0
3
+ Version: 9.19.0
4
4
  Summary: integrate.ai
5
5
  Author: integrate.ai
6
6
  License: Copyright (C) 2022 integrate.ai, Inc. All rights reserved.
@@ -70,5 +70,5 @@ iai client train --token <IAI_TOKEN> --session <SESSION_ID> --train_path <PATH_T
70
70
  'integrate_ai.utils',
71
71
  ),
72
72
  'python_requires': '>=3.7.5',
73
- 'version': '9.18.0',
73
+ 'version': '9.19.0',
74
74
  })
File without changes
File without changes