Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
  • 11 commits
  • 96 files changed
  • 0 commit comments
  • 2 contributors
Commits on Dec 03, 2012
@msrba msrba Update etc/configuration.yml 13df17f
@msrba msrba Update etc/configuration.yml d21ee38
Commits on Jan 08, 2013
Maik Srba merge gwdg master 7215955
Maik Srba Prepare fogio Backend
- copy dummy.rb to fogio backend
- copy dummy json to fogio json
- make fogio backend in the frontend available
31f317e
Commits on Jan 09, 2013
Maik Srba next Step fogio Backend
- initial implementation for resource handling and registration
dcdec8d
Commits on Jan 19, 2013
@ffeldhaus ffeldhaus cloud4e szenario stuff
 - fog.io implementation for compute deploy
 - link and amqp handling
 - link and mixin persistence
 - occi id match for openstack ids
1a8c99d
Commits on Jan 29, 2013
Maik Srba Initial Checkin for rOCCI-Server redesign fbc97e0
Commits on Jan 31, 2013
Maik Srba Server
 - init Frontend
 - init Backend

 Common
 - write modules for classes
471eabe
Maik Srba Server
 - init Frontend
 - init Backend

 Common
 - write modules for classes
8b1d0f4
Commits on Feb 01, 2013
Maik Srba backend
- add accounting, monitoring, security
- add methods for backend register
- add rspec
bab6ff0
Commits on Feb 22, 2013
@ffeldhaus ffeldhaus Merge pull request #56 from msrba/refactoring
Refactoring
d9bc951
Showing with 553 additions and 4,987 deletions.
  1. +3 −0  Gemfile
  2. +35 −17 Gemfile.lock
  3. +0 −17 bin/{occi_server.rb → occi-server.rb}
  4. +1 −2  config.ru
  5. +0 −7 etc/backend/default.json
  6. +0 −7 etc/backend/dummy/dummy.json
  7. +0 −38 etc/backend/dummy/templates/extra_large.json
  8. +0 −38 etc/backend/dummy/templates/large.json
  9. +0 −40 etc/backend/dummy/templates/medium.json
  10. +0 −12 etc/backend/dummy/templates/my_os.json
  11. +0 −40 etc/backend/dummy/templates/small.json
  12. 0  etc/backend/ec2/ec2.conf
  13. +0 −45 etc/backend/ec2/templates/extra_large.json
  14. +0 −45 etc/backend/ec2/templates/large.json
  15. +0 −47 etc/backend/ec2/templates/medium.json
  16. +0 −47 etc/backend/ec2/templates/small.json
  17. +0 −40 etc/backend/opennebula/model/infrastructure/compute.json
  18. +0 −13 etc/backend/opennebula/model/infrastructure/console_link.json
  19. +0 −39 etc/backend/opennebula/model/infrastructure/network.json
  20. +0 −41 etc/backend/opennebula/model/infrastructure/networkinterface.json
  21. +0 −44 etc/backend/opennebula/model/infrastructure/storage.json
  22. +0 −25 etc/backend/opennebula/model/infrastructure/storagelink.json
  23. +0 −124 etc/backend/opennebula/one_templates/compute.erb
  24. +0 −27 etc/backend/opennebula/one_templates/network.erb
  25. +0 −17 etc/backend/opennebula/one_templates/storage.erb
  26. +0 −22 etc/backend/opennebula/opennebula.json
  27. +0 −38 etc/backend/opennebula/templates/extra_large.json
  28. +0 −38 etc/backend/opennebula/templates/large.json
  29. +0 −40 etc/backend/opennebula/templates/medium.json
  30. +0 −40 etc/backend/opennebula/templates/small.json
  31. +29 −32 etc/configuration.yml
  32. +0 −267 lib/occi/backend/dummy.rb
  33. +0 −215 lib/occi/backend/ec2.rb
  34. +0 −310 lib/occi/backend/ec2/compute.rb
  35. +0 −126 lib/occi/backend/manager.rb
  36. +0 −283 lib/occi/backend/opennebula.rb
  37. +0 −149 lib/occi/backend/opennebula/auth/server_cipher_auth.rb
  38. +0 −459 lib/occi/backend/opennebula/compute.rb
  39. +0 −182 lib/occi/backend/opennebula/network.rb
  40. +0 −190 lib/occi/backend/opennebula/storage.rb
  41. +0 −49 lib/occi/config.rb
  42. +0 −27 lib/occi/exceptions.rb
  43. +0 −24 lib/occi/frontend/amqp/amqp_frontend.rb
  44. +0 −75 lib/occi/frontend/amqp/amqp_request.rb
  45. +0 −88 lib/occi/frontend/amqp/amqp_response.rb
  46. +0 −108 lib/occi/frontend/amqp_server.rb
  47. +0 −332 lib/occi/frontend/base/base_frontend.rb
  48. +0 −13 lib/occi/frontend/base/base_request.rb
  49. +0 −10 lib/occi/frontend/base/base_response.rb
  50. +0 −108 lib/occi/frontend/http/http_frontend.rb
  51. +0 −50 lib/occi/frontend/http/http_request.rb
  52. +0 −137 lib/occi/frontend/http_server.rb
  53. +0 −49 lib/occi/helper/occi_server_options.rb
  54. +0 −30 lib/occi/occi_amqp/amqp_consumer.rb
  55. +0 −39 lib/occi/occi_amqp/amqp_producer.rb
  56. +0 −49 lib/occi/occi_amqp/amqp_worker.rb
  57. +11 −16 lib/occi/server.rb
  58. +20 −0 lib/occi/server/backend.rb
  59. +9 −0 lib/occi/server/backend/accounting.rb
  60. +11 −0 lib/occi/server/backend/infrastructure.rb
  61. +13 −0 lib/occi/server/backend/infrastructure/compute.rb
  62. +15 −0 lib/occi/server/backend/infrastructure/compute/cloudstack.rb
  63. +15 −0 lib/occi/server/backend/infrastructure/compute/dummy.rb
  64. +15 −0 lib/occi/server/backend/infrastructure/compute/ec2.rb
  65. +16 −0 lib/occi/server/backend/infrastructure/compute/opennebula.rb
  66. +15 −0 lib/occi/server/backend/infrastructure/compute/openstack.rb
  67. +15 −0 lib/occi/server/backend/infrastructure/compute/vsphere.rb
  68. +13 −0 lib/occi/server/backend/infrastructure/network.rb
  69. +15 −0 lib/occi/server/backend/infrastructure/network/cloudstack.rb
  70. +15 −0 lib/occi/server/backend/infrastructure/network/dummy.rb
  71. +15 −0 lib/occi/server/backend/infrastructure/network/opennebula.rb
  72. +15 −0 lib/occi/server/backend/infrastructure/network/openstack.rb
  73. +13 −0 lib/occi/server/backend/infrastructure/storage.rb
  74. +12 −0 lib/occi/server/backend/infrastructure/storage/cloudstack.rb
  75. +13 −0 lib/occi/server/backend/infrastructure/storage/dummy.rb
  76. +12 −0 lib/occi/server/backend/infrastructure/storage/opennebula.rb
  77. +12 −0 lib/occi/server/backend/infrastructure/storage/openstack.rb
  78. +12 −0 lib/occi/server/backend/infrastructure/storage/s3.rb
  79. +9 −0 lib/occi/server/backend/monitoring.rb
  80. +9 −0 lib/occi/server/backend/platform.rb
  81. +8 −0 lib/occi/server/backend/response.rb
  82. +9 −0 lib/occi/server/backend/security.rb
  83. +10 −0 lib/occi/server/backend/security/keystone.rb
  84. +9 −0 lib/occi/server/backend/service.rb
  85. +28 −0 lib/occi/server/frontend.rb
  86. +8 −0 lib/occi/server/frontend/amqp.rb
  87. +8 −0 lib/occi/server/frontend/http.rb
  88. +8 −0 lib/occi/server/frontend/request.rb
  89. +10 −0 lib/occi/server/helper/bin/options.rb
  90. +8 −0 lib/occi/server/helper/config.rb
  91. +16 −0 lib/occi/server/helper/exceptions.rb
  92. +8 −0 lib/occi/server/usermanagement.rb
  93. +0 −382 spec/occi/frontend/amqp_server_spec.rb
  94. +11 −0 spec/occi/server.rb
  95. +24 −0 spec/occi/server/backend.rb
  96. +0 −238 spec/occi/server_spec.rb
View
3  Gemfile
@@ -15,6 +15,9 @@ gem "oca", "~>3.4.0"
# occi_amqp
gem "amqp"
+# fogio
+gem "fog"
+
# sinatra and related
gem "sinatra"
gem "sinatra-contrib"
View
52 Gemfile.lock
@@ -1,44 +1,60 @@
GEM
remote: http://rubygems.org/
specs:
- activesupport (3.2.9)
+ activesupport (3.2.11)
i18n (~> 0.6)
multi_json (~> 1.0)
amq-client (0.9.10)
amq-protocol (>= 0.9.4)
eventmachine
- amq-protocol (1.0.0)
+ amq-protocol (1.0.1)
amqp (0.9.8)
amq-client (~> 0.9.5)
amq-protocol (>= 0.9.4)
eventmachine
antlr3 (1.8.12)
- aws-sdk (1.7.1)
+ aws-sdk (1.8.0)
httparty (~> 0.7)
json (~> 1.4)
nokogiri (>= 1.4.4)
uuidtools (~> 2.1)
- backports (2.6.5)
+ backports (2.7.0)
builder (3.1.4)
daemon_controller (1.1.0)
diff-lcs (1.1.3)
erubis (2.7.0)
eventmachine (1.0.0)
+ excon (0.16.10)
fastthread (1.0.7)
+ fog (1.8.0)
+ builder
+ excon (~> 0.14)
+ formatador (~> 0.2.0)
+ mime-types
+ multi_json (~> 1.0)
+ net-scp (~> 1.0.4)
+ net-ssh (>= 2.1.3)
+ nokogiri (~> 1.5.0)
+ ruby-hmac
+ formatador (0.2.4)
hashie (1.2.0)
highline (1.6.15)
- httparty (0.9.0)
+ httparty (0.10.0)
multi_json (~> 1.0)
multi_xml
i18n (0.6.1)
- json (1.7.5)
- multi_json (1.4.0)
- multi_xml (0.5.1)
- nokogiri (1.5.5)
+ json (1.7.6)
+ mime-types (1.19)
+ multi_json (1.5.0)
+ multi_xml (0.5.2)
+ net-scp (1.0.4)
+ net-ssh (>= 1.99.1)
+ net-ssh (2.6.3)
+ nokogiri (1.5.6)
oca (3.4.1)
nokogiri
xmlparser
- occi (2.5.13)
+ occi (2.5.16)
activesupport
antlr3
hashie
@@ -48,27 +64,28 @@ GEM
json
nokogiri
uuidtools
- passenger (3.0.18)
+ passenger (3.0.19)
daemon_controller (>= 1.0.0)
fastthread (>= 1.0.1)
rack
rake (>= 0.8.1)
- rack (1.4.1)
- rack-protection (1.2.0)
+ rack (1.4.4)
+ rack-protection (1.3.2)
rack
rack-test (0.6.2)
rack (>= 1.0)
- rake (10.0.2)
+ rake (10.0.3)
rspec (2.12.0)
rspec-core (~> 2.12.0)
rspec-expectations (~> 2.12.0)
rspec-mocks (~> 2.12.0)
- rspec-core (2.12.1)
- rspec-expectations (2.12.0)
+ rspec-core (2.12.2)
+ rspec-expectations (2.12.1)
diff-lcs (~> 1.1.3)
rspec-http (0.10.0)
rspec (~> 2.0)
- rspec-mocks (2.12.0)
+ rspec-mocks (2.12.1)
+ ruby-hmac (0.4.0)
simplecov (0.7.1)
multi_json (~> 1.0)
simplecov-html (~> 0.7.1)
@@ -103,6 +120,7 @@ DEPENDENCIES
aws-sdk
builder
erubis
+ fog
hashie
json
nokogiri
View
17 bin/occi_server.rb → bin/occi-server.rb
@@ -13,24 +13,7 @@
# See the License for the specific language governing permissions and #
# limitations under the License. #
#--------------------------------------------------------------------------- #
-$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
-#TODO write an script to start rocci with amqp or http frontend
-
-require 'rubygems'
-require 'occi/helper/occi_server_options'
-require 'occi/server'
-require 'rack'
-
-options = OCCI::Helper::OcciServerOptions.new
-options._parse ARGV
-
-server = OCCI::Server.new().start(options.frontend, true)
-
-if options.frontend == 'http'
- #TODO start inside Passenger
- Rack::Server.new(:app => server, :Port => 9292, :server => 'webrick').start
-end
View
3  config.ru
@@ -4,5 +4,4 @@ require 'rubygems'
require 'sinatra'
require 'occi/server'
-run OCCI::Server.new().start('http')
-
+run OCCI::Server.new.start
View
7 etc/backend/default.json
@@ -1,7 +0,0 @@
-{
- "resources":[
- {
- "kind":"http://rocci.info/server/backend#dummy"
- }
- ]
-}
View
7 etc/backend/dummy/dummy.json
@@ -1,7 +0,0 @@
-{
- "resources":[
- {
- "kind":"http://rocci.info/server/backend#dummy"
- }
- ]
-}
View
38 etc/backend/dummy/templates/extra_large.json
@@ -1,38 +0,0 @@
-{
- "mixins":[
- {
- "term":"extra_large",
- "scheme":"/occi/infrastructure/resource_tpl#",
- "title":"Extra Large Instance",
- "related":[
- "http://schemas.ogf.org/occi/infrastructure#resource_tpl"
- ],
- "attributes":{
- "occi":{
- "compute":{
- "architecture":{
- "Mutable":false,
- "Type":"string",
- "Default":"x64"
- },
- "cores":{
- "Mutable":false,
- "Type":"number",
- "Default":4
- },
- "speed":{
- "Mutable":false,
- "Type":"number",
- "Default":2
- },
- "memory":{
- "Mutable":false,
- "Type":"number",
- "Default":15
- }
- }
- }
- }
- }
- ]
-}
View
38 etc/backend/dummy/templates/large.json
@@ -1,38 +0,0 @@
-{
- "mixins":[
- {
- "term":"large",
- "scheme":"/occi/infrastructure/resource_tpl#",
- "title":"Large Instance",
- "related":[
- "http://schemas.ogf.org/occi/infrastructure#resource_tpl"
- ],
- "attributes":{
- "occi":{
- "compute":{
- "architecture":{
- "Mutable":false,
- "Type":"string",
- "Default":"x64"
- },
- "cores":{
- "Mutable":false,
- "Type":"number",
- "Default":2
- },
- "speed":{
- "Mutable":false,
- "Type":"number",
- "Default":2
- },
- "memory":{
- "Mutable":false,
- "Type":"number",
- "Default":7.5
- }
- }
- }
- }
- }
- ]
-}
View
40 etc/backend/dummy/templates/medium.json
@@ -1,40 +0,0 @@
-{
- "mixins":[
- {
- "term":"medium",
- "scheme":"/occi/infrastructure/resource_tpl#",
- "title":"Medium Instance",
- "related":[
- "http://schemas.ogf.org/occi/infrastructure#resource_tpl"
- ],
- "attributes":{
- "occi":{
- "compute":{
- "architecture":{
- "Mutable":true,
- "Required":false,
- "Type":"string",
- "Pattern":"x86|x64",
- "Default":"x86"
- },
- "cores":{
- "Mutable":false,
- "Type":"number",
- "Default":2
- },
- "speed":{
- "Mutable":false,
- "Type":"number",
- "Default":1
- },
- "memory":{
- "Mutable":false,
- "Type":"number",
- "Default":3.75
- }
- }
- }
- }
- }
- ]
-}
View
12 etc/backend/dummy/templates/my_os.json
@@ -1,12 +0,0 @@
-{
- "mixins":[
- {
- "term":"my_os",
- "scheme":"/occi/infrastructure/os_tpl#",
- "title":"My OS Template",
- "related":[
- "http://schemas.ogf.org/occi/infrastructure#os_tpl"
- ]
- }
- ]
-}
View
40 etc/backend/dummy/templates/small.json
@@ -1,40 +0,0 @@
-{
- "mixins":[
- {
- "term":"small",
- "scheme":"/occi/infrastructure/resource_tpl#",
- "title":"Small Instance",
- "related":[
- "http://schemas.ogf.org/occi/infrastructure#resource_tpl"
- ],
- "attributes":{
- "occi":{
- "compute":{
- "architecture":{
- "Mutable":true,
- "Required":false,
- "Type":"string",
- "Pattern":"x86|x64",
- "Default":"x86"
- },
- "cores":{
- "Mutable":false,
- "Type":"number",
- "Default":1
- },
- "speed":{
- "Mutable":false,
- "Type":"number",
- "Default":1
- },
- "memory":{
- "Mutable":false,
- "Type":"number",
- "Default":1.7
- }
- }
- }
- }
- }
- ]
-}
View
0  etc/backend/ec2/ec2.conf
No changes.
View
45 etc/backend/ec2/templates/extra_large.json
@@ -1,45 +0,0 @@
-{
- "mixins":[
- {
- "term":"extra_large",
- "scheme":"http://aws.amazon.com/ec2/instance-types#",
- "title":"Extra Large Instance",
- "related":[
- "http://schemas.ogf.org/occi/infrastructure#resource_tpl"
- ],
- "attributes":{
- "occi":{
- "compute":{
- "architecture":{
- "Mutable":false,
- "Type":"string",
- "Default":"x64"
- },
- "cores":{
- "Mutable":false,
- "Type":"number",
- "Default":4
- },
- "speed":{
- "Mutable":false,
- "Type":"number",
- "Default":2
- },
- "memory":{
- "Mutable":false,
- "Type":"number",
- "Default":15
- }
- },
- "storage":{
- "size":{
- "Mutable":false,
- "Type":"number",
- "Default":1690
- }
- }
- }
- }
- }
- ]
-}
View
45 etc/backend/ec2/templates/large.json
@@ -1,45 +0,0 @@
-{
- "mixins":[
- {
- "term":"large",
- "scheme":"http://aws.amazon.com/ec2/instance-types#",
- "title":"Large Instance",
- "related":[
- "http://schemas.ogf.org/occi/infrastructure#resource_tpl"
- ],
- "attributes":{
- "occi":{
- "compute":{
- "architecture":{
- "Mutable":false,
- "Type":"string",
- "Default":"x64"
- },
- "cores":{
- "Mutable":false,
- "Type":"number",
- "Default":2
- },
- "speed":{
- "Mutable":false,
- "Type":"number",
- "Default":2
- },
- "memory":{
- "Mutable":false,
- "Type":"number",
- "Default":7.5
- }
- },
- "storage":{
- "size":{
- "Mutable":false,
- "Type":"number",
- "Default":850
- }
- }
- }
- }
- }
- ]
-}
View
47 etc/backend/ec2/templates/medium.json
@@ -1,47 +0,0 @@
-{
- "mixins":[
- {
- "term":"medium",
- "scheme":"http://aws.amazon.com/ec2/instance-types#",
- "title":"Medium Instance",
- "related":[
- "http://schemas.ogf.org/occi/infrastructure#resource_tpl"
- ],
- "attributes":{
- "occi":{
- "compute":{
- "architecture":{
- "Mutable":true,
- "Required":false,
- "Type":"string",
- "Pattern":"x86|x64",
- "Default":"x86"
- },
- "cores":{
- "Mutable":false,
- "Type":"number",
- "Default":2
- },
- "speed":{
- "Mutable":false,
- "Type":"number",
- "Default":1
- },
- "memory":{
- "Mutable":false,
- "Type":"number",
- "Default":3.75
- }
- },
- "storage":{
- "size":{
- "Mutable":false,
- "Type":"number",
- "Default":410
- }
- }
- }
- }
- }
- ]
-}
View
47 etc/backend/ec2/templates/small.json
@@ -1,47 +0,0 @@
-{
- "mixins":[
- {
- "term":"small",
- "scheme":"http://aws.amazon.com/ec2/instance-types#",
- "title":"Small Instance",
- "related":[
- "http://schemas.ogf.org/occi/infrastructure#resource_tpl"
- ],
- "attributes":{
- "occi":{
- "compute":{
- "architecture":{
- "Mutable":true,
- "Required":false,
- "Type":"string",
- "Pattern":"x86|x64",
- "Default":"x86"
- },
- "cores":{
- "Mutable":false,
- "Type":"number",
- "Default":1
- },
- "speed":{
- "Mutable":false,
- "Type":"number",
- "Default":1
- },
- "memory":{
- "Mutable":false,
- "Type":"number",
- "Default":1.7
- }
- },
- "storage":{
- "size":{
- "Mutable":false,
- "Type":"number",
- "Default":160
- }
- }
- }
- }
- }
- ]
-}
View
40 etc/backend/opennebula/model/infrastructure/compute.json
@@ -1,40 +0,0 @@
-{
- "mixins":[
- {
- "term":"compute",
- "scheme":"http://opennebula.org/occi/infrastructure#",
- "title":"OpenNebula specific Compute attributes",
- "attributes":{
- "org":{
- "opennebula":{
- "compute":{
- "cpu":{
- "Description":"Percentage of CPU divided by 100 required for the Virtual Machine, half a processor is written 0.5. This value is used by OpenNebula and the scheduler to guide the host overcommitment.",
- "Type":"number",
- "Minimum":0
- },
- "kernel":{
- "Description":"path to the OS kernel to boot the image"
- },
- "initrd":{
- "Description":"path to the initrd image"
- },
- "root":{
- "Description":"device to be mounted as root"
- },
- "kernel_cmd":{
- "Description":"arguments for the booting kernel"
- },
- "bootloader":{
- "Description":"path to the bootloader executable"
- },
- "boot":{
- "Description":"boot device type: hd,fd,cdrom ,network"
- }
- }
- }
- }
- }
- }
- ]
-}
View
13 etc/backend/opennebula/model/infrastructure/console_link.json
@@ -1,13 +0,0 @@
-{
- "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/"
- }
- ]
-}
View
39 etc/backend/opennebula/model/infrastructure/network.json
@@ -1,39 +0,0 @@
-{
- "mixins":[
- {
- "term":"network",
- "scheme":"http://opennebula.org/occi/infrastructure#",
- "title":"OpenNebula specific Network attributes",
- "attributes":{
- "org":{
- "opennebula":{
- "network":{
- "id":{
- "Description":"ID of the virtual network"
- },
- "bridge":{
- "Description":"Name of the physical bridge in the physical host where the VM should connect its network interface"
- },
- "vlan":{
- "Description":"Whether or not to isolate this virtual network using the Virtual Network Manager drivers. If omitted, the default value is NO.",
- "Pattern": "YES|NO",
- "Default":"NO"
- },
- "phydev":{
- "Description":"Name of the physical network device that will be attached to the bridge. "
- },
- "ip_start": {
- "Description":"First IP of the range.",
- "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*)"
- } ,
- "ip_end": {
- "Description":"Last IP of the range.",
- "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*)"
- }
- }
- }
- }
- }
- }
- ]
-}
View
41 etc/backend/opennebula/model/infrastructure/networkinterface.json
@@ -1,41 +0,0 @@
-{
- "mixins":[
- {
- "term":"networkinterface",
- "scheme":"http://opennebula.org/occi/infrastructure#",
- "title":"OpenNebula specific Networkinterface attributes",
- "attributes":{
- "org":{
- "opennebula":{
- "networkinterface":{
- "bridge":{
- "Description":"Name of the bridge the network device is going to be attached to."
- },
- "script":{
- "Description":"name of a shell script to be executed after creating the tun device for the VM"
- },
- "model":{
- "Description":"hardware that will emulate this network interface. With Xen this is the type attribute of the vif."
- },
- "white_ports_tcp":{
- "Description":"iptables_range: Permits access to the VM only through the specified ports in the TCP protocol. Supersedes BLACK_PORTS_TCP if defined."
- },
- "black_ports_tcp":{
- "Description":"iptables_range: Doesn't permit access to the VM through the specified ports in the TCP protocol. Superseded by WHITE_PORTS_TCP if defined."
- },
- "white_ports_udp":{
- "Description":"iptables_range: Permits access to the VM only through the specified ports in the UDP protocol. Supersedes BLACK_PORTS_UDP if defined. "
- },
- "black_ports_udp":{
- "Description":"iptables_range: Doesn't permit access to the VM through the specified ports in the UDP protocol. Superseded by WHITE_PORTS_UDP if defined."
- },
- "icmp":{
- "Description":"drop: Blocks ICMP connections to the VM. By default it's set to accept."
- }
- }
- }
- }
- }
- }
- ]
-}
View
44 etc/backend/opennebula/model/infrastructure/storage.json
@@ -1,44 +0,0 @@
-{
- "mixins":[
- {
- "term":"storage",
- "scheme":"http://opennebula.org/occi/infrastructure#",
- "title":"OpenNebula specific Storage attributes",
- "attributes":{
- "org":{
- "opennebula":{
- "storage":{
- "id":{
- "Description":"ID of the storage element"
- },
- "type":{
- "Description":"Type of the image. If omitted, the default value is the one defined in oned.conf (install default is OS).",
- "Pattern": "OS|CDROM|DATABLOCK"
- },
- "persistent":{
- "Description":"Persistence of the image. If omitted, the default value is NO.",
- "Pattern": "YES|NO",
- "Default":"NO"
- },
- "dev_prefix":{
- "Description":"Prefix for the emulated device this image will be mounted at. For instance, “hd”, “sd”. If omitted, the default value is the one defined in oned.conf (installation default is “hd”)."
- },
- "bus":{
- "Description":"Type of disk device to emulate.",
- "Pattern": "ide|IDE|scsi|SCSI|virtio"
- },
- "driver":{
- "Description":"Specific image mapping driver. VMware is unsupported",
- "Pattern": "raw|qcow2|tap2:tapdisk:aio:|tap:aio:|file:"
- },
- "fstype":{
- "Description":"Type of file system to be built. This can be any value understood by mkfs unix command."
- }
- }
- }
- }
- }
- }
- ]
-}
-
View
25 etc/backend/opennebula/model/infrastructure/storagelink.json
@@ -1,25 +0,0 @@
-{
- "mixins":[
- {
- "term":"storagelink",
- "scheme":"http://opennebula.org/occi/infrastructure#",
- "title":"OpenNebula specific Storagelink attributes",
- "attributes":{
- "org":{
- "opennebula":{
- "storagelink":{
- "bus":{
- "Description":"Type of disk device to emulate",
- "Pattern":"ide|IDE|scsi|SCSI|virtio"
- },
- "driver":{
- "Description":"Specific image mapping driver. For XEN: tap:aio:,file: For KVM: raw, qcow2",
- "Pattern":"raw|qcow2|tap2:tapdisk:aio:|tap:aio:|file:"
- }
- }
- }
- }
- }
- }
- ]
-}
View
124 etc/backend/opennebula/one_templates/compute.erb
@@ -1,124 +0,0 @@
-<%# Template options %>
-<%# Some default values are hypervisor specific %>
-<% hypervisor = :kvm #or :xen %>
-<%# Should we automaticaly enable VNC? %>
-<% vnc_enable = false #or true %>
-<%# Some restricted attributes cannot be used it the template, WIP%>
-<% restricted = ["SOURCE", "RANK"] %>
-
-<%# Mandatory settings %>
-OCCI_ID = "<%= @compute.id %>"
-<% @compute.mixins.each do |mixin| %>
-OCCI_MIXIN = "<%= mixin %>"
-<% end %>
-NAME = "<%= @compute.title ||= "rOCCI VM" %>"
-DESCRIPTION = "<%= @compute.summary ||= "VM instantiated using rOCCI-server" %>"
-<% if @compute.attributes.occi!.compute!.memory %>
-MEMORY = "<%= (@compute.attributes.occi!.compute!.memory.to_f * 1000).to_i %>"
-<% else %>
-MEMORY = "512"
-<% end %>
-VCPU = "<%= @compute.attributes.occi!.compute!.cores ||= 1 %>"
-CPU = "<%= @compute.attributes.occi!.compute!.speed ||= 0.01 %>"
-
-<%# Hypervisor specific settings %>
-RAW = [TYPE = <%= hypervisor.to_s %>]
-OS = [
- <% if @compute.attributes.occi!.compute!.architecture == "x64" %>
- ARCH = "x86_64"
- <% else %>
- ARCH = "i686"
- <% end %>
-
- <% if hypervisor == :xen %>
- ,BOOTLOADER = "pygrub"
- <% else %>
- ,BOOT = "<%= @compute.attributes.org!.opennebula!.boot ||= "hd" %>"
- <% end %>
-]
-
-<%# Links to images %>
-<% @compute.links.select {|link| link.kind == "http://schemas.ogf.org/occi/infrastructure#storagelink"}.each do |storagelink| %>
-DISK = [
- <% storage = @model.get_by_id("http://schemas.ogf.org/occi/infrastructure#storage").entities.select {|storage| storage.id == storagelink.target.split('/').last}.first %>
- LINK_OCCI_ID = "<%= storagelink.id %>",
- <% storagelink.mixins.each do |mixin| %>
- LINK_OCCI_MIXIN = "<%= mixin %>"
- <% end %>
- STORAGE_OCCI_ID = "<%= storage.id %>",
- <% if restricted.include? "SOURCE" %>
- <%# IMAGE = <%= @model.get_by_id("http://schemas.ogf.org/occi/infrastructure#storage").entities.select {|storage| storage.id == storagelink.target.split('/').last}.first.title.inspect %>
- IMAGE_ID = <%= storage.attributes.org!.opennebula!.storage!.id %>
- <% else %>
- TYPE = "OS",
- SOURCE = "<%= storagelink.target %>"
- <% end %>
-
- <% if @compute.attributes.occi!.storagelink!.deviceid %>
- ,TARGET = "<%= @compute.attributes.occi!.storagelink!.deviceid %>"
- <% end %>
- <% if @compute.attributes.org!.opennebula!.storagelink!.bus %>
- ,BUS = "<%= @compute.attributes.org!.opennebula!.storagelink!.bus %>"
- <% end %>
- <% if @compute.attributes.org!.opennebula!.storagelink!.driver %>
- ,DRIVER = "<%= @compute.attributes.org!.opennebula!.storagelink!.driver %>"
- <% end %>
-]
-<%end if @compute.links%>
-
-<%# Links to networks %>
-<% @compute.links.select {|link| link.kind == "http://schemas.ogf.org/occi/infrastructure#networkinterface"}.each do |networkinterface| %>
-NIC = [
- <% network = @model.get_by_id("http://schemas.ogf.org/occi/infrastructure#network").entities.select {|network| network.id == networkinterface.target.split('/').last}.first %>
- LINK_OCCI_ID = "<%= networkinterface.id %>",
- <% networkinterface.mixins.each do |mixin| %>
- LINK_OCCI_MIXIN = "<%= mixin %>"
- <% end %>
- NETWORK_OCCI_ID = "<%= network.id %>",
- <%# NETWORK = <%= @model.get_by_id("http://schemas.ogf.org/occi/infrastructure#network").entities.select {|network| network.id == networkinterface.target.split('/').last}.first.title.inspect %>
- NETWORK_ID = <%= network.attributes.org!.opennebula!.network!.id %>
-
- <% if @compute.attributes.occi!.networkinferface!.address %>
- ,IP = <%= @compute.attributes.occi!.networkinferface!.address %>
- <% end %>
- <% if @compute.attributes.occi!.networkinferface!.mac %>
- ,MAC = <%= @compute.attributes.occi!.networkinferface!.mac %>
- <% end %>
- <% if @compute.attributes.occi!.networkinferface!.interface %>
- ,TARGET = <%= @compute.attributes.occi!.networkinferface!.interface %>
- <% end %>
- <% if @compute.attributes.org!.opennebula!.networkinterface!.bridge %>
- ,BRIDGE = <%= @compute.attributes.org!.opennebula!.networkinterface!.bridge %>
- <% end %>
- <% if @compute.attributes.org!.opennebula!.networkinterface!.script %>
- ,SCRIPT = <%= @compute.attributes.org!.opennebula!.networkinterface!.script %>
- <% end %>
- <% if @compute.attributes.org!.opennebula!.networkinterface!.white_ports_tcp %>
- ,WHITE_PORTS_TCP = <%= @compute.attributes.org!.opennebula!.networkinterface!.white_ports_tcp %>
- <% end %>
- <% if @compute.attributes.org!.opennebula!.networkinterface!.black_ports_tcp %>
- ,BLACK_PORTS_TCP = <%= @compute.attributes.org!.opennebula!.networkinterface!.black_ports_tcp %>
- <% end %>
- <% if @compute.attributes.org!.opennebula!.networkinterface!.white_ports_udp %>
- ,WHITE_PORTS_UDP = <%= @compute.attributes.org!.opennebula!.networkinterface!.white_ports_udp %>
- <% end %>
- <% if @compute.attributes.org!.opennebula!.networkinterface!.black_ports_udp %>
- ,BLACK_PORTS_UDP = <%= @compute.attributes.org!.opennebula!.networkinterface!.black_ports_udp %>
- <% end %>
- <% if @compute.attributes.org!.opennebula!.networkinterface!.icmp %>
- ,ICMP = <%= @compute.attributes.org!.opennebula!.networkinterface!.icmp %>
- <% end %>
-]
-<%end if @compute.links%>
-
-<%# Custom settings %>
-<% if vnc_enable %>
-GRAPHICS = [
- TYPE = vnc,
- LISTEN = 0.0.0.0
-]
-<% end %>
-FEATURES = [ acpi="yes" ]
-<% unless restricted.include? "RANK" %>
-RANK = FREECPU
-<% end %>
View
27 etc/backend/opennebula/one_templates/network.erb
@@ -1,27 +0,0 @@
-ID = <%= @network.attributes.org!.opennebula!.network!.id %>
-OCCI_ID = <%= @network.id %>
-<% @network.mixins.each do |mixin| %>
-OCCI_MIXIN = "<%= mixin %>"
-<% end %>
-NAME = <%= @network.title.inspect if @network.title %>
-DESCRIPTION = <%= @network.summary.inspect if @network.summary %>
-VLAN = <%= @network.attributes.org!.opennebula!.network!.vlan %>
-VLAN_ID = <%= @network.attributes.occi!.network!.vlan %>
-PHYDEV = <%= @network.attributes.org!.opennebula!.network!.phydev %>
-BRIDGE = <%= @network.attributes.org!.opennebula!.network!.bridge %>
-
-<% if @network.attributes.occi!.network!.allocation == 'static' %>
-TYPE = FIXED
-<% for lease in IPAddr.new(network.attributes.occi!.network!.address).to_range.select {|address| address != IPAddr.new(network.attributes.occi!.network!.gateway)} do %>
-LEASES = [ <%= lease.to_s %> ]
-<% end %>
-<% else %>
-TYPE = RANGED
-NETWORK_ADDRESS = <%= @network.attributes.occi!.network!.address %>
-IP_START = <%= @network.attributes.org!.opennebula!.network!.ip_start %>
-IP_END = <%= @network.attributes.org!.opennebula!.network!.ip_end %>
-<% end %>
-
-GATEWAY = <%= @network.attributes.occi!.network!.gateway %>
-
-
View
17 etc/backend/opennebula/one_templates/storage.erb
@@ -1,17 +0,0 @@
-<%="ID =" + @storage.attributes.org!.opennebula!.storage!.id %>
-OCCI_ID = <%= @storage.id %>
-<% @storage.mixins.each do |mixin| %>
-OCCI_MIXIN = "<%= mixin %>"
-<% end %>
-<%="NAME =" + @storage.title.inspect if @storage.title %>
-<%="DESCRIPTION =" + @storage.summary if @storage.summary %>
-<% if @storage.attributes.org!.opennebula!.storage!.type %>
- TYPE = <%= @storage.attributes.org!.opennebula!.storage!.type %>
-<% elsif @storage.attributes.occi!.storage!.size %>
- TYPE = DATABLOCK
- FSTYPE = <%= @storage.attributes.org!.opennebula!.storage!.fstype ||= "ext3" %>
- SIZE = <%= @storage.attributes.occi!.storage!.size %>
-<% end %>
-<%="PERSISTENT =" + @storage.attributes.org!.opennebula!.storage!.persistent if @storage.attributes.org!.opennebula!.storage!.persistent %>
-<%="DEV_PREFIX =" + @storage.attributes.org!.opennebula!.storage!.dev_prefix if @storage.attributes.org!.opennebula!.storage!.dev_prefix %>
-<%="BUS =" + @storage.attributes.org!.opennebula!.storage!.bus if @storage.attributes.org!.opennebula!.storage!.bus %>
View
22 etc/backend/opennebula/opennebula.json
@@ -1,22 +0,0 @@
-{
- "resources":[
- {
- "kind":"http://rocci.info/server/backend#opennebula",
- "attributes":{
- "info":{
- "rocci":{
- "backend":{
- "opennebula":{
- "endpoint":"http://localhost:2633/RPC2",
- "admin":"occi",
- "password":"occi",
- "scheme":"http://my.occi.service"
- }
- }
- }
- }
-
- }
- }
- ]
-}
View
38 etc/backend/opennebula/templates/extra_large.json
@@ -1,38 +0,0 @@
-{
- "mixins":[
- {
- "term":"extra_large",
- "scheme":"/occi/infrastructure/resource_tpl#",
- "title":"Extra Large Instance",
- "related":[
- "http://schemas.ogf.org/occi/infrastructure#resource_tpl"
- ],
- "attributes":{
- "occi":{
- "compute":{
- "architecture":{
- "Mutable":false,
- "Type":"string",
- "Default":"x64"
- },
- "cores":{
- "Mutable":false,
- "Type":"number",
- "Default":4
- },
- "speed":{
- "Mutable":false,
- "Type":"number",
- "Default":2
- },
- "memory":{
- "Mutable":false,
- "Type":"number",
- "Default":15
- }
- }
- }
- }
- }
- ]
-}
View
38 etc/backend/opennebula/templates/large.json
@@ -1,38 +0,0 @@
-{
- "mixins":[
- {
- "term":"large",
- "scheme":"/occi/infrastructure/resource_tpl#",
- "title":"Large Instance",
- "related":[
- "http://schemas.ogf.org/occi/infrastructure#resource_tpl"
- ],
- "attributes":{
- "occi":{
- "compute":{
- "architecture":{
- "Mutable":false,
- "Type":"string",
- "Default":"x64"
- },
- "cores":{
- "Mutable":false,
- "Type":"number",
- "Default":2
- },
- "speed":{
- "Mutable":false,
- "Type":"number",
- "Default":2
- },
- "memory":{
- "Mutable":false,
- "Type":"number",
- "Default":7.5
- }
- }
- }
- }
- }
- ]
-}
View
40 etc/backend/opennebula/templates/medium.json
@@ -1,40 +0,0 @@
-{
- "mixins":[
- {
- "term":"medium",
- "scheme":"/occi/infrastructure/resource_tpl#",
- "title":"Medium Instance",
- "related":[
- "http://schemas.ogf.org/occi/infrastructure#resource_tpl"
- ],
- "attributes":{
- "occi":{
- "compute":{
- "architecture":{
- "Mutable":true,
- "Required":false,
- "Type":"string",
- "Pattern":"x86|x64",
- "Default":"x86"
- },
- "cores":{
- "Mutable":false,
- "Type":"number",
- "Default":2
- },
- "speed":{
- "Mutable":false,
- "Type":"number",
- "Default":1
- },
- "memory":{
- "Mutable":false,
- "Type":"number",
- "Default":3.75
- }
- }
- }
- }
- }
- ]
-}
View
40 etc/backend/opennebula/templates/small.json
@@ -1,40 +0,0 @@
-{
- "mixins":[
- {
- "term":"small",
- "scheme":"/occi/infrastructure/resource_tpl#",
- "title":"Small Instance",
- "related":[
- "http://schemas.ogf.org/occi/infrastructure#resource_tpl"
- ],
- "attributes":{
- "occi":{
- "compute":{
- "architecture":{
- "Mutable":true,
- "Required":false,
- "Type":"string",
- "Pattern":"x86|x64",
- "Default":"x86"
- },
- "cores":{
- "Mutable":false,
- "Type":"number",
- "Default":1
- },
- "speed":{
- "Mutable":false,
- "Type":"number",
- "Default":1
- },
- "memory":{
- "Mutable":false,
- "Type":"number",
- "Default":1.7
- }
- }
- }
- }
- }
- ]
-}
View
61 etc/configuration.yml
@@ -1,35 +1,32 @@
default:
- amqp:
- connection_setting:
- host: localhost
- port: 5672
- password: stack
+ occi:
+ occi_admin_user: demo
+ occi_admin_password: demo
- identifier: amqp.occi.http://localhost:9292/
+ backends:
+ infrastructure:
+ compute:
+ provider: openstack
+ endpoint: ...
+ admin_user: demo
+ admin_password: demo
+ network:
+ provider: openstack
+ endpoint: ...
+ admin_user: demo
+ admin_password: demo
+ storage:
+ provider: openstack
+ endpoint: ...
+ admin_user: demo
+ admin_password: demo
-production:
- amqp:
- connection_setting:
- host: localhost
- port: 5672
- password: stack
-
- identifier: amqp.occi.http://localhost:9292/
-
-development:
- amqp:
- connection_setting:
- host: localhost
- port: 5672
- password: stack
-
- identifier: amqp.occi.http://localhost:9292/
-
-test:
- amqp:
- connection_setting:
- host: localhost
- port: 5672
- password: stack
-
- identifier: amqp.occi.http://localhost:9292/
+ amqp:
+ active: true
+ connection_setting:
+ host: localhost
+ port: 5672
+ user: guest
+ password: guest
+ vhost:
+ identifier: amqp.occi.http://141.5.99.83/
View
267 lib/occi/backend/dummy.rb
@@ -1,267 +0,0 @@
-##############################################################################
-# Copyright 2011 Service Computing group, TU Dortmund
-#
-# 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.
-##############################################################################
-
-##############################################################################
-# Description: Dummy Backend
-# Author(s): Hayati Bice, Florian Feldhaus, Piotr Kasprzak
-##############################################################################
-
-require 'occi/backend/manager'
-require 'hashie/hash'
-require 'occi/log'
-require 'uuidtools'
-require 'pstore'
-
-module OCCI
- module Backend
-
- # ---------------------------------------------------------------------------------------------------------------------
- class Dummy < OCCI::Core::Resource
-
- attr_reader :model
-
- def self.kind_definition
- kind = OCCI::Core::Kind.new('http://rocci.info/server/backend#', 'dummy')
-
- kind.related = %w{http://rocci.org/serer#backend}
- kind.title = "rOCCI Dummy backend"
-
- kind.attributes.info!.rocci!.backend!.dummy!.scheme!.Default = 'http://my.occi.service/'
-
- kind
- end
-
- def initialize(kind='http://rocci.org/server#backend', mixins=nil, attributes=nil, links=nil)
- scheme = attributes.info!.rocci!.backend!.dummy!.scheme if attributes
- scheme ||= self.class.kind_definition.attributes.info.rocci.backend.dummy.scheme.Default
- scheme.chomp!('/')
- @model = OCCI::Model.new
- @model.register_core
- @model.register_infrastructure
- @model.register_files('etc/backend/dummy/model', scheme)
- @model.register_files('etc/backend/dummy/templates', scheme)
- OCCI::Backend::Manager.register_backend(OCCI::Backend::Dummy, OCCI::Backend::Dummy::OPERATIONS)
-
- super(kind, mixins, attributes, links)
- end
-
- def authorized?(username, password)
- true
- end
-
- # Generate a new Dummy client for the target User, if the username
- # is nil the Client is generated for the default user
- # @param [String] username
- # @return [Client]
- def client(username='default')
- username ||= 'default'
- client = PStore.new(username)
- client.transaction do
- client['resources'] ||= []
- client['links'] ||= []
- end
- client
- end
-
- def get_username(cert_subject)
- cn = cert_subject [/.*\/CN=([^\/]*).*/,1]
- user = cn.downcase.gsub ' ','' if cn
- user ||= 'default'
- end
-
- # ---------------------------------------------------------------------------------------------------------------------
- # Operation mappings
-
- OPERATIONS = {}
-
- OPERATIONS["http://schemas.ogf.org/occi/infrastructure#compute"] = {
-
- # Generic resource operations
- :deploy => :compute_deploy,
- :update_state => :resource_update_state,
- :delete => :resource_delete,
-
- # network specific resource operations
- :start => :compute_action_start,
- :stop => :compute_action_stop,
- :restart => :compute_action_restart,
- :suspend => :compute_action_suspend
- }
-
- OPERATIONS["http://schemas.ogf.org/occi/infrastructure#network"] = {
-
- # Generic resource operations
- :deploy => :network_deploy,
- :update_state => :resource_update_state,
- :delete => :resource_delete,
-
- # Network specific resource operations
- :up => :network_action_up,
- :down => :network_action_down
- }
-
- OPERATIONS["http://schemas.ogf.org/occi/infrastructure#storage"] = {
-
- # Generic resource operations
- :deploy => :storage_deploy,
- :update_state => :resource_update_state,
- :delete => :resource_delete,
-
- # Network specific resource operations
- :online => :storage_action_online,
- :offline => :storage_action_offline,
- :backup => :storage_action_backup,
- :snapshot => :storage_action_snapshot,
- :resize => :storage_action_resize
- }
-
- # ---------------------------------------------------------------------------------------------------------------------
- def register_existing_resources(client)
- client.transaction(read_only=true) do
- entities = client['resources'] + client['links']
- entities.each do |entity|
- kind = @model.get_by_id(entity.kind)
- kind.entities << entity
- OCCI::Log.debug("#### Number of entities in kind #{kind.type_identifier}: #{kind.entities.size}")
- end
- end
- end
-
- # TODO: register user defined mixins
-
- def compute_deploy(client, compute)
- compute.id = UUIDTools::UUID.timestamp_create.to_s
- compute_action_start(client, compute)
- store(client, compute)
- end
-
- def storage_deploy(client, storage)
- storage.id = UUIDTools::UUID.timestamp_create.to_s
- storage_action_online(client, storage)
- store(client, storage)
- end
-
- def network_deploy(client, network)
- network.id = UUIDTools::UUID.timestamp_create.to_s
- network_action_up(client, network)
- store(client, network)
- end
-
- # ---------------------------------------------------------------------------------------------------------------------
- def store(client, resource)
- OCCI::Log.debug("### DUMMY: Deploying resource with id #{resource.id}")
- client.transaction do
- client['resources'].delete_if { |res| res.id == resource.id }
- client['resources'] << resource
- end
- end
-
- # ---------------------------------------------------------------------------------------------------------------------
- def resource_update_state(resource)
- OCCI::Log.debug("Updating state of resource '#{resource.attributes['occi.core.title']}'...")
- end
-
- # ---------------------------------------------------------------------------------------------------------------------
- def resource_delete(client, resource)
- OCCI::Log.debug("Deleting resource '#{resource.attributes['occi.core.title']}'...")
- client.transaction do
- client['resources'].delete_if { |res| res.id == resource.id }
- end
- end
-
- # ---------------------------------------------------------------------------------------------------------------------
- # ACTIONS
- # ---------------------------------------------------------------------------------------------------------------------
-
- def compute_action_start(client, compute, parameters=nil)
- action_dummy(client, compute)
- compute.attributes.occi!.compute!.state = 'active'
- compute.actions = %w|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|
- store(client, compute)
- end
-
- def compute_action_stop(client, compute, parameters=nil)
- action_dummy(client, compute)
- compute.attributes.occi!.compute!.state = 'inactive'
- compute.actions = %w|http://schemas.ogf.org/occi/infrastructure/compute/action#start|
- store(client, compute)
- end
-
- def compute_action_restart(client, compute, parameters=nil)
- compute_action_start(client, compute)
- end
-
- def compute_action_suspend(client, compute, parameters=nil)
- action_dummy(client, compute)
- compute.attributes.occi!.compute!.state = 'suspended'
- compute.actions = %w|http://schemas.ogf.org/occi/infrastructure/compute/action#start|
- store(client, compute)
- end
-
- def storage_action_online(client, storage, parameters=nil)
- action_dummy(client, storage)
- storage.attributes.occi!.storage!.state = 'online'
- storage.actions = %w|http://schemas.ogf.org/occi/infrastructure/storage/action#offline http://schemas.ogf.org/occi/infrastructure/storage/action#restart http://schemas.ogf.org/occi/infrastructure/storage/action#suspend http://schemas.ogf.org/occi/infrastructure/storage/action#resize|
- store(client, storage)
- end
-
- def storage_action_offline(client, storage, parameters=nil)
- action_dummy(client, storage)
- storage.attributes.occi!.storage!.state = 'offline'
- storage.actions = %w|http://schemas.ogf.org/occi/infrastructure/storage/action#online http://schemas.ogf.org/occi/infrastructure/storage/action#restart http://schemas.ogf.org/occi/infrastructure/storage/action#suspend http://schemas.ogf.org/occi/infrastructure/storage/action#resize|
- store(client, storage)
- end
-
- def storage_action_backup(client, storage, parameters=nil)
- # nothing to do, state and actions stay the same after the backup which is instant for the dummy
- end
-
- def storage_action_snapshot(client, storage, parameters=nil)
- # nothing to do, state and actions stay the same after the snapshot which is instant for the dummy
- end
-
- def storage_action_resize(client, storage, parameters=nil)
- puts "Parameters: #{parameters}"
- storage.attributes.occi!.storage!.size = parameters[:size].to_i
- # state and actions stay the same after the resize which is instant for the dummy
- store(client, storage)
- end
-
- def network_action_up(client, network, parameters=nil)
- action_dummy(client, network)
- network.attributes.occi!.network!.state = 'up'
- network.actions = %w|http://schemas.ogf.org/occi/infrastructure/network/action#down|
- store(client, network)
- end
-
- def network_action_down(client, network, parameters=nil)
- action_dummy(client, network)
- network.attributes.occi!.network!.state = 'down'
- network.actions = %w|http://schemas.ogf.org/occi/infrastructure/network/action#up|
- store(client, network)
- end
-
- # ---------------------------------------------------------------------------------------------------------------------
- def action_dummy(client, resource, parameters=nil)
- OCCI::Log.debug("Calling method for resource '#{resource.attributes['occi.core.title']}' with parameters: #{parameters.inspect}")
- resource.links ||= []
- resource.links.delete_if { |link| link.rel.include? 'action' }
- end
-
- end
-
- end
-end
View
215 lib/occi/backend/ec2.rb
@@ -1,215 +0,0 @@
-##############################################################################
-# Copyright 2011 Service Computing group, TU Dortmund
-#
-# 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.
-##############################################################################
-
-##############################################################################
-# Description: EC2 Backend
-# Author(s): Max Guenther
-##############################################################################
-
-# Amazon Webservices SDK
-require 'aws-sdk'
-
-# EC2 backend
-#require 'occi/backend/ec2/Compute'
-
-# for XML parsing (gem = "xml-simple")
-require 'xmlsimple'
-
-require 'occi/log'
-
-
-module OCCI
- module Backend
- module EC2
- # ---------------------------------------------------------------------------------------------------------------------
-
- #begin
- # ### Create networks
- # # Create private network
- # attributes = OCCI::Core::Attributes.new()
- # attributes['occi.core.title'] = "ec2_private_network"
- # attributes['occi.core.summary'] = "This network contains private links to all EC2 compute instances."
- # mixins = []
- # private_network = OCCI::Infrastructure::Network.new(attributes, mixins)
- # OCCI::Rendering::HTTP::LocationRegistry.register("/network/ec2_private_network", private_network)
- # private_network.state_machine.set_state(OCCI::Infrastructure::Network::STATE_ACTIVE)
- # private_network.attributes['occi.network.state'] = "active"
- #
- # # Create public network
- # attributes = OCCI::Core::Attributes.new()
- # attributes['occi.core.title'] = "ec2_public_network"
- # attributes['occi.core.summary'] = "This network contains public links to all EC2 compute instances."
- # mixins = []
- # public_network = OCCI::Infrastructure::Network.new(attributes, mixins)
- # OCCI::Rendering::HTTP::LocationRegistry.register("/network/ec2_public_network", public_network)
- # public_network.state_machine.set_state(OCCI::Infrastructure::Network::STATE_ACTIVE)
- # public_network.attributes['occi.network.state'] = "active"
- #end
-
- public
-
- def self.get_ec2_interface
- ec2 = AWS::EC2.new
- return ec2.regions[OCCI::Server.config["avail_zone"]]
- end
-
- class EC2
-
- #include Compute
-
- # ---------------------------------------------------------------------------------------------------------------------
- # Operation mappings
-
-
- OPERATIONS = {}
-
- OPERATIONS["http://schemas.ogf.org/occi/infrastructure#compute"] = {
-
- # Generic resource operations
- :deploy => :compute_deploy,
- :update_state => :compute_update_state,
- :refresh => :compute_refresh,
- :delete => :compute_delete,
-
- # Compute specific resource operations
- :start => :compute_start,
- :stop => :compute_stop,
- :restart => :compute_restart,
- :suspend => nil
- }
-
- OPERATIONS["http://schemas.ogf.org/occi/infrastructure#network"] = {
-
- # Generic resource operations
- :deploy => nil,
- :update_state => nil,
- :refresh => nil,
- :delete => nil,
-
- # Network specific resource operations
- :up => nil,
- :down => nil
- }
-
- OPERATIONS["http://schemas.ogf.org/occi/infrastructure#storage"] = {
-
- # Generic resource operations
- :deploy => nil,
- :update_state => nil,
- :refresh => nil,
- :delete => nil,
-
- # Network specific resource operations
- :online => nil,
- :offline => nil,
- :backup => nil,
- :snapshot => nil,
- :resize => nil
- }
-
- OPERATIONS["http://schemas.ogf.org/gwdg#nfsstorage"] = {
-
- # Generic resource operations
- :deploy => nil,
- :update_state => nil,
- :refresh => nil,
- :delete => nil
- }
-
- # ---------------------------------------------------------------------------------------------------------------------
-
- def initialize(access_key_id, secret_access_key)
- # EC2 access key
- AWS.config(
- :access_key_id => access_key_id,
- :secret_access_key => secret_access_key)
- end
-
- def register_templates
- OCCI::Log.debug("Loading EC2 templates.")
-
- # import Compute Resource Templates from etc/ec2_templates/resource_templates.xml
- xml = XmlSimple.xml_in("etc/ec2_templates/resource_templates.xml")
- xml["instance"].each do |instance|
- term = instance["term"][0]
- scheme = "http://mycloud.org/templates/compute#"
- title = instance["title"][0]
- attributes = OCCI::Core::Attributes.new()
- actions = []
- entities = []
- related = [OCCI::Infrastructure::ResourceTemplate::MIXIN]
- mixin = OCCI::Core::Mixin.new(term, scheme, title, attributes, actions, related, entities)
- OCCI::Model.register(mixin)
- end
-
- ## import image templates
- # get the ec2 interface
- ec2 = OCCI::Backend::EC2.get_ec2_interface()
- # register each image
- ec2.images.each do |image|
- term = image.id
- scheme = "http://mycloud.org/templates/os#"
- title = image.name
- attributes = OCCI::Core::Attributes.new()
- actions = []
- entities = []
- related = [OCCI::Infrastructure::OSTemplate::MIXIN]
- mixin = OCCI::Core::Mixin.new(term, scheme, title, attributes, actions, related, entities)
- OCCI::Model.register(mixin)
- end
- OCCI::Log.debug("Finished loading EC2 templates.")
- end
-
-
- # ---------------------------------------------------------------------------------------------------------------------
- def register_existing_resources
-
- end
-
- # ---------------------------------------------------------------------------------------------------------------------
- def resource_deploy(resource)
- OCCI::Log.debug("Deploying resource '#{resource.attributes['occi.core.title']}'...")
- end
-
- # ---------------------------------------------------------------------------------------------------------------------
- def resource_refresh(resource)
- OCCI::Log.debug("Refreshing resource '#{resource.attributes['occi.core.title']}'...")
- end
-
- # ---------------------------------------------------------------------------------------------------------------------
- def resource_update_state(resource)
- OCCI::Log.debug("Updating state of resource '#{resource.attributes['occi.core.title']}'...")
- end
-
- # ---------------------------------------------------------------------------------------------------------------------
- def resource_delete(resource)
- OCCI::Log.debug("Deleting resource '#{resource.attributes['occi.core.title']}'...")
- end
-
- # ---------------------------------------------------------------------------------------------------------------------
- # ACTIONS
- # ---------------------------------------------------------------------------------------------------------------------
-
- # ---------------------------------------------------------------------------------------------------------------------
- def action_dummy(compute, parameters)
- OCCI::Log.debug("Calling method for resource '#{resource.attributes['occi.core.title']}' with parameters: #{parameters.inspect}")
- end
-
- end
-
- end
- end
-end
View
310 lib/occi/backend/ec2/compute.rb
@@ -1,310 +0,0 @@
-##############################################################################
-# Copyright 2011 Service Computing group, TU Dortmund
-#
-# 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.
-##############################################################################
-
-##############################################################################
-# Description: EC2 Backend
-# Author(s): Max Guenther
-##############################################################################
-
-require 'aws-sdk'
-require 'occi/log'
-
-module OCCI
- module Backend
- module EC2
-
- # ---------------------------------------------------------------------------------------------------------------------
- module Compute
-
- # ---------------------------------------------------------------------------------------------------------------------
- private
- # ---------------------------------------------------------------------------------------------------------------------
-
- def get_backend_instance(compute)
- # get the ec2 interface
- ec2 = OCCI::Backend::EC2.get_ec2_interface()
-
- # get the ec2 backend instance
- backend_instance = ec2.instances[compute.backend[:id]]
-
- raise "Problems refreshing compute instance: An instance with the EC2 ID #{compute.backend[:id]} could not be found." if backend_instance.nil?
- # return the instance
- return backend_instance
- end
-
- def has_console_link(compute)
- compute.links.each do |link|
- OCCI::Log.debug("Link: #{link}")
- if link.kind.term == "console"
- return true
- end
- end
- return false
- end
-
- def key_pair_exists(key_name)
- ec2 = OCCI::Backend::EC2.get_ec2_interface()
-
- ec2.key_pairs.each do |key|
- if key.name == "default_occi_key"
- return true
- end
- end
- return false
- end
-
- public
- # ---------------------------------------------------------------------------------------------------------------------
-
- # ---------------------------------------------------------------------------------------------------------------------
- def compute_deploy(compute)
- OCCI::Log.debug("Deploying EC2 instance.")
-
- # look what template and instance type to use
- image_id = "ami-973b06e3" # fallback os template
- instance_type = "t1.micro" # fallback resource template
- compute.mixins.each do |mixin|
- mixin.related.each do |related|
- if related.term == "os_tpl"
- image_id = mixin.term
- break # use the first template found
- elsif related.term == "resource_tpl"
- instance_type = mixin.term
- break # use the first template found
- end
- end
- end
-
- # get the ec2 interface
- ec2 = OCCI::Backend::EC2.get_ec2_interface()
-
- # create an instance
- if key_pair_exists("default_occi_key")
- backend_instance = ec2.instances.create(:image_id => image_id,
- :instance_type => instance_type,
- :key_name => "default_occi_key")
- else
- backend_instance = ec2.instances.create(:image_id => image_id,
- :instance_type => instance_type)
- end
-
- # save the id of the instance
- compute.backend[:id] = backend_instance.id
-
- # link it to the private ec2 network
- OCCI::Log.debug("Linking instance to \"/network/ec2_private_network\".")
- private_network = OCCI::Rendering::HTTP::LocationRegistry.get_object("/network/ec2_private_network")
- attributes = OCCI::Core::Attributes.new()
- attributes["occi.networkinterface.interface"] = ""
- attributes["occi.core.source"] = compute.get_location
- attributes["occi.core.target"] = "/network/ec2_private_network"
- ipnetwork = OCCI::Model.get_by_id("http://schemas.ogf.org/occi/infrastructure/networkinterface#ipnetworkinterface")
- ipnetwork.backend[:network] = "private"
- mixins = [ipnetwork]
- private_networkinterface = OCCI::Infrastructure::Networkinterface.new(attributes, mixins)
- # save the id of the compute backend instance in the network link for future identification
- private_networkinterface.backend[:backend_id] = backend_instance.id
- private_networkinterface.backend[:network] = "ec2_private_network"
- compute.links << private_networkinterface
- private_network.links << private_networkinterface
- OCCI::Rendering::HTTP::LocationRegistry.register(private_networkinterface.get_location, private_networkinterface)
-
- # link it to the public ec2 network
- OCCI::Log.debug("Linking instance to \"/network/ec2_public_network\".")
- public_network = OCCI::Rendering::HTTP::LocationRegistry.get_object("/network/ec2_public_network")
- attributes = OCCI::Core::Attributes.new()
- attributes["occi.networkinterface.interface"] = ""
- attributes["occi.core.source"] = compute.get_location
- attributes["occi.core.target"] = "/network/ec2_public_network"
- ipnetwork = OCCI::Model.get_by_id("http://schemas.ogf.org/occi/infrastructure/networkinterface#ipnetworkinterface")
- ipnetwork.backend[:network] = "ec2_public_network"
- mixins = [ipnetwork]
- public_networkinterface = OCCI::Infrastructure::Networkinterface.new(attributes, mixins)
- # save the id of the compute backend instance in the network link for future identification
- public_networkinterface.backend[:backend_id] = backend_instance.id
- public_networkinterface.backend[:network] = "public"
- compute.links << public_networkinterface
- public_network.links << public_networkinterface
- OCCI::Rendering::HTTP::LocationRegistry.register(public_networkinterface.get_location, public_networkinterface)
-
- OCCI::Log.debug("Deployed EC2 instance with EC2 ID: #{compute.backend[:id]}")
- end
-
- # ---------------------------------------------------------------------------------------------------------------------
- def compute_refresh(compute)
- OCCI::Log.debug("Refreshing EC2 compute object with backend ID: #{compute.backend[:id]}")
-
- # get the ec2 backend instance
- backend_instance = get_backend_instance(compute)
-
- # check if there are any problems with the backend instance
- if backend_instance.nil?
- OCCI::Log.debug("Problems refreshing compute instance: An instance with the EC2 ID #{compute.backend[:id]} could not be found.")
- return
- end
-
- # update the state
- compute_update_state(compute)
- OCCI::Log.debug("Refreshed EC2 compute object with backend ID: #{compute.backend[:id]}")
-
- # setting the architecture
- compute.attributes["occi.compute.architecture"] = backend_instance.architecture.to_s
- compute.attributes["ec2.compute.platform"] = backend_instance.platform
- compute.attributes["ec2.compute.kernel_id"] = backend_instance.kernel_id
-
- # update public and private ip
- compute.links.each do |link|
- if link.kind.term == "networkinterface" and link.backend[:backend_id] == backend_instance.id
- if link.backend[:network] == "public" and backend_instance.ip_address != nil
- link.mixins.each do |mixin|
- if mixin.backend[:network] == "ec2_public_network"
- link.attributes["occi.networkinterface.address"] = backend_instance.ip_address
- state = OCCI::Infrastructure::Networkinterface::STATE_ACTIVE
- link.state_machine.set_state(state)
- link.attributes['occi.networkinterface.state'] = "active"
- end
- end
- elsif link.backend[:network] == "private" and backend_instance.private_ip_address != nil
- link.mixins.each do |mixin|
- if mixin.backend[:network] == "ec2_private_network"
- link.attributes["occi.networkinterface.address"] = backend_instance.private_ip_address
- state = OCCI::Infrastructure::Networkinterface::STATE_ACTIVE
- link.state_machine.set_state(state)
- link.attributes['occi.networkinterface.state'] = "active"
- end
- end
- end
- end
- end
-
- # create the console link if not already existent and if in state active
- if compute.state_machine.current_state == OCCI::Infrastructure::Compute::STATE_ACTIVE and not has_console_link(compute) and backend_instance.key_name == "default_occi_key"
- # create a ConsoleLink
- OCCI::Log.debug("Creating a ConsoleLink to the EC2 Compute instance.")
- attributes = OCCI::Core::Attributes.new()
- attributes['occi.core.target'] = "ssh://" + backend_instance.public_dns_name
- attributes['occi.core.source'] = compute.get_location
- mixins = []
- console_link = OCCI::Infrastructure::ConsoleLink.new(attributes, mixins)
- # save the id of the compute backend instance in the network link for future identification
- console_link.backend[:backend_id] = backend_instance.id
- # link and register
- location = console_link.get_location
- compute.links << console_link
- OCCI::Rendering::HTTP::LocationRegistry.register(location, console_link)
- end
- end
-
- # ---------------------------------------------------------------------------------------------------------------------
- def compute_update_state(compute)
- # get the ec2 backend instance
- backend_instance = get_backend_instance(compute)
-
- # map the ec2 state to an OCCI state
- OCCI::Log.debug("Current EC2 VM state is: #{backend_instance.status}")
- state = case backend_instance.status
- when :running then
- OCCI::Infrastructure::Compute::STATE_ACTIVE
- when :pending, :shutting_down, :stopping, :terminated then
- OCCI::Infrastructure::Compute::STATE_INACTIVE
- when :stopped then
- OCCI::Infrastructure::Compute::STATE_SUSPENDED
- else
- OCCI::Infrastructure::Compute::STATE_INACTIVE
- end
- # set the state
- compute.state_machine.set_state(state)
- compute.attributes['occi.compute.state'] = compute.state_machine.current_state.name
- end
-
- # ---------------------------------------------------------------------------------------------------------------------
- def compute_delete(compute)
- OCCI::Log.debug("Deleting EC2 Compute instance with EC2 ID #{compute.backend[:id]}")
-
- # get the ec2 backend instance
- backend_instance = get_backend_instance(compute)
-
- if backend_instance.nil?
- OCCI::Log.debug("Problems refreshing compute instance: An instance with the EC2 ID #{compute.backend[:id]} could not be found.")
- return
- end
- # terminate the instance
- backend_instance.terminate()
-
- # delete networklinks to the private and public network and the ConsoleLink
- compute.links.each do |link|
- if link.backend[:backend_id] == backend_instance.id
- location = OCCI::Rendering::HTTP::LocationRegistry.get_location_of_object(link)
- OCCI::Log.debug("Deleting link to #{location}")
- OCCI::Rendering::HTTP::LocationRegistry.unregister(location)
- end
- end
- OCCI::Log.debug("Deleted EC2 Compute instance with EC2 ID #{compute.backend[:id]}")