bbrowning-deltacloud-core 0.0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (113) hide show
  1. data/COPYING +502 -0
  2. data/Rakefile +85 -0
  3. data/bin/deltacloudd +88 -0
  4. data/config.ru +5 -0
  5. data/deltacloud.rb +14 -0
  6. data/lib/deltacloud/base_driver.rb +19 -0
  7. data/lib/deltacloud/base_driver/base_driver.rb +189 -0
  8. data/lib/deltacloud/base_driver/features.rb +159 -0
  9. data/lib/deltacloud/base_driver/mock_driver.rb +37 -0
  10. data/lib/deltacloud/drivers/ec2/ec2_driver.rb +340 -0
  11. data/lib/deltacloud/drivers/ec2/ec2_mock_driver.rb +170 -0
  12. data/lib/deltacloud/drivers/gogrid/gogrid_client.rb +45 -0
  13. data/lib/deltacloud/drivers/gogrid/gogrid_driver.rb +322 -0
  14. data/lib/deltacloud/drivers/mock/mock_driver.rb +275 -0
  15. data/lib/deltacloud/drivers/opennebula/cloud_client.rb +116 -0
  16. data/lib/deltacloud/drivers/opennebula/occi_client.rb +204 -0
  17. data/lib/deltacloud/drivers/opennebula/opennebula_driver.rb +241 -0
  18. data/lib/deltacloud/drivers/rackspace/rackspace_client.rb +129 -0
  19. data/lib/deltacloud/drivers/rackspace/rackspace_driver.rb +150 -0
  20. data/lib/deltacloud/drivers/rhevm/rhevm_driver.rb +254 -0
  21. data/lib/deltacloud/drivers/rimuhosting/rimuhosting_client.rb +84 -0
  22. data/lib/deltacloud/drivers/rimuhosting/rimuhosting_driver.rb +144 -0
  23. data/lib/deltacloud/drivers/terremark/terremark_driver.rb +261 -0
  24. data/lib/deltacloud/hardware_profile.rb +153 -0
  25. data/lib/deltacloud/helpers.rb +5 -0
  26. data/lib/deltacloud/helpers/application_helper.rb +56 -0
  27. data/lib/deltacloud/helpers/conversion_helper.rb +38 -0
  28. data/lib/deltacloud/helpers/hardware_profiles_helper.rb +35 -0
  29. data/lib/deltacloud/method_serializer.rb +84 -0
  30. data/lib/deltacloud/models/base_model.rb +58 -0
  31. data/lib/deltacloud/models/image.rb +26 -0
  32. data/lib/deltacloud/models/instance.rb +37 -0
  33. data/lib/deltacloud/models/instance_profile.rb +47 -0
  34. data/lib/deltacloud/models/realm.rb +25 -0
  35. data/lib/deltacloud/models/storage_snapshot.rb +26 -0
  36. data/lib/deltacloud/models/storage_volume.rb +27 -0
  37. data/lib/deltacloud/state_machine.rb +84 -0
  38. data/lib/deltacloud/validation.rb +70 -0
  39. data/lib/drivers.rb +38 -0
  40. data/lib/sinatra/accept_media_types.rb +128 -0
  41. data/lib/sinatra/lazy_auth.rb +56 -0
  42. data/lib/sinatra/rabbit.rb +272 -0
  43. data/lib/sinatra/respond_to.rb +269 -0
  44. data/lib/sinatra/static_assets.rb +83 -0
  45. data/lib/sinatra/url_for.rb +51 -0
  46. data/public/favicon.ico +0 -0
  47. data/public/images/grid.png +0 -0
  48. data/public/images/logo-wide.png +0 -0
  49. data/public/images/rails.png +0 -0
  50. data/public/images/topbar-bg.png +0 -0
  51. data/public/javascripts/application.js +32 -0
  52. data/public/javascripts/jquery-1.4.2.min.js +154 -0
  53. data/public/stylesheets/compiled/application.css +613 -0
  54. data/public/stylesheets/compiled/ie.css +31 -0
  55. data/public/stylesheets/compiled/print.css +27 -0
  56. data/public/stylesheets/compiled/screen.css +456 -0
  57. data/server.rb +342 -0
  58. data/support/fedora/deltacloudd +68 -0
  59. data/support/fedora/rubygem-deltacloud-core.spec +91 -0
  60. data/tests/deltacloud_test.rb +60 -0
  61. data/tests/images_test.rb +94 -0
  62. data/tests/instances_test.rb +136 -0
  63. data/tests/realms_test.rb +56 -0
  64. data/tests/storage_snapshots_test.rb +48 -0
  65. data/tests/storage_volumes_test.rb +48 -0
  66. data/torquebox-ec2-config.ru +8 -0
  67. data/views/accounts/index.html.haml +11 -0
  68. data/views/accounts/show.html.haml +30 -0
  69. data/views/api/show.html.haml +15 -0
  70. data/views/api/show.xml.haml +5 -0
  71. data/views/docs/collection.html.haml +37 -0
  72. data/views/docs/collection.xml.haml +14 -0
  73. data/views/docs/index.html.haml +15 -0
  74. data/views/docs/index.xml.haml +5 -0
  75. data/views/docs/operation.html.haml +31 -0
  76. data/views/docs/operation.xml.haml +10 -0
  77. data/views/errors/auth_exception.html.haml +8 -0
  78. data/views/errors/auth_exception.xml.haml +2 -0
  79. data/views/errors/backend_error.html.haml +17 -0
  80. data/views/errors/backend_error.xml.haml +8 -0
  81. data/views/errors/validation_failure.html.haml +11 -0
  82. data/views/errors/validation_failure.xml.haml +7 -0
  83. data/views/hardware_profiles/index.html.haml +25 -0
  84. data/views/hardware_profiles/index.xml.haml +4 -0
  85. data/views/hardware_profiles/show.html.haml +19 -0
  86. data/views/hardware_profiles/show.xml.haml +17 -0
  87. data/views/images/index.html.haml +30 -0
  88. data/views/images/index.xml.haml +7 -0
  89. data/views/images/show.html.haml +21 -0
  90. data/views/images/show.xml.haml +5 -0
  91. data/views/instance_states/show.gv.erb +45 -0
  92. data/views/instance_states/show.html.haml +31 -0
  93. data/views/instance_states/show.xml.haml +8 -0
  94. data/views/instances/index.html.haml +30 -0
  95. data/views/instances/index.xml.haml +23 -0
  96. data/views/instances/new.html.haml +55 -0
  97. data/views/instances/show.html.haml +43 -0
  98. data/views/instances/show.xml.haml +41 -0
  99. data/views/layout.html.haml +26 -0
  100. data/views/realms/index.html.haml +29 -0
  101. data/views/realms/index.xml.haml +12 -0
  102. data/views/realms/show.html.haml +15 -0
  103. data/views/realms/show.xml.haml +10 -0
  104. data/views/root/index.html.haml +4 -0
  105. data/views/storage_snapshots/index.html.haml +20 -0
  106. data/views/storage_snapshots/index.xml.haml +11 -0
  107. data/views/storage_snapshots/show.html.haml +14 -0
  108. data/views/storage_snapshots/show.xml.haml +9 -0
  109. data/views/storage_volumes/index.html.haml +21 -0
  110. data/views/storage_volumes/index.xml.haml +13 -0
  111. data/views/storage_volumes/show.html.haml +20 -0
  112. data/views/storage_volumes/show.xml.haml +13 -0
  113. metadata +361 -0
@@ -0,0 +1,31 @@
1
+ %h1 Instance States
2
+
3
+ %div#state_graph
4
+ = image_tag url_for( '/api/instance_states.png' )
5
+
6
+ %table.states
7
+ %thead
8
+ %tr
9
+ %th Origin
10
+ %th Action
11
+ %th Destination
12
+ %tbody
13
+ - @machine.states.each do |state|
14
+ %tr
15
+ %td.origin{:rowspan => "#{state.transitions.empty? ? 2 : (state.transitions.size + 1)}"}
16
+ = state
17
+ - if state.transitions.empty?
18
+ %tr
19
+ %td --
20
+ %td --
21
+ - else
22
+ - state.transitions.each do |transition|
23
+ %tr
24
+ %td
25
+ - if transition.automatically?
26
+ %em auto
27
+ - else
28
+ = transition.action
29
+ %td
30
+ = transition.destination
31
+
@@ -0,0 +1,8 @@
1
+ %states
2
+ - for state in @machine.states
3
+ %state{ :name=>state }
4
+ - for transition in state.transitions
5
+ - if ( transition.automatically? )
6
+ %transition{ :to=>transition.destination, :auto=>'true'}
7
+ - else
8
+ %transition{ :to=>transition.destination, :action=>transition.action }
@@ -0,0 +1,30 @@
1
+ %h1 Instances
2
+
3
+ %table.display
4
+ %thead
5
+ %tr
6
+ %th ID
7
+ %th Owner
8
+ %th Name
9
+ %th Image
10
+ %th Realm
11
+ %th State
12
+ %th Actions
13
+ %tbody
14
+ - @instances.each do |instance|
15
+ %tr
16
+ %td
17
+ = link_to instance.id, instance_url( instance.id )
18
+ %td
19
+ = link_to instance.owner_id, images_url( instance.owner_id )
20
+ %td
21
+ = instance.name
22
+ %td
23
+ = link_to instance.image_id, image_url( instance.image_id )
24
+ %td
25
+ = instance.realm_id ? link_to(instance.realm_id, realm_url( instance.realm_id )) : 'default'
26
+ %td
27
+ = instance.state
28
+ %td
29
+ -instance.actions.each do |action|
30
+ =link_to action, self.send(:"#{action}_instance_url", instance.id), :class => instance_action_method(action)
@@ -0,0 +1,23 @@
1
+ !!! XML
2
+ %instances
3
+ - @elements.each do |instance|
4
+ %instance{:href => instance_url(instance.id)}
5
+ %id #{instance.id}
6
+ %name #{instance.name}
7
+ %owner_id #{instance.owner_id}
8
+ %image{:href => image_url(instance.image_id)}
9
+ %realm{:href => realm_url(instance.realm_id)}
10
+ %state #{instance.state}
11
+ - haml_tag :"hardware-profile", { :href => hardware_profile_url(instance.instance_profile.id)} do
12
+ %id #{instance.instance_profile.id}
13
+ - instance.instance_profile.overrides.each do |p, v|
14
+ %property{:kind => 'fixed', :name => p, :value => v, :unit => Deltacloud::HardwareProfile::unit(p)}
15
+ %actions
16
+ - instance.actions.compact.each do |action|
17
+ %link{:rel => action, :href => self.send("#{action}_instance_url", instance.id), :method => instance_action_method(action)}
18
+ %public-addresses
19
+ - instance.public_addresses.each do |address|
20
+ %address #{address}
21
+ %private-addresses
22
+ - instance.private_addresses.each do |address|
23
+ %address #{address}
@@ -0,0 +1,55 @@
1
+ %h1 New Instance
2
+
3
+ %h2= @image.id
4
+ %h3= @image.description
5
+
6
+ %form{ :action => instances_url, :method => :post }
7
+ %input{ :name => :image_id, :type => :hidden, :value => @instance.image_id }/
8
+ %p
9
+ %label
10
+ Instance Name:
11
+ %input{ :name => 'name', :size => 30 }/
12
+ -if driver_has_feature?(:authentication_key)
13
+ %p
14
+ %label
15
+ Instance Keyname:
16
+ %input{:name => 'keyname', :size => 30 }
17
+ - if !@hardware_profiles.empty?
18
+ %h3 What size machine?
19
+ - for hwp in @hardware_profiles
20
+ .radio-group
21
+ %label{ :for => "hwp_id_#{hwp.name}" }
22
+ %input{ :type => :radio, :name => 'hwp_id', :value => hwp.name }/
23
+ = hwp.name
24
+ %br/
25
+ %span.radio-group-details
26
+ - first = true
27
+ - hwp.properties.select { |prop| prop.fixed? }.each do |prop|
28
+ - unless first
29
+ ,
30
+ - first = false
31
+ = format_hardware_property prop
32
+ - hwp.properties.reject { |prop| prop.fixed? }.each do |prop|
33
+ %span.radio-group-details
34
+ %label{ :for => "#{prop.param}_#{hwp.name}" }
35
+ = prop.name
36
+ - if prop.kind == :enum
37
+ %select{ :size => 1, :name => prop.param }
38
+ - for v in prop.values
39
+ %option= v
40
+ = prop.unit
41
+ - else
42
+ %input{ :name => prop.param, :size => 10, :value => "#{prop.default}" }
43
+ = prop.unit
44
+ (value must be between #{prop.first} #{prop.unit} and #{prop.last} #{prop.unit})
45
+ - if !@realms.empty?
46
+ %h3 Where do you want it?
47
+ - for realm in @realms
48
+ .radio-group
49
+ %label{ :for => "realm_id_#{realm.id}" }
50
+ %input{ :type => :radio, :name => 'realm_id', :value => realm.id }/
51
+ = realm.id
52
+ %br/
53
+ %span.radio-group-details
54
+ = "#{realm.name}, #{realm.limit}"
55
+ %input{ :type => :submit, :name => "commit", :value => "create" }/
@@ -0,0 +1,43 @@
1
+ %h1
2
+ = @instance.id
3
+
4
+ %dl
5
+ %di
6
+ %dt Image
7
+ %dd
8
+ = link_to @instance.image_id, image_url( @instance.image_id )
9
+ %di
10
+ %dt Owner
11
+ %dd
12
+ = @instance.owner_id
13
+ %di
14
+ %dt Name
15
+ %dd
16
+ = @instance.name
17
+ %di
18
+ %dt Hardware Profile
19
+ %dd
20
+ - prof = @instance.instance_profile
21
+ = link_to(prof.name, hardware_profile_url(prof.name))
22
+ = format_instance_profile(prof)
23
+ %di
24
+ %dt Realm
25
+ %dd
26
+ = @instance.realm_id ? link_to(@instance.realm_id, realm_url(@instance.realm_id)) : 'default'
27
+ %di
28
+ %dt State
29
+ %dd
30
+ = @instance.state
31
+ %di
32
+ %dt Public Addresses
33
+ %dd
34
+ = @instance.public_addresses.collect { |address| "<div>#{address}</div>" }.join
35
+ %di
36
+ %dt Private Addresses
37
+ %dd
38
+ = @instance.private_addresses.collect { |address| "<div>#{address}</div>" }.join
39
+ %di
40
+ %dt
41
+ %dd
42
+ -@instance.actions.each do |action|
43
+ =link_to action, self.send(:"#{action}_instance_url", @instance.id), :class => instance_action_method(action)
@@ -0,0 +1,41 @@
1
+ !!! XML
2
+ %instance{:href => instance_url(@instance.id)}
3
+ %id<
4
+ =@instance.id
5
+ %name<
6
+ =@instance.name
7
+ %owner_id<
8
+ =@instance.owner_id
9
+ %image{:href => image_url(@instance.image_id)}
10
+ %realm{:href => realm_url(@instance.realm_id)}
11
+ %state<
12
+ =@instance.state
13
+ - haml_tag :"hardware-profile", {:href => hardware_profile_url(@instance.instance_profile.id)} do
14
+ %id<
15
+ =@instance.instance_profile.id
16
+ - @instance.instance_profile.overrides.each do |p, v|
17
+ %property{:kind => 'fixed', :name => p, :value => v, :unit => Deltacloud::HardwareProfile::unit(p)}
18
+ %actions
19
+ - @instance.actions.compact.each do |instance_action|
20
+ %link{:rel => instance_action, :method => instance_action_method(instance_action), :href => self.send("#{instance_action}_instance_url", @instance.id)}
21
+ %public-addresses
22
+ - @instance.public_addresses.each do |address|
23
+ %address<
24
+ =address
25
+ %private-addresses
26
+ - @instance.private_addresses.each do |address|
27
+ %address<
28
+ =address
29
+ - if driver_has_auth_features?
30
+ %authentication{ :type => driver_auth_feature_name }
31
+ - if @instance.authn_feature_failed?
32
+ %error #{@instance.authn_error}
33
+ - else
34
+ - if driver_auth_feature_name == 'password'
35
+ %login
36
+ %username #{@instance.username}
37
+ %password #{@instance.password}
38
+ - if driver_auth_feature_name == 'key'
39
+ %login
40
+ %keyname #{@instance.keyname}
41
+
@@ -0,0 +1,26 @@
1
+ !!!
2
+ !!! XML
3
+
4
+ %html
5
+ %head
6
+ = stylesheet_link_tag '/stylesheets/compiled/screen.css', :media => 'screen, projection'
7
+ = stylesheet_link_tag '/stylesheets/compiled/print.css', :media => 'print'
8
+ /[if lt IE 8]
9
+ = stylesheet_link_tag '/stylesheets/compiled/ie.css', :media => 'screen, projection'
10
+ = stylesheet_link_tag '/stylesheets/compiled/application.css', :media => 'screen, projection'
11
+ %script{:type => "text/javascript", :src => "/javascripts/jquery-1.4.2.min.js" }
12
+ %script{:type => "text/javascript", :src => "/javascripts/application.js" }
13
+ %body
14
+ #wrapper
15
+ #header
16
+ = link_to image_tag( "/images/logo-wide.png" ), root_url
17
+ = bread_crumb
18
+ #content
19
+ = yield
20
+ #footer
21
+ #driver_info
22
+ Driver: #{DRIVER}
23
+ #copyright
24
+ Copyright 2009, 2010
25
+ %a{:href => 'http://redhat.com'} Red Hat
26
+ and individual contributors.
@@ -0,0 +1,29 @@
1
+ %h1
2
+ Realms
3
+
4
+ %table.display
5
+ %thead
6
+ %tr
7
+ %th
8
+ Name
9
+ %th
10
+ Architecture
11
+ %th
12
+ Memory
13
+ %th
14
+ Storage
15
+ %th
16
+ Mutable
17
+ %tbody
18
+ - @realms.each do |realm|
19
+ %tr
20
+ %td
21
+ = link_to realm.id, realm_url( realm.id )
22
+ %td
23
+ = realm.name
24
+ %td
25
+ = realm.state
26
+ %td
27
+ = realm.limit
28
+ %td
29
+
@@ -0,0 +1,12 @@
1
+ !!!XML
2
+ %realms
3
+ - @elements.each do |realm|
4
+ %realm{:href => realm_url(realm.id)}
5
+ %id<
6
+ =realm.id
7
+ %name<
8
+ =realm.name
9
+ %state<
10
+ =realm.state
11
+ %limit<
12
+ =realm.limit.eql?(:unlimited) ? '' : realm.limit
@@ -0,0 +1,15 @@
1
+ %h1
2
+ = @realm.id
3
+ %dl
4
+ %di
5
+ %dt Name
6
+ %dd
7
+ = @realm.name
8
+ %di
9
+ %dt State
10
+ %dd
11
+ = @realm.state
12
+ %di
13
+ %dt Limit
14
+ %dd
15
+ = @realm.limit
@@ -0,0 +1,10 @@
1
+ !!!XML
2
+ %realm{:href => realm_url(@realm.id)}
3
+ %id<
4
+ =@realm.id
5
+ %name<
6
+ =@realm.name
7
+ %state<
8
+ =@realm.state
9
+ %limit<
10
+ =@realm.limit.eql?(:unlimited) ? '' : @realm.limit
@@ -0,0 +1,4 @@
1
+ %h1
2
+ Deltacloud:
3
+ = DRIVER.to_s.titlecase
4
+ = link_to 'API', api_url
@@ -0,0 +1,20 @@
1
+ %h1 Storage Snapshots
2
+
3
+ %table
4
+ %thead
5
+ %tr
6
+ %th ID
7
+ %th Volume
8
+ %th Created
9
+ %th State
10
+ %tbody
11
+ - @storage_snapshots.each do |snapshot|
12
+ %tr
13
+ %td
14
+ = link_to snapshot.id, storage_snapshot_url( snapshot.id )
15
+ %td
16
+ = link_to snapshot.storage_volume_id, storage_volume_url( snapshot.storage_volume_id )
17
+ %td
18
+ = snapshot.created
19
+ %td
20
+ = snapshot.state
@@ -0,0 +1,11 @@
1
+ !!!XML
2
+ %storage-snapshots
3
+ - @elements.each do |snapshot|
4
+ %storage-snapshot{ :href => storage_snapshot_url(snapshot.id)}
5
+ %id<
6
+ =snapshot.id
7
+ %created<
8
+ =snapshot.created
9
+ %state<
10
+ =snapshot.state
11
+ %storage-volume{ :href => storage_volume_url(snapshot.storage_volume_id)}
@@ -0,0 +1,14 @@
1
+ %h1
2
+ = @storage_snapshot.id
3
+
4
+ %dl
5
+ %di
6
+ %dt Volume
7
+ %dd
8
+ = @storage_snapshot.storage_volume_id
9
+ %dt Created
10
+ %dd
11
+ = @storage_snapshot.created
12
+ %dt State
13
+ %dd
14
+ = @storage_snapshot.state
@@ -0,0 +1,9 @@
1
+ !!!XML
2
+ %storage-snapshot{:href => storage_snapshot_url(@storage_snapshot.id)}
3
+ %id<
4
+ =@storage_snapshot.id
5
+ %created<
6
+ =@storage_snapshot.created
7
+ %state<
8
+ =@storage_snapshot.state
9
+ %storage-volume{:href => storage_volume_url(@storage_snapshot.storage_volume_id)}
@@ -0,0 +1,21 @@
1
+ %h1 Storage Volumes
2
+
3
+ %table.display
4
+ %thead
5
+ %tr
6
+ %th ID
7
+ %th Created
8
+ %th Capacity
9
+ %th Status
10
+ %tbody
11
+ - @storage_volumes.each do |volume|
12
+ %tr
13
+ %td
14
+ = link_to volume.id, storage_volume_url( volume.id )
15
+ %td
16
+ = volume.created
17
+ %td
18
+ = "#{volume.capacity} GB"
19
+ %td
20
+ = "#{volume.state}"
21
+
@@ -0,0 +1,13 @@
1
+ !!!XML
2
+ %storage-volumes
3
+ - @elements.each do |volume|
4
+ %storage-volume{ :href => storage_volume_url(volume.id)}
5
+ %id<
6
+ =volume.id
7
+ %created<
8
+ =volume.created
9
+ %capacity<
10
+ =volume.capacity
11
+ %device<
12
+ =volume.device
13
+ %instance{:href => volume.instance_id}