Skip to content
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

Fix ENDPOINT #20

Merged
merged 2 commits into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 11 additions & 23 deletions src/server/runtime.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]

Expand Down Expand Up @@ -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']

Expand All @@ -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]
Expand All @@ -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
Expand Down
11 changes: 6 additions & 5 deletions tests/tests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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