def action(self): """deletes current kubernetes namespace""" if sync_helpers.get_sync_spec() is not None: error_handling.throw_error( "This app is currently being synced, please run " "`mlt sync delete` to unsync first", "red") namespace = self.config['namespace'] jobs = files.get_deployed_jobs(job_names_only=True) if not jobs: error_handling.throw_error("This app has not been deployed yet.") else: if self.args.get('--job-name'): job_name = self.args['--job-name'] if job_name in jobs: self._undeploy_jobs(namespace, job_name) else: error_handling.throw_error( 'Job name {} not found in: {}'.format(job_name, jobs)) elif self.args.get('--all') or len(jobs) == 1: self._undeploy_jobs(namespace, jobs, all_jobs=True) else: error_handling.throw_error( "Multiple jobs are found under this application, " "please try `mlt undeploy --all` or specify a single " "job to undeploy using " "`mlt undeploy --job-name <job-name>`")
def action(self): """deletes current kubernetes namespace""" if sync_helpers.get_sync_spec() is not None: print(colored("This app is currently being synced, please run " "`mlt sync delete` to unsync first", 'red')) sys.exit(1) namespace = self.config['namespace'] jobs_list = files.get_deployed_jobs() if not jobs_list: print("This app has not been deployed yet.") sys.exit(1) else: if self.args.get('--all'): self._undeploy_all(namespace, jobs_list) elif self.args.get('--job-name'): job_name = self.args['--job-name'] if job_name in jobs_list: self._undeploy_job(namespace, job_name) else: print('Job-name {} not found in: {}' .format(job_name, jobs_list)) sys.exit(1) elif len(jobs_list) == 1: self._undeploy_job(namespace, jobs_list.pop()) else: print("Multiple jobs are found under this application, " "please try `mlt undeploy --all` or specify a single" " job to undeploy using " "`mlt undeploy --job-name <job-name>`") sys.exit(1)
def action(self): if not os.path.isfile('.push.json'): print("This app has not been deployed yet") sys.exit(1) namespace = self.config['namespace'] jobs = files.get_deployed_jobs() # display status for only `--count` amount of jobs for job in jobs[:self.args["<count>"]]: job_name = job.replace('k8s/', '') print('Job: {} -- Creation Time: {}'.format( # replacing tzinfo with UTC to print `+0000` so users know # output is in utc # TODO: better way to print this? job_name, datetime.utcfromtimestamp( int(os.path.getmtime(job))).replace( tzinfo=timezone('UTC')))) self._display_status(job_name, namespace) # TODO: something more fancy to separate different statuses? print('')
def _grab_job_name(self): """used with use_job_name flag to get the first of the list of the deployed jobs """ return get_deployed_jobs(job_names_only=True, work_dir=self.project_dir)[0]