def pause(runner): # Check the STATUS column. runner.call_proc() detects and aborts on errors. status = runner.call_proc('@Pause', [], []).table(0).tuple(0).column_integer(0) if status == 0: utility.info('The cluster is paused.') else: utility.error('The cluster has failed to pause with status: %d' % status)
def _create_package(self, output_dir, name, version, description, force): # Internal method to create a runnable Python package. output_path = os.path.join(output_dir, name) utility.info('Creating compressed executable Python program: %s' % output_path) zipper = utility.Zipper(excludes=['[.]pyc$']) zipper.open(output_path, force=force, preamble='#!/usr/bin/env python\n') try: # Generate the __main__.py module for automatic execution from the zip file. standalone = str(environment.standalone) main_script = ('''\ import sys from voltcli import runner runner.main('%(name)s', '', '%(version)s', '%(description)s', package = True, standalone = %(standalone)s, *sys.argv[1:])''' % locals()) zipper.add_file_from_string(main_script, '__main__.py') # Recursively package lib/python as lib in the zip file. zipper.add_directory(environment.volt_python, '') # Add <verbspace-name>.d subdirectory if found under the command directory. command_d = os.path.join(environment.command_dir, '%s.d' % name) if os.path.isdir(command_d): dst = os.path.join('voltcli', os.path.basename(command_d)) zipper.add_directory(command_d, dst) finally: zipper.close(make_executable=True)
def _create_package(self, output_dir, name, version, description, force): # Internal method to create a runnable Python package. output_path = os.path.join(output_dir, name) utility.info('Creating compressed executable Python program: %s' % output_path) zipper = utility.Zipper(excludes = ['[.]pyc$']) zipper.open(output_path, force = force, preamble = '#!/usr/bin/env python\n') try: # Generate the __main__.py module for automatic execution from the zip file. standalone = str(environment.standalone) main_script = ('''\ import sys from voltcli import runner runner.main('%(name)s', '', '%(version)s', '%(description)s', package = True, standalone = %(standalone)s, *sys.argv[1:])''' % locals()) zipper.add_file_from_string(main_script, '__main__.py') # Recursively package lib/python as lib in the zip file. zipper.add_directory(environment.volt_python, '') # Add <verbspace-name>.d subdirectory if found under the command directory. command_d = os.path.join(environment.command_dir, '%s.d' % name) if os.path.isdir(command_d): dst = os.path.join('voltcli', os.path.basename(command_d)) zipper.add_directory(command_d, dst) finally: zipper.close(make_executable = True)
def update(runner): columns = [VOLT.FastSerializer.VOLTTYPE_STRING, VOLT.FastSerializer.VOLTTYPE_STRING] catalog = VOLT.utility.File(runner.opts.catalog).read_hex() deployment = VOLT.utility.File(runner.opts.deployment).read() params = [catalog, deployment] # call_proc() aborts with an error if the update failed. runner.call_proc('@UpdateApplicationCatalog', columns, params) utility.info('The catalog update succeeded.')
def restore(runner): columns = [ VOLT.FastSerializer.VOLTTYPE_STRING, VOLT.FastSerializer.VOLTTYPE_STRING ] params = [runner.opts.directory, runner.opts.nonce] response = runner.call_proc('@SnapshotRestore', columns, params) utility.info('The snapshot was restored.') print response.table(0).format_table(caption='Snapshot Restore Results')
def run_config_reset(runner): #=============================================================================== """ Implementation of "config reset" sub-command. """ utility.info('Clearing configuration settings...') # Perform the reset. get_config(runner, reset=True) # Display the help. get_config(runner)
def generate_all(self): self.generate_readme() self.generate_deployment() self.generate_run_script() self.generate_ddl() self.generate_sample_client() #self.generate_sample_procedure() utility.info('Project files were generated successfully.', 'Please examine the following files thoroughly before using.', self.generated)
def config(runner): bad = [] for arg in runner.opts.keyvalue: if arg.find('=') == -1: bad.append(arg) if bad: utility.abort('Bad arguments (must be KEY=VALUE format):', bad) for arg in runner.opts.keyvalue: key, value = [s.strip() for s in arg.split('=', 1)] # Default to 'volt.' if simple name is given. if key.find('.') == -1: key = 'volt.%s' % key runner.config.set_local(key, value) utility.info('Configuration: %s=%s' % (key, value))
def info(self, *msgs): """ Display INFO level messages. """ utility.info(*msgs)
def restore(runner): columns = [VOLT.FastSerializer.VOLTTYPE_STRING, VOLT.FastSerializer.VOLTTYPE_STRING] params = [runner.opts.directory, runner.opts.nonce] response = runner.call_proc("@SnapshotRestore", columns, params) utility.info("The snapshot was restored.") print response.table(0).format_table(caption="Snapshot Restore Results")