Skip to content

Commit

Permalink
Update schema
Browse files Browse the repository at this point in the history
  • Loading branch information
dann1 committed Nov 7, 2023
1 parent 2206af4 commit 75b4b6c
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 63 deletions.
36 changes: 16 additions & 20 deletions share/swagger/schema_sr.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,28 +25,24 @@
"required": ["FLAVOUR"]
},
"DAAS": {
"oneOf": [
{
"type": "object",
"properties": {
"FLAVOUR": { "type": "string" },
"CPU": { "type": "number" },
"VCPU": { "type": "integer" },
"MEMORY": { "type": "integer" },
"DISK_SIZE": { "type": "integer" },
"VM_ID": { "type": "integer" },
"STATE": {
"type": "string",
"enum": ["PENDING", "RUNNING", "UPDATING", "ERROR"]
},
"ENDPOINT": {
"oneOf": [{ "type": "string" }, { "type": "null" }]
}
"type": "object",
"properties": {
"FLAVOUR": { "type": "string" },
"CPU": { "type": "number" },
"VCPU": { "type": "integer" },
"MEMORY": { "type": "integer" },
"DISK_SIZE": { "type": "integer" },
"VM_ID": { "type": "integer" },
"STATE": {
"type": "string",
"enum": ["PENDING", "RUNNING", "UPDATING", "ERROR"]
},
"required": ["FLAVOUR"]
"ENDPOINT": {
"oneOf": [{ "type": "string" }, { "type": "null" }]
}
},
{ "type": "null" }
]
"required": ["FLAVOUR"],
"minProperties" : 1
},
"SCHEDULING": {
"type": "object",
Expand Down
81 changes: 40 additions & 41 deletions src/server/runtime.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class ServerlessRuntime < OpenNebula::DocumentJSON
]
}.freeze

# TODO: Load json schema from FS. Distribute schema in the installer to /etc.
SCHEMA_SPECIFICATION = {
:type => 'object',
:properties => {
Expand Down Expand Up @@ -97,49 +98,43 @@ class ServerlessRuntime < OpenNebula::DocumentJSON
:required => ['FLAVOUR']
},
:DAAS => {
'oneOf' => [
{
:type => 'object',
:properties => {
:FLAVOUR => {
:type => 'object',
:properties => {
:FLAVOUR => {
:type => 'string'
},
:CPU => {
:type => 'number'
},
:VCPU => {
:type => 'integer'
},
:MEMORY => {
:type => 'integer'
},
:DISK_SIZE => {
:type => 'integer'
},
:VM_ID => {
:type => 'integer'
},
:STATE => {
:type => 'string',
:enum => FUNCTION_STATES
},
:ENDPOINT => {
'oneOf' => [
{
:type => 'string'
},
:CPU => {
:type => 'number'
},
:VCPU => {
:type => 'integer'
},
:MEMORY => {
:type => 'integer'
},
:DISK_SIZE => {
:type => 'integer'
},
:VM_ID => {
:type => 'integer'
},
:STATE => {
:type => 'string',
:enum => FUNCTION_STATES
},
:ENDPOINT => {
'oneOf' => [
{
:type => 'string'
},
{
:type => 'null'
}
]
{
:type => 'null'
}
},
:required => ['FLAVOUR']
},
{
:type => 'null'
]
}
]
},
:required => ['FLAVOUR'],
:minProperties => 1
},
:SCHEDULING => {
:type => 'object',
Expand Down Expand Up @@ -416,7 +411,7 @@ def self.to_service(client, specification)
end

['FAAS', 'DAAS'].each do |role|
next unless specification[role]
next unless specification[role] && !specification[role]['FLAVOUR'].empty?

client.logger.info("Requesting #{CVMR} for function #{role}\n#{specification[role]}")

Expand Down Expand Up @@ -453,7 +448,11 @@ def self.to_service(client, specification)

def self.tuple(specification)
tuple = specification['FAAS']['FLAVOUR']
tuple = "#{tuple}-#{specification['DAAS']['FLAVOUR']}" if specification['DAAS']

if specification['DAAS'] && !specification['DAAS']['FLAVOUR'].empty?
tuple = "#{tuple}-#{specification['DAAS']['FLAVOUR']}"
end

tuple
end

Expand Down
2 changes: 1 addition & 1 deletion tests/lib/common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def verify_sr_spec(specification, runtime)
expect(response.code.to_i).to eq(200)

['FAAS', 'DAAS'].each do |role|
next unless specification[role]
next unless specification[role] && !specification[role]['FLAVOUR'].empty?

vm = OpenNebula::VirtualMachine.new_with_id(runtime[role]['VM_ID'], @conf[:client][:oned])
raise "Error getting #{SR} VM" if OpenNebula.is_error?(vm.info)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
"FAAS": {
"FLAVOUR": "Function"
},
"DAAS": null,
"DAAS": {
"FLAVOUR": ""
},
"SCHEDULING": {},
"DEVICE_INFO": {}
}
Expand Down

0 comments on commit 75b4b6c

Please sign in to comment.