Example #1
0
def rollback(env, baseDir, connectConfig=None):
    if connectConfig is None:
        connectConfig = conn_config.retrieveConnectionConfigurationFor(
            env, baseDir)
        security.prompt_password_if_empty(connectConfig)

    current_release_number = common_dml.select_release_number(connectConfig)

    scripts = dir_struct.all_rollback_scripts_sorted_desc(baseDir)
    for script in scripts:
        patch_release_number = common_dml.determine_patch_applied_recently(
            connectConfig, script, current_release_number)
        if patch_release_number == current_release_number:
            patch_type = common_dml.determine_patch_type_if_already_applied(
                connectConfig, script)
            if patch_type in ('PATCH', 'BASELINE'):
                print "Applying rollback: " + script.getName()
                apply_rollback(connectConfig, script)
                common_dml.update_patch_metadata_entry(connectConfig, script,
                                                       current_release_number,
                                                       'ROLLBACK')
                continue
            elif patch_type == 'ROLLBACK':
                # do nothing
                continue
            else:
                # do nothing
                continue
Example #2
0
def patch(env, baseDir, connectConfig=None):
    if connectConfig is None:
        connectConfig = conn_config.retrieveConnectionConfigurationFor(
            env, baseDir)
        security.prompt_password_if_empty(connectConfig)

    release_number = common_dml.update_release_number(connectConfig)

    scripts = dir_struct.all_patch_scripts_sorted_asc(baseDir)
    for script in scripts:
        patch_type = common_dml.determine_patch_type_if_already_applied(
            connectConfig, script)
        if patch_type in ('PATCH', 'BASELINE'):
            # do nothing
            continue
        elif patch_type == 'ROLLBACK':
            print "Applying patch: " + script.getName()
            apply_patch(connectConfig, script)
            common_dml.update_patch_metadata_entry(connectConfig, script,
                                                   release_number, 'PATCH')
        else:
            print "Applying patch: " + script.getName()
            apply_patch(connectConfig, script)
            common_dml.insert_patch_metadata_entry(connectConfig, script,
                                                   release_number)
Example #3
0
def baseline(env, baseDir, connectConfig=None):
    if connectConfig is None:
        connectConfig = conn_config.retrieveConnectionConfigurationFor(env, baseDir)
        security.prompt_password_if_empty(connectConfig)

    clean_schema(connectConfig)
    create_patch_metadata(connectConfig)
    execute_baseline(baseDir, connectConfig)
    patch_metadata_assert_patches_applied(baseDir, connectConfig)
Example #4
0
    def test_secured_connection_password_correct(self):
        connect_config = retrieveConnectionConfigurationFor(
            'secured', 'tests/impl')

        with patch('impl.mysql.security.raw_input',
                   create=True,
                   return_value='qmg'):
            with patch('impl.mysql.security.check_invalid_credentials',
                       return_value=False) as mock_credentials:
                from impl.mysql.security import prompt_password_if_empty

                prompt_password_if_empty(connect_config)
                mock_credentials.assert_called_once_with(connect_config)

        prompt_password_if_empty(connect_config)

        return
Example #5
0
def patch(env, baseDir, connectConfig=None):
    if connectConfig is None:
        connectConfig = conn_config.retrieveConnectionConfigurationFor(env, baseDir)
        security.prompt_password_if_empty(connectConfig)

    release_number = common_dml.update_release_number(connectConfig)

    scripts = dir_struct.all_patch_scripts_sorted_asc(baseDir)
    for script in scripts:
        patch_type = common_dml.determine_patch_type_if_already_applied(connectConfig, script)
        if patch_type in ("PATCH", "BASELINE"):
            # do nothing
            continue
        elif patch_type == "ROLLBACK":
            print "Applying patch: " + script.getName()
            apply_patch(connectConfig, script)
            common_dml.update_patch_metadata_entry(connectConfig, script, release_number, "PATCH")
        else:
            print "Applying patch: " + script.getName()
            apply_patch(connectConfig, script)
            common_dml.insert_patch_metadata_entry(connectConfig, script, release_number)
Example #6
0
def rollback(env, baseDir, connectConfig = None):
    if connectConfig is None:
        connectConfig = conn_config.retrieveConnectionConfigurationFor(env, baseDir)
        security.prompt_password_if_empty(connectConfig)

    current_release_number = common_dml.select_release_number(connectConfig)

    scripts = dir_struct.all_rollback_scripts_sorted_desc(baseDir)
    for script in scripts:
        patch_release_number = common_dml.determine_patch_applied_recently(connectConfig, script, current_release_number)
        if patch_release_number == current_release_number:
            patch_type = common_dml.determine_patch_type_if_already_applied(connectConfig, script)
            if patch_type in ('PATCH', 'BASELINE'):
                print "Applying rollback: " + script.getName()
                apply_rollback(connectConfig, script)
                common_dml.update_patch_metadata_entry(connectConfig, script, current_release_number, 'ROLLBACK')
                continue
            elif patch_type == 'ROLLBACK':
                # do nothing
                continue
            else:
                # do nothing
                continue
Example #7
0
 def test_assert_yaml_contract_unsecured(self):
     connect_config = retrieveConnectionConfigurationFor('unsecured', 'tests/impl')
     self.assertEqual('qmg_admin', connect_config.getUser())
     self.assertEqual('qmg', connect_config.getPassword())
     self.assertEqual('localhost', connect_config.getHost())
     self.assertEqual('qmg', connect_config.getDatabase())
Example #8
0
 def test_assert_yaml_contract_secured(self):
     connect_config = retrieveConnectionConfigurationFor('secured', 'tests/impl')
     self.assertIsNone(connect_config.getPassword())
Example #9
0
def check(env, baseDir, connectConfig=None):
    if connectConfig is None:
        connectConfig = conn_config.retrieveConnectionConfigurationFor(env, baseDir)
        security.prompt_password_if_empty(connectConfig)

    return common_dml.determine_if_baseline_exists(connectConfig)