Skip to content

Commit

Permalink
refactoring of the code base. Improved rendering. Overall usage of ru…
Browse files Browse the repository at this point in the history
…by and sinatra best practises. Code cleanup. Dummy backend now persistent. Improved rSpec scenarios.
  • Loading branch information
Florian Feldhaus committed May 19, 2012
1 parent fcf81ba commit c979a76
Show file tree
Hide file tree
Showing 69 changed files with 3,830 additions and 5,188 deletions.
8 changes: 8 additions & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
rOCCI was designed and is mainly developed by Florian Feldhaus (GWDG) and Piotr Kasprzak (GWDG) in Germany.

Special thanks to the following extraordinary individuals, who-out which rOCCI would not be possible:

* Hayati Bice - who wrote the initial version of an OCCI server rOCCI is based on
* Max Günther - who wrote the EC2 backend
* Andre Thevapalan - for his input regarding the JSON rendering
* the OCCI Working Group - for developing OCCI
4 changes: 3 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ source :rubygems
gem "uuidtools"
gem "json"
gem "antlr3"
#gem "hashie", :git => 'git://github.com/ffeldhaus/hashie.git', :branch => "hash_deep_merge_with_array_concatenation"
gem "hashie"
gem "nokogiri", "<=1.5.0"
gem "nokogiri", "<=1.5.0"

# sinatra and related
gem "sinatra"
Expand All @@ -28,4 +29,5 @@ group :development do
gem "simplecov"
gem "yard"
gem "yard-sinatra"
gem "rspec-http"
end
3 changes: 3 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ GEM
rspec-core (2.9.0)
rspec-expectations (2.9.0)
diff-lcs (~> 1.1.3)
rspec-http (0.10.0)
rspec (~> 2.0)
rspec-mocks (2.9.0)
simplecov (0.6.1)
multi_json (~> 1.0)
Expand Down Expand Up @@ -78,6 +80,7 @@ DEPENDENCIES
nokogiri (<= 1.5.0)
passenger
rspec
rspec-http
simplecov
sinatra
sinatra-contrib
Expand Down
13 changes: 13 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Copyright (c) 2012 GWDG

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
4 changes: 2 additions & 2 deletions config.ru
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ $: << 'lib'

require 'rubygems'
require 'sinatra'
require 'occi/occi-server.rb'
require 'occi/server'

VERSION_NUMBER=0.5

run OCCIServer.new
run OCCI::Server.new
13 changes: 13 additions & 0 deletions etc/model/extensions/console_link.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"kinds":[
{
"term":"console",
"scheme":"http://schemas.ogf.org/occi/infrastructure/compute#",
"title":"Link to the VM's console",
"related":[
"http://schemas.ogf.org/occi/core#link"
],
"location":"/consolelink/"
}
]
}
115 changes: 115 additions & 0 deletions etc/model/infrastructure/compute.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
{
"kinds":[
{
"term":"compute",
"scheme":"http://schemas.ogf.org/occi/infrastructure#",
"title":"Compute Resource",
"related":[
"http://schemas.ogf.org/occi/core#resource"
],
"attributes":{
"occi":{
"compute":{
"architecture":{
"mutable":true,
"required":false,
"type":"string",
"pattern":"x86|x64",
"default":"x86"
},
"cores":{
"mutable":true,
"required":false,
"type":"number",
"minimum":1,
"maximum":32767
},
"hostname":{
"mutable":true,
"required":false,
"type":"string",
"pattern":"(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\\-]*[a-zA-Z0-9])\\.)*"
},
"speed":{
"mutable":true,
"required":false,
"type":"number",
"minimum":0,
"maximum":32767
},
"memory":{
"mutable":true,
"required":false,
"type":"number",
"minimum":0,
"maximum":32767
},
"state":{
"mutable":false,
"required":false,
"type":"string",
"pattern":"inactive|active|suspended|failed",
"default":"inactive"
}
}
}
},
"actions":[
"http://schemas.ogf.org/occi/infrastructure/compute/action#start",
"http://schemas.ogf.org/occi/infrastructure/compute/action#stop",
"http://schemas.ogf.org/occi/infrastructure/compute/action#restart",
"http://schemas.ogf.org/occi/infrastructure/compute/action#suspend"
],
"location":"/compute/"
}
],
"actions":[
{
"term":"start",
"scheme":"http://schemas.ogf.org/occi/infrastructure/compute/action#",
"title":"Start Compute instance"
},
{
"term":"stop",
"scheme":"http://schemas.ogf.org/occi/infrastructure/compute/action#",
"title":"Stop Compute instance",
"attributes":{
"method":{
"mutable":true,
"required":false,
"type":"string",
"pattern":"graceful|acpioff|poweroff",
"default":"poweroff"
}
}
},
{
"term":"restart",
"scheme":"http://schemas.ogf.org/occi/infrastructure/compute/action#",
"title":"Restart Compute instance",
"attributes":{
"method":{
"mutable":true,
"required":false,
"type":"string",
"pattern":"graceful|warm|cold",
"default":"cold"
}
}
},
{
"term":"suspend",
"scheme":"http://schemas.ogf.org/occi/infrastructure/compute/action#",
"title":"Suspend Compute instance",
"attributes":{
"method":{
"mutable":true,
"required":false,
"type":"string",
"pattern":"hibernate|suspend",
"default":"suspend"
}
}
}
]
}
52 changes: 52 additions & 0 deletions etc/model/infrastructure/ipnetwork.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"mixins":[
{
"term":"ipnetwork",
"scheme":"http://schemas.ogf.org/occi/infrastructure/network#",
"title":"IP Network Mixin",
"attributes":{
"occi":{
"network":{
"address":{
"mutable":true,
"required":false,
"type":"string",
"pattern":"(^\\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]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0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:)))(%.+)?\\s*)"
}
},
"default":"10.0.0.1"
},
"allocation":{
"mutable":true,
"required":false,
"type":{
"string":{
"pattern":"dynamic|static"
}
},
"default":"dynamic"
},
"state":{
"mutable":false,
"required":false,
"type":{
"string":{
"pattern":"active|inactive"
}
},
"default":"inactive"
}
}
}
}
}
]
}
43 changes: 43 additions & 0 deletions etc/model/infrastructure/ipnetworkinterface.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"mixins":[
{
"term":"ipnetworkinterface",
"scheme":"http://schemas.ogf.org/occi/infrastructure/networkinterface#",
"title":"IP Networkinterface Mixin",
"attributes":{
"occi":{
"networkinterface":{
"address":{
"mutable":true,
"required":false,
"type":"string",
"pattern":"(^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$)|(^\\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:)))(%.+)?\\s*)",
"default":"10.0.0.0/8"
},
"gateway":{
"mutable":true,
"required":false,
"type":"string",
"pattern":"(^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$)|(^\\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:)))(%.+)?\\s*)",
"default":"10.0.0.1"
},
"allocation":{
"mutable":true,
"required":false,
"type":"string",
"pattern":"dynamic|static",
"default":"dynamic"
},
"state":{
"mutable":false,
"required":false,
"type":"string",
"pattern":"active|inactive",
"default":"inactive"
}
}
}
}
}
]
}
56 changes: 56 additions & 0 deletions etc/model/infrastructure/network.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"kinds":[
{
"term":"network",
"scheme":"http://schemas.ogf.org/occi/infrastructure#",
"title":"Network Resource",
"related":[
"http://schemas.ogf.org/occi/core#resource"
],
"attributes":{
"occi":{
"storage":{
"vlan":{
"mutable":true,
"required":false,
"type":"number",
"minimum":0,
"maximum":4095,
"default":0
},
"label":{
"mutable":true,
"required":false,
"type":"string",
"pattern":".*"
},
"state":{
"mutable":false,
"required":false,
"type":"string",
"pattern":"active|inactive",
"default":"inactive"
}
}
}
},
"actions":[
"http://schemas.ogf.org/occi/infrastructure/network/action#up" ,
"http://schemas.ogf.org/occi/infrastructure/network/action#down"
],
"location":"/network/"
}
],
"actions":[
{
"term":"up",
"scheme":"http://schemas.ogf.org/occi/infrastructure/network/action#",
"title":"Activate network"
},
{
"term":"down",
"scheme":"http://schemas.ogf.org/occi/infrastructure/network/action#up",
"title":"Activate network"
}
]
}
Loading

0 comments on commit c979a76

Please sign in to comment.