def run(): """ Main execution """ parser, args = parse_arguments() logger = setup_logger(args.verbosity or logging.DEBUG) # If -c or --config flag is received data is loaded from the configuration file if args.config: data = load_config_file(args.config, logger) config_data = ConfigData(data, logger) elif args.sid and args.instance and args.password: config_data = ConfigData(vars(args), logger) else: logger.info( 'Configuration file or sid, instance and passwords parameters must be provided\n') parser.print_help() exit(1) if args.remote: config_data.remote = args.remote try: hana_instance = hana.HanaInstance( config_data.sid, config_data.instance, config_data.password, remote_host=config_data.remote) if vars(args).get('hana'): run_hana_subcommands(hana_instance, args, logger) elif vars(args).get('sr'): run_sr_subcommands(hana_instance, args, logger) else: parser.print_help() except Exception as err: logger.error(err) exit(1)
def _init( sid=None, inst=None, password=None): ''' Returns an instance of the hana instance sid HANA system id (PRD for example) inst HANA instance number (00 for example) password HANA instance password ''' if sid is None: sid = __salt__['config.option']('hana.sid', None) if inst is None: inst = __salt__['config.option']('hana.inst', None) if password is None: password = __salt__['config.option']('hana.password', None) try: return hana.HanaInstance(sid, inst, password) except TypeError as err: raise exceptions.SaltInvocationError(err)
def test_init(self): self._hana = hana.HanaInstance('prd', 1, 'pass') self.assertEqual('01', self._hana.inst) with self.assertRaises(TypeError) as err: self._hana = hana.HanaInstance(1, '00', 'pass') self.assertTrue( 'provided sid, inst and password parameters must be str type' in str(err.exception)) self.assertTrue( 'provided sid, inst and password parameters must be str type' in str(err.exception)) with self.assertRaises(TypeError) as err: self._hana = hana.HanaInstance('prd', '00', 1234) self.assertTrue( 'provided sid, inst and password parameters must be str type' in str(err.exception))
def test_run_hana_command_uppercase(self, mock_execute): proc_mock = mock.Mock() proc_mock.returncode = 0 mock_execute.return_value = proc_mock self._hana = hana.HanaInstance('PRD', 1, 'pass') result = self._hana._run_hana_command('test command') mock_execute.assert_called_once_with('test command', 'prdadm', 'pass', None) self.assertEqual(proc_mock, result)
import logging logging.getLogger(__name__) from shaptools import hana h = hana.HanaInstance('prd', '00', 'YourPassword1234') param_list_unset = [['system_replication', 'preload_column_tables'], ['memorymanager', 'global_allocation_limit']] database = 'SYSTEMDB' file_name = 'global.ini' layer = 'SYSTEM' key_name = 'backupkey' user_name = 'system' user_password = '******' h.unset_ini_parameter(param_list_unset, database, file_name, layer, reconfig=True, user_name=user_name, user_password=user_password)
def setUp(self): """ Test setUp. """ self._hana = hana.HanaInstance('prd', '00', 'pass')