-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add released updates. #17
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,7 @@ | |
|
||
|
||
Name: yast2-sap-ha | ||
Version: 1.0.9 | ||
Version: 1.0.15 | ||
Release: 0 | ||
|
||
BuildArch: noarch | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,8 +35,13 @@ class SemanticChecks | |
attr_accessor :silent | ||
attr_reader :checks_passed | ||
|
||
IDENTIFIER_REGEXP = Regexp.new('^[_a-zA-Z][_a-zA-Z0-9]{0,30}$') | ||
#Site identifier regexp. That is what SAP allows. All ASCII charactest from 33 until 125 | ||
#expect of '*' and '/'. The identifier can be 256 character long | ||
#However, for security and technical reasons, we only allow alphanumeric characters as well as '-' and '_'. | ||
#The identifier must not be longer than 30 characters and it must be minimum 2 long. | ||
IDENTIFIER_REGEXP = Regexp.new('^[a-zA-Z0-9][a-zA-Z0-9_\-]{1,29}$') | ||
SAP_SID_REGEXP = Regexp.new('^[A-Z][A-Z0-9]{2}$') | ||
SAP_INST_NUM_REGEX = Regexp.new('^[0-9]{2}$') | ||
RESERVED_SAP_SIDS = %w(ADD ALL AND ANY ASC COM DBA END EPS FOR GID IBM INT KEY LOG MON NIX | ||
NOT OFF OMS RAW ROW SAP SET SGA SHG SID SQL SYS TMP UID USR VAR).freeze | ||
|
||
|
@@ -235,19 +240,18 @@ def integer_in_range(value, low, high, message = '', field_name = '') | |
def sap_sid(value, message = '', field_name = '') | ||
message = "A valid SAP System ID consists of three characters, starts with a letter, and "\ | ||
" must not collide with one of the reserved IDs" if message.nil? || message.empty? | ||
flag = !SAP_SID_REGEXP.match(value).nil? | ||
flag &= !RESERVED_SAP_SIDS.include?(value) | ||
flag = SAP_SID_REGEXP.match?(value) && !RESERVED_SAP_SIDS.include?(value) | ||
report_error(flag, message, field_name, value) | ||
end | ||
|
||
# Check if the provided value is a correct SAP Instance number | ||
# @param value [String] | ||
# @param message [String] custom error message | ||
# @param field_name [String] name of the related field in the form | ||
def sap_instance_number(value, message, field_name) | ||
return report_error(false, 'The SAP Instance number must be a string of exactly two digits', | ||
field_name, value) unless value.is_a?(::String) && value.length == 2 | ||
integer_in_range(value, 0, 99, message, field_name) | ||
def sap_instance_number(value, message = '', field_name = 'Instant Number') | ||
message = "The SAP Instance number must be a string of exactly two digits " if message.nil? || message.empty? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
flag = SAP_INST_NUM_REGEX.match?(value) | ||
report_error(flag, message, field_name, value) | ||
end | ||
|
||
# Check if the provided value is a non-empty string | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -213,35 +213,6 @@ def set_secute_store(system_id, key_name, env, user_name, password) | |
) | ||
end | ||
|
||
# Write the takeover hook script | ||
# @param system_id [String] HANA System ID (production) | ||
# @param hook_script [String] HANA takeover hook script | ||
def write_sr_hook(system_id, hook_script) | ||
log.info "--- called #{self.class}.#{__callee__}(#{system_id}, #{hook_script.inspect}) ---" | ||
hook_dir = "/hana/shared/#{system_id.upcase}/srHook" | ||
begin | ||
Dir.mkdir(hook_dir) unless Dir.exist?(hook_dir) | ||
rescue StandardError => e | ||
log.error "Error creating directory #{hook_dir}: #{e.message}" | ||
NodeLogger.error("Could not create directory #{hook_dir}") | ||
NodeLogger.output(e.message) | ||
return false | ||
end | ||
begin | ||
hook_path = File.join(hook_dir, 'srTakeover.py') | ||
File.open(hook_path, 'wb') do |fh| | ||
fh.write(hook_script) | ||
end | ||
rescue StandardError => e | ||
log.error "Error writing file #{hook_path}: #{e.message}" | ||
NodeLogger.error("Could not write the system replication hook script to #{hook_path}") | ||
NodeLogger.output(e.message) | ||
return false | ||
end | ||
NodeLogger.info("Wrote system replication hook script to #{hook_path}") | ||
true | ||
end | ||
|
||
# Implement adjustments to the production system, so that a non-production | ||
# HANA could be run along it | ||
# @param system_id [String] HANA System ID (production) | ||
|
@@ -258,11 +229,12 @@ def adjust_production_system(system_id, options = {}) | |
begin | ||
global_ini = CFA::GlobalIni.new(global_ini_path) | ||
global_ini.load | ||
global_ini.set_config('ha_dr_provider_srTakeover', 'provider', 'srTakeover') | ||
global_ini.set_config('ha_dr_provider_srTakeover', 'path', "/hana/shared/#{system_id.upcase}/srHook/srTakeover.py") | ||
global_ini.set_config('ha_dr_provider_srTakeover', 'execution_order', options[:execution_order]) | ||
global_ini.set_config('memorymanager', 'global_allocation_limit', options[:global_alloc_limit]) | ||
global_ini.set_config('system_replication', 'preload_column_tables', options[:preload_column_tables]) | ||
global_ini.set_config('ha_dr_provider_SAPHanaSR', 'provider', 'SAPHanaSR') | ||
global_ini.set_config('ha_dr_provider_SAPHanaSR', 'path', '/usr/share/SAPHanaSR') | ||
global_ini.set_config('ha_dr_provider_SAPHanaSR', 'execution_order', '1') | ||
global_ini.set_config('trace', 'ha_dr_saphanasr', 'info') | ||
global_ini.save | ||
rescue StandardError => e | ||
NodeLogger.error "Could not adjust global.ini for the production system:" | ||
|
@@ -290,6 +262,10 @@ def adjust_non_production_system(system_id, options = {}) | |
global_ini = CFA::GlobalIni.new(global_ini_path) | ||
global_ini.load | ||
global_ini.set_config('memorymanager', 'global_allocation_limit', options[:global_alloc_limit]) | ||
global_ini.set_config('ha_dr_provider_SAPHanaSR', 'provider', 'SAPHanaSR') | ||
global_ini.set_config('ha_dr_provider_SAPHanaSR', 'path', '/usr/share/SAPHanaSR') | ||
global_ini.set_config('ha_dr_provider_SAPHanaSR', 'execution_order', '1') | ||
global_ini.set_config('trace', 'ha_dr_saphanasr', 'info') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a lot of duplication from the previous method, maybe it would make sense to share the common part. But as this is for a maintenance update it would be more safe to do this only in the def adjust_non_production_system(system_id, options = {})
log.info "--- called #{self.class}.#{__callee__}(#{system_id}, #{options.inspect}) ---"
adjust_system(system_id, options, 'non-production')
end
def adjust_production_system(system_id, options = {})
log.info "--- called #{self.class}.#{__callee__}(#{system_id}, #{options.inspect}) ---"
adjust_system(system_id, options, 'production') do |ini|
ini.set_config('system_replication', 'preload_column_tables', options[:preload_column_tables])
end
end
def adjust_system(system_id, options = {}, system_type = "", &block)
# Change the global.ini
global_ini_path = HANA_GLOBAL_INI % system_id.upcase
unless File.exist?(global_ini_path)
NodeLogger.error "Could not adjust global.ini for the #{system_type} system:"
NodeLogger.output "File #{global_ini_path} does not exist"
return false
end
begin
global_ini = CFA::GlobalIni.new(global_ini_path)
global_ini.load
global_ini.set_config('memorymanager', 'global_allocation_limit', options[:global_alloc_limit])
global_ini.set_config('ha_dr_provider_SAPHanaSR', 'provider', 'SAPHanaSR')
global_ini.set_config('ha_dr_provider_SAPHanaSR', 'path', '/usr/share/SAPHanaSR')
global_ini.set_config('ha_dr_provider_SAPHanaSR', 'execution_order', '1')
global_ini.set_config('trace', 'ha_dr_saphanasr', 'info')
block.call(global_ini) if block_given?
global_ini.save
rescue StandardError => e
NodeLogger.error "Could not adjust global.ini for the #{system_type} system:"
NodeLogger.output e.message
return false
else
NodeLogger.info "Successfully adjusted global.ini for the #{system_type} system #{system_id}"
true
end
end You can make the Untested! Quick Hack! Please test it well! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've applied your suggestions in master. |
||
global_ini.save | ||
rescue StandardError => e | ||
NodeLogger.error "Could not adjust global.ini for the non-production system:" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -112,7 +112,8 @@ def list_watchdogs | |
log.error "Could not find the kernel modules source directory #{MODULES_PATH}" | ||
return [] | ||
end | ||
Dir.glob(MODULES_PATH + '/*.ko').map { |path| File.basename(path, '.ko') } | ||
wmods = Dir.glob(MODULES_PATH + '/*.ko*').map { |path| File.basename(path).gsub(/\.ko[\.\S+]*$/,'') } | ||
wmods | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
end | ||
|
||
# Look into the /etc/modules-load.d and list all of the modules | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -139,4 +139,37 @@ | |
expect(subject.ipv4_in_network_cidr('192.168.100.16', '192.168.100.0/28')).to eq false | ||
end | ||
end | ||
|
||
describe 'SAP naming tests' do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Some notes:
You can find more suggestions at https://www.betterspecs.org/ Proposal: context 'SAP naming tests' do
before do
subject.silent = true
end
describe "#identifier" do
it "returns true for valid IDs" do
expect(subject.identifier('1Nuremberg')).to eq true
expect(subject.identifier('1Nuremberg-A')).to eq true
expect(subject.identifier('1Nuremberg_BA')).to eq true
expect(subject.identifier('SuSE-1_2')).to eq true
end
it "returns false for invalid IDs" do
expect(subject.identifier('Nürnberg')).to eq false
expect(subject.identifier('-Nuremberg')).to eq false
expect(subject.identifier('_Nuremberg')).to eq false
expect(subject.identifier('*WalDorf-1_2/')).to eq false
end
end
describe "#sap_sid" do
it "returns true for valid IDs" do
expect(subject.sap_sid('X12')).to eq true
end
it "returns false for invalid IDs" do
expect(subject.sap_sid('123')).to eq false
expect(subject.sap_sid('NOT')).to eq false
end
end
describe "#sap_instance_number" do
it "returns true for valid numbers" do
expect(subject.sap_instance_number('05')).to eq true
expect(subject.sap_instance_number('09')).to eq true
expect(subject.sap_instance_number('10')).to eq true
expect(subject.sap_instance_number('99')).to eq true
end
it "returns false for invalid numbers" do
expect(subject.sap_instance_number('1')).to eq false
expect(subject.sap_instance_number('1A')).to eq false
expect(subject.sap_instance_number('999')).to eq false
end
end
end Again, quick hack, please test it! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks a lot! |
||
it 'reports if valid SID and site names will be allowed' do | ||
subject.silent = true | ||
expect(subject.identifier('1Nuremberg')).to eq true | ||
expect(subject.identifier('1Nuremberg-A')).to eq true | ||
expect(subject.identifier('1Nuremberg_BA')).to eq true | ||
expect(subject.identifier('SuSE-1_2')).to eq true | ||
expect(subject.sap_sid('X12')).to eq true | ||
end | ||
it 'reports if invalid SID and site names will be found' do | ||
subject.silent = true | ||
expect(subject.identifier('Nürnberg')).to eq false | ||
expect(subject.identifier('-Nuremberg')).to eq false | ||
expect(subject.identifier('_Nuremberg')).to eq false | ||
expect(subject.identifier('*WalDorf-1_2/')).to eq false | ||
expect(subject.sap_sid('123')).to eq false | ||
expect(subject.sap_sid('NOT')).to eq false | ||
end | ||
it 'reports if valid instance number will be allowed' do | ||
subject.silent = true | ||
expect(subject.sap_instance_number('05')).to eq true | ||
expect(subject.sap_instance_number('09')).to eq true | ||
expect(subject.sap_instance_number('10')).to eq true | ||
expect(subject.sap_instance_number('99')).to eq true | ||
end | ||
it 'reports if invalid instance number will be found' do | ||
subject.silent = true | ||
expect(subject.sap_instance_number('1')).to eq false | ||
expect(subject.sap_instance_number('1A')).to eq false | ||
expect(subject.sap_instance_number('999')).to eq false | ||
end | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a note: do not forget that in Ruby
^
means "start of line", not "start of the string" as usually...