def confirm_patch(self, patches): to_patch = PatchOperation.get_patches_by_availability(patches, True) to_ignore = PatchOperation.get_patches_by_availability(patches, False) to_ignore += [{ 'server_name': server, 'invalid_ami': True } for server in self.ignored_servers] message = PatchOperation.describe_patches(to_patch, to_ignore) if not to_patch: self.show_result({}, message) return False else: message.append('Do you want to continue? (y/n) ') return confirm(message)
def run_patch_update(self, cluster, env): env = env.lower() if self.environment_is_protected(env): self.stop_spinner() print('Bulk patching is temporarily disabled in {0}'.format(env)) return if self.opts.get('kill', False): self.stop_spinner() PatchOperation.kill(cluster, env) else: patch_operation = PatchOperation(self.api) current_operation = PatchOperation.get_current(cluster, env) if current_operation is None: from_ami = self.opts.get('from-ami') to_ami = self.opts.get('to-ami') whitelist = self.get_user_filter('whitelist', 'match') blacklist = self.get_user_filter('blacklist', 'ignore') current_operation = self.get_patch_requirements( cluster, env, from_ami, to_ami, whitelist, blacklist) self.stop_spinner() if not current_operation: return self.patch_not_required(cluster, env) if not self.confirm_patch(current_operation): return else: print('') patch_operation.run(current_operation, cluster, env)
def get_patch_status(self, cluster, env): from_ami = self.opts.get('from-ami') to_ami = self.opts.get('to-ami') whitelist = self.get_user_filter('whitelist', 'match') blacklist = self.get_user_filter('blacklist', 'ignore') result = self.get_patch_requirements(cluster, env, from_ami, to_ami, whitelist, blacklist) if not result: self.patch_not_required(cluster, env) else: message = PatchOperation.describe_patches(result) self.show_result(result, message)
def show_current_status(self, cluster, env): patch_operation = PatchOperation.get_current(cluster, env) patch_status = PatchOperation.get_current_status(cluster, env) self.stop_spinner() self.show_result(patch_operation, patch_status)
def describe_status(self, cluster, env): if PatchOperation.is_in_progress(cluster, env): self.show_current_status(cluster, env) else: self.get_patch_status(cluster, env)