deltacloud-core 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. data/COPYING +502 -0
  2. data/Rakefile +108 -0
  3. data/bin/deltacloudd +88 -0
  4. data/config.ru +5 -0
  5. data/deltacloud.rb +14 -0
  6. data/lib/converters/xml_converter.rb +133 -0
  7. data/lib/deltacloud/base_driver.rb +19 -0
  8. data/lib/deltacloud/base_driver/base_driver.rb +189 -0
  9. data/lib/deltacloud/base_driver/features.rb +144 -0
  10. data/lib/deltacloud/drivers/ec2/ec2_driver.rb +318 -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 +239 -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/rimu/rimu_hosting_client.rb +87 -0
  22. data/lib/deltacloud/drivers/rimu/rimu_hosting_driver.rb +143 -0
  23. data/lib/deltacloud/hardware_profile.rb +131 -0
  24. data/lib/deltacloud/helpers.rb +5 -0
  25. data/lib/deltacloud/helpers/application_helper.rb +38 -0
  26. data/lib/deltacloud/helpers/conversion_helper.rb +39 -0
  27. data/lib/deltacloud/helpers/hardware_profiles_helper.rb +35 -0
  28. data/lib/deltacloud/models/base_model.rb +58 -0
  29. data/lib/deltacloud/models/image.rb +26 -0
  30. data/lib/deltacloud/models/instance.rb +37 -0
  31. data/lib/deltacloud/models/instance_profile.rb +47 -0
  32. data/lib/deltacloud/models/realm.rb +25 -0
  33. data/lib/deltacloud/models/storage_snapshot.rb +26 -0
  34. data/lib/deltacloud/models/storage_volume.rb +27 -0
  35. data/lib/deltacloud/state_machine.rb +84 -0
  36. data/lib/deltacloud/validation.rb +70 -0
  37. data/lib/drivers.rb +37 -0
  38. data/lib/sinatra/lazy_auth.rb +56 -0
  39. data/lib/sinatra/rabbit.rb +272 -0
  40. data/lib/sinatra/respond_to.rb +262 -0
  41. data/lib/sinatra/static_assets.rb +83 -0
  42. data/lib/sinatra/url_for.rb +44 -0
  43. data/public/favicon.ico +0 -0
  44. data/public/images/grid.png +0 -0
  45. data/public/images/logo-wide.png +0 -0
  46. data/public/images/rails.png +0 -0
  47. data/public/images/topbar-bg.png +0 -0
  48. data/public/javascripts/application.js +2 -0
  49. data/public/javascripts/controls.js +963 -0
  50. data/public/javascripts/dragdrop.js +973 -0
  51. data/public/javascripts/effects.js +1128 -0
  52. data/public/javascripts/prototype.js +4320 -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 +340 -0
  58. data/tests/deltacloud_test.rb +60 -0
  59. data/tests/images_test.rb +94 -0
  60. data/tests/instances_test.rb +136 -0
  61. data/tests/realms_test.rb +56 -0
  62. data/tests/storage_snapshots_test.rb +48 -0
  63. data/tests/storage_volumes_test.rb +48 -0
  64. data/views/accounts/index.html.haml +11 -0
  65. data/views/accounts/show.html.haml +30 -0
  66. data/views/api/show.html.haml +15 -0
  67. data/views/api/show.xml.haml +5 -0
  68. data/views/docs/collection.html.haml +37 -0
  69. data/views/docs/collection.xml.haml +14 -0
  70. data/views/docs/index.html.haml +15 -0
  71. data/views/docs/index.xml.haml +5 -0
  72. data/views/docs/operation.html.haml +31 -0
  73. data/views/docs/operation.xml.haml +10 -0
  74. data/views/errors/auth_exception.html.haml +8 -0
  75. data/views/errors/auth_exception.xml.haml +2 -0
  76. data/views/errors/backend_error.html.haml +17 -0
  77. data/views/errors/backend_error.xml.haml +8 -0
  78. data/views/errors/validation_failure.html.haml +11 -0
  79. data/views/errors/validation_failure.xml.haml +7 -0
  80. data/views/hardware_profiles/index.html.haml +25 -0
  81. data/views/hardware_profiles/index.xml.haml +4 -0
  82. data/views/hardware_profiles/show.html.haml +19 -0
  83. data/views/hardware_profiles/show.xml.haml +17 -0
  84. data/views/images/index.html.haml +30 -0
  85. data/views/images/index.xml.haml +7 -0
  86. data/views/images/show.html.haml +21 -0
  87. data/views/images/show.xml.haml +5 -0
  88. data/views/instance_states/show.gv.erb +45 -0
  89. data/views/instance_states/show.html.haml +31 -0
  90. data/views/instance_states/show.xml.haml +8 -0
  91. data/views/instances/index.html.haml +29 -0
  92. data/views/instances/index.xml.haml +23 -0
  93. data/views/instances/new.html.haml +49 -0
  94. data/views/instances/show.html.haml +42 -0
  95. data/views/instances/show.xml.haml +28 -0
  96. data/views/layout.html.haml +23 -0
  97. data/views/realms/index.html.haml +29 -0
  98. data/views/realms/index.xml.haml +12 -0
  99. data/views/realms/show.html.haml +15 -0
  100. data/views/realms/show.xml.haml +10 -0
  101. data/views/root/index.html.haml +4 -0
  102. data/views/storage_snapshots/index.html.haml +20 -0
  103. data/views/storage_snapshots/index.xml.haml +11 -0
  104. data/views/storage_snapshots/show.html.haml +14 -0
  105. data/views/storage_snapshots/show.xml.haml +9 -0
  106. data/views/storage_volumes/index.html.haml +21 -0
  107. data/views/storage_volumes/index.xml.haml +13 -0
  108. data/views/storage_volumes/show.html.haml +20 -0
  109. data/views/storage_volumes/show.xml.haml +13 -0
  110. metadata +311 -0
@@ -0,0 +1,10 @@
1
+ %docs{:status => "unsupported"}
2
+ %operation{:url => "/api/docs/#{@collection.name.to_s}", :name => "#{@operation.name.to_s}", :href => "#{@operation.path}", :method => "#{@operation.method}"}
3
+ %description #{@operation.description}
4
+ - @operation.each_param do |param|
5
+ %parameter{:name => "#{param.name}", :type => "#{param.type}"}
6
+ %class #{param.klass}
7
+ - unless param.options.empty?
8
+ %values
9
+ - param.options.each do |v|
10
+ %value #{v}
@@ -0,0 +1,8 @@
1
+ %h1 Authentication Failure
2
+
3
+ %p= @error.message
4
+
5
+ %dl
6
+ %di
7
+ %dt Request URL
8
+ %dd= request.env['REQUEST_URI']
@@ -0,0 +1,2 @@
1
+ %error{:url => "#{request.env['REQUEST_URI']}", :status => "#{response.status}"}
2
+ %message #{@error.message}
@@ -0,0 +1,17 @@
1
+ %h1 Backend Error
2
+
3
+ %p= @error.message
4
+
5
+ %dl
6
+ %di
7
+ %dt Request URL
8
+ %dd= request.env['REQUEST_URI']
9
+ %di
10
+ %dt Code
11
+ %dd= @error.code
12
+ %di
13
+ %dt Cause
14
+ %dd= @error.cause
15
+ %di
16
+ %dt Details
17
+ %dd= @error.details
@@ -0,0 +1,8 @@
1
+ %error{:url => "#{request.env['REQUEST_URI']}", :status => "#{response.status}"}
2
+ %kind backend_error
3
+ %backend{ :driver => DRIVER }
4
+ %code= @error.code
5
+ %cause= @error.cause
6
+ - if @error.details
7
+ %details #{@error.details}
8
+ %message #{@error.message}
@@ -0,0 +1,11 @@
1
+ %h1 Validation Failure
2
+
3
+ %p= @error.message
4
+
5
+ %dl
6
+ %di
7
+ %dt Request URL
8
+ %dd= request.env['REQUEST_URI']
9
+ %di
10
+ %dt Parameter
11
+ %dd= @error.name
@@ -0,0 +1,7 @@
1
+ %error{:url => "#{request.env['REQUEST_URI']}", :status => "#{response.status}"}
2
+ %parameter #{@error.name}
3
+ %message #{@error.message}
4
+ - unless @error.param.options.empty?
5
+ %valid_options
6
+ - @error.param.options.each do |v|
7
+ %value #{v}
@@ -0,0 +1,25 @@
1
+ %h1
2
+ Hardware Profiles
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
+ %tbody
16
+ - for profile in @profiles
17
+ %tr
18
+ %td
19
+ = link_to profile.name, hardware_profile_url( profile.name )
20
+ %td
21
+ = format_hardware_property profile.architecture
22
+ %td
23
+ = format_hardware_property profile.memory
24
+ %td
25
+ = format_hardware_property profile.storage
@@ -0,0 +1,4 @@
1
+ !!! XML
2
+ %hardware-profiles
3
+ - @profiles.each do |prof|
4
+ = haml :'hardware_profiles/show', :locals => { :@profile => prof, :partial => true }
@@ -0,0 +1,19 @@
1
+ %h1
2
+ = @profile.name
3
+
4
+ %dl
5
+ %di
6
+ %dt
7
+ Architecture
8
+ %dd
9
+ = format_hardware_property @profile.architecture
10
+ %di
11
+ %dt
12
+ Memory
13
+ %dd
14
+ = format_hardware_property @profile.memory
15
+ %di
16
+ %dt
17
+ Storage
18
+ %dd
19
+ = format_hardware_property @profile.storage
@@ -0,0 +1,17 @@
1
+ - unless defined?(partial)
2
+ !!! XML
3
+ %hardware-profile{ :href => hardware_profile_url(@profile.name) }
4
+ %id= @profile.name
5
+ - @profile.each_property do |prop|
6
+ - attr = { :name => prop.name, :kind => prop.kind, :unit => prop.unit }
7
+ - if prop.kind == :fixed
8
+ %property{ attr, :value => prop.value }/
9
+ - else
10
+ %property{ attr, :value => prop.default }
11
+ %param{ :operation => "create", :href => instances_url, :method => "post", :name => prop.param }
12
+ - if prop.kind == :range
13
+ %range{ :first => prop.first, :last => prop.last }/
14
+ - elsif prop.kind == :enum
15
+ %enum
16
+ - prop.values.each do |v|
17
+ %entry{ :value => v }/
@@ -0,0 +1,30 @@
1
+ %h1
2
+ Images
3
+
4
+ %table.display
5
+ %thead
6
+ %tr
7
+ %th
8
+ ID
9
+ %th
10
+ Name
11
+ %th
12
+ Owner
13
+ %th
14
+ Architecture
15
+ %th
16
+ Description
17
+ %tbody
18
+ - @images.each do |image|
19
+ %tr
20
+ %td
21
+ = link_to image.id, image_url(image.id)
22
+ %td
23
+ = image.name
24
+ %td
25
+ = link_to image.owner_id, images_url( :owner_id => image.owner_id )
26
+ %td
27
+ = image.architecture
28
+ %td
29
+ = image.description
30
+
@@ -0,0 +1,7 @@
1
+ !!! XML
2
+ %images
3
+ - @elements.each do |image|
4
+ %image{:href => image_url(image.id)}
5
+ - image.attributes.each do |attribute|
6
+ - haml_tag(attribute, :<) do
7
+ - haml_concat image.send(attribute)
@@ -0,0 +1,21 @@
1
+ %h1 Image
2
+ %h2
3
+ = @image.id
4
+
5
+ %dl
6
+ %di
7
+ %dt Name
8
+ %dd
9
+ = @image.name
10
+ %dt Owner
11
+ %dd
12
+ = link_to @image.owner_id, images_url( :owner_id => @image.owner_id )
13
+ %dt Architecture
14
+ %dd
15
+ = @image.architecture
16
+ %dt Description
17
+ %dd
18
+ = @image.description
19
+ %dt
20
+ %dd
21
+ = link_to 'Launch', "/api/instances/new?image_id=#{@image.id}"
@@ -0,0 +1,5 @@
1
+ !!! XML
2
+ %image{:href => image_url(@image.id)}
3
+ - @image.attributes.each do |attribute|
4
+ - haml_tag(attribute, :<) do
5
+ - haml_concat @image.send(attribute)
@@ -0,0 +1,45 @@
1
+ digraph instance_states {
2
+ rankdir=LR;
3
+ <% for state in @machine.states do %>
4
+ <%= state %>
5
+ [
6
+ label="<%= state.to_s.titlecase %>",
7
+ labelloc="c",
8
+ fontsize="12.0",
9
+ <% if ( state.name == :start || state.name == :finish ) %>
10
+ fontname="Liberation Sans Bold",
11
+ color="<%= state.name == :start ? '#449944' : '#994444' %>",
12
+ fillcolor="<%= state.name == :start ? '#88DD88' : '#DD8888' %>",
13
+ style="filled",
14
+ shape="doublecircle",
15
+ <% else %>
16
+ fontname="Liberation Sans Bold",
17
+ shape="rect",
18
+ color="#999999",
19
+ fillcolor="#DDDDDD",
20
+ style="filled",
21
+ <% end %>
22
+ height=0.5
23
+ ]
24
+ <% end %>
25
+
26
+ <% for state in @machine.states do %>
27
+ <% for transition in state.transitions do %>
28
+ <%= state %> -> <%= transition.destination %>
29
+ [
30
+ label="<%= transition.automatically? ? 'auto' : transition.action %>",
31
+ fontsize="14.0",
32
+ penwidth="2.0",
33
+ labelloc="t",
34
+ color="#CCCCCC",
35
+ <% if transition.automatically? %>
36
+ fontcolor="#227722",
37
+ fontname="Liberation Sans Bold Italic",
38
+ <% else %>
39
+ fontcolor="#333333",
40
+ fontname="Liberation Sans Bold",
41
+ <% end %>
42
+ ];
43
+ <% end %>
44
+ <% end %>
45
+ }
@@ -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,29 @@
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.collect { |a| link_to(a, self.send("#{a}_instance_url", instance.id), :method => :post)}.join(' ')
@@ -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)}
18
+ - haml_tag :"public-addresses" do
19
+ - instance.public_addresses.each do |address|
20
+ %address #{address}
21
+ - haml_tag :"private-addresses" do
22
+ - instance.private_addresses.each do |address|
23
+ %address #{address}
@@ -0,0 +1,49 @@
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
+ %label
9
+ Instance Name:
10
+ %input{ :name => 'name', :size => 30 }/
11
+ - if !@hardware_profiles.empty?
12
+ %h3 What size machine?
13
+ - for hwp in @hardware_profiles
14
+ .radio-group
15
+ %label{ :for => "hwp_id_#{hwp.name}" }
16
+ %input{ :type => :radio, :name => 'hwp_id', :value => hwp.name }/
17
+ = hwp.name
18
+ %br/
19
+ %span.radio-group-details
20
+ - first = true
21
+ - hwp.properties.select { |prop| prop.fixed? }.each do |prop|
22
+ - unless first
23
+ ,
24
+ - first = false
25
+ = format_hardware_property prop
26
+ - hwp.properties.reject { |prop| prop.fixed? }.each do |prop|
27
+ %span.radio-group-details
28
+ %label{ :for => "#{prop.param}_#{hwp.name}" }
29
+ = prop.name
30
+ - if prop.kind == :enum
31
+ %select{ :size => 1, :name => prop.param }
32
+ - for v in prop.values
33
+ %option= v
34
+ = prop.unit
35
+ - else
36
+ %input{ :name => prop.param, :size => 10, :value => "#{prop.default}" }
37
+ = prop.unit
38
+ (value must be between #{prop.first} #{prop.unit} and #{prop.last} #{prop.unit})
39
+ - if !@realms.empty?
40
+ %h3 Where do you want it?
41
+ - for realm in @realms
42
+ .radio-group
43
+ %label{ :for => "realm_id_#{realm.id}" }
44
+ %input{ :type => :radio, :name => 'realm_id', :value => realm.id }/
45
+ = realm.id
46
+ %br/
47
+ %span.radio-group-details
48
+ = "#{realm.name}, #{realm.limit}"
49
+ %input{ :type => :submit, :name => "commit", :value => "create" }/
@@ -0,0 +1,42 @@
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.collect { |action| link_to(action, "/api/instances/#{@instance.id}/#{action}") }.join("&nbsp;")