(self, params)
| 169 | raise RuntimeError('You must run this command as sudo.') |
| 170 | |
| 171 | def install(self, params): |
| 172 | if 'installer' in params: |
| 173 | self.INSTALLER = params.installer |
| 174 | |
| 175 | self._update_system(params) |
| 176 | self._stop_agent(params) |
| 177 | |
| 178 | response = self.s3.get_object(Bucket=params.bucket, Key=params.key) |
| 179 | with open(self.INSTALLER, 'wb') as f: |
| 180 | f.write(response['Body'].read()) |
| 181 | |
| 182 | subprocess.check_call(['chmod', '+x', f'./{self.INSTALLER}']) |
| 183 | |
| 184 | credentials = self.session.get_credentials() |
| 185 | environment = os.environ.copy() |
| 186 | environment['AWS_REGION'] = params.region |
| 187 | environment['AWS_ACCESS_KEY_ID'] = credentials.access_key |
| 188 | environment['AWS_SECRET_ACCESS_KEY'] = credentials.secret_key |
| 189 | if credentials.token is not None: |
| 190 | environment['AWS_SESSION_TOKEN'] = credentials.token |
| 191 | subprocess.check_call([f'./{self.INSTALLER}', 'auto'], env=environment) |
| 192 | |
| 193 | def uninstall(self, params): |
| 194 | process = self._stop_agent(params) |
no test coverage detected