diff --git a/src/server/runtime.rb b/src/server/runtime.rb index 33613ef..474b139 100644 --- a/src/server/runtime.rb +++ b/src/server/runtime.rb @@ -217,22 +217,9 @@ def to_sr } } rsr = runtime[:SERVERLESS_RUNTIME] - rsr.merge!(@body) + rsr.merge!(@body) rsr.delete('registration_time') - rsr['SERVICE_ID'] = rsr['SERVICE_ID'].to_i - - ['FAAS', 'DAAS'].each do |role| - next unless rsr[role] - - ['MEMORY', 'DISK_SIZE'].each do |param| - rsr[role][param] = rsr[role][param].to_i - end - - ['CPU'].each do |param| - rsr[role][param] = rsr[role][param].to_f - end - end runtime end @@ -275,7 +262,7 @@ def self.service_sync(client, runtime_definition, service_id, timeout = 30) client.logger.debug(service) - runtime_definition['SERVICE_ID'] = service['DOCUMENT']['ID'] + runtime_definition['SERVICE_ID'] = service['DOCUMENT']['ID'].to_i runtime_definition['FAAS'].merge!(xaas_template(client, roles[0])) runtime_definition['DAAS'].merge!(xaas_template(client, roles[1])) if roles[1] @@ -325,7 +312,7 @@ def self.to_service(client, specification) return client.service_template_instantiate(id) end - msg = "Cannot find a valid service template for the specified flavours: #{tuple}" + msg = "Cannot find a valid service template for the specified flavours: #{tuple}\n" msg << "FaaS -> #{specification['FAAS']}" msg << "DaaS -> #{specification['DAAS']}" if specification['DAAS'] @@ -348,10 +335,9 @@ def self.tuple(specification) # def self.xaas_template(client, role) xaas_template = {} - xaas_template['ENDPOINT'] = client.conf[:oneflow_server] vm_info = role['nodes'][0]['vm_info']['VM'] - vm_id = vm_info['ID'] + vm_id = vm_info['ID'].to_i response = client.vm_get(vm_id) rc = response[0] @@ -361,14 +347,16 @@ def self.xaas_template(client, role) vm = rb - # consequential parameters + # rubocop:disable Style/StringLiterals rubocop complains but is needed for ID=0 xaas_template['VM_ID'] = vm_id xaas_template['STATE'] = vm.state_str + xaas_template['ENDPOINT'] = vm["//TEMPLATE/NIC[NIC_ID=\"0\"]/IP"] - # optional specification parameters - xaas_template['CPU'] = vm['//TEMPLATE/CPU'] - xaas_template['MEMORY'] = vm['//TEMPLATE/MEMORY'] - xaas_template['DISK_SIZE'] = vm['//TEMPLATE/DISK/SIZE'] + xaas_template['CPU'] = vm['//TEMPLATE/CPU'].to_f + xaas_template['VCPU'] = vm['//TEMPLATE/VCPU'].to_i + xaas_template['MEMORY'] = vm['//TEMPLATE/MEMORY'].to_i + xaas_template['DISK_SIZE'] = vm["//TEMPLATE/DISK[DISK_ID=\"0\"]/SIZE"].to_i + # rubocop:enable Style/StringLiterals xaas_template end diff --git a/tests/tests.rb b/tests/tests.rb index 8c76197..7768d49 100644 --- a/tests/tests.rb +++ b/tests/tests.rb @@ -101,11 +101,12 @@ it 'prints every log' do logcation = '/var/log/provision-engine' + sep = '-----------------------------------' + log_files = ['engine', 'api', 'CloudClient'] - pp '-----------------------------------' - pp File.read("#{logcation}/engine.log") - pp '-----------------------------------' - pp File.read("#{logcation}/api.log") - pp '-----------------------------------' + log_files.each do |log_file| + pp File.read("#{logcation}/#{log_file}.log") + pp sep + end end end