Two simple patches
by David Lutterkort
These are two very simple patches. For whitespace, we should really get a
hook on the git repo installed that will force us to stay clean.
David
14 years, 5 months
[RFC] Advertise data injection
by David Lutterkort
These patches implement part of what's needed for user data/file
injection. The main change is that the toplevel entry point now advertises
user-data for EC2 and user-files for Rackspace in the XML, and lists
optional features in the HTML. Patch 4/4 also adds support for user-data to
the EC2 driver.
The main point of posting these is to get some discussion on the proposed
XML format for optional features.
There's still a whole bunch of things that need to happen before this is ready:
* Update the client to accept user-data/user-files when appropriate
* Add validation of request parameters, e.g., so that you get an error
when you try to create an instance with user-data on Rimu. I might put
that off for another patch series, since we need more validation across
the board
* Add user-files support to Rackspace driver
In any event, the api.xml for EC2 now contains
<link href='http://localhost:3000/api/instances' rel='instances'>
<feature name='user-data'>
<constraint name='size' unit='kB'>16</constraint>
</feature>
</link>
and that for Rackspace has
<link href='http://localhost:3000/api/instances' rel='instances'>
<feature name='user-files'>
<constraint name='number' unit='count'>5</constraint>
<constraint name='size' unit='kB'>10</constraint>
<constraint name='pathlen' unit='byte'>255</constraint>
</feature>
</link>
The idea is that features are per-collection; it is implied that having the
user-data feature means that you can include a corresponding parameter in a
create instance request. AFAICT, you don't get that back from a
DescribeInstances, and there is therefore no way to display this in the
instance view.
David
14 years, 5 months
[PATCH 1/4] Advertising of optional features
by David Lutterkort
From: David Lutterkort <lutter(a)redhat.com>
* new class Feature
* base_driver: add features and support for defining them in drivers
* views (xml): list features for each collection in api.xml
* views (html): produce table with all features for a driver
---
server/libexec/app/views/api/show.html.haml | 21 ++++++++++++++++-
server/libexec/app/views/api/show.xml.haml | 4 +++
server/libexec/lib/deltacloud/base_driver.rb | 14 +++++++++++
server/libexec/lib/deltacloud/feature.rb | 31 ++++++++++++++++++++++++++
4 files changed, 69 insertions(+), 1 deletions(-)
create mode 100644 server/libexec/lib/deltacloud/feature.rb
diff --git a/server/libexec/app/views/api/show.html.haml b/server/libexec/app/views/api/show.html.haml
index 95bb744..f6712c5 100644
--- a/server/libexec/app/views/api/show.html.haml
+++ b/server/libexec/app/views/api/show.html.haml
@@ -3,5 +3,24 @@
%ul
- for entry_point in @entry_points
- %li
+ %li
= link_to entry_point[0].to_s.titlecase, entry_point[1]
+
+%h2 Optional Features
+
+%table
+ %tr
+ %th Collection
+ %th Name
+ %th Constraints
+ - for coll in driver.class.features.keys.sort
+ - for feature in driver.features(coll)
+ %tr
+ %td= coll
+ %td= feature.name
+ %td
+ - first = true
+ - for constr in feature.constraints
+ = " and " unless first
+ - first = false
+ #{constr.name} <= #{constr.human_value}
diff --git a/server/libexec/app/views/api/show.xml.haml b/server/libexec/app/views/api/show.xml.haml
index a41acb8..5520fe9 100644
--- a/server/libexec/app/views/api/show.xml.haml
+++ b/server/libexec/app/views/api/show.xml.haml
@@ -1,3 +1,7 @@
%api{ :version=>@version, :driver=>DRIVER }
- for entry_point in @entry_points
%link{ :rel=>entry_point[0], :href=>entry_point[1] }
+ - for feature in driver.features(entry_point[0])
+ %feature{ :name=>feature.name }
+ - for constr in feature.constraints
+ %constraint{ :name => constr.name, :unit => constr.unit } #{constr.value}
diff --git a/server/libexec/lib/deltacloud/base_driver.rb b/server/libexec/lib/deltacloud/base_driver.rb
index 5add111..03d3d5b 100644
--- a/server/libexec/lib/deltacloud/base_driver.rb
+++ b/server/libexec/lib/deltacloud/base_driver.rb
@@ -45,6 +45,20 @@ module Deltacloud
self.class.hardware_profiles.find{|e| e.name == name }
end
+ def self.features
+ @features ||= {}
+ end
+
+ def self.feature(collection, name, &block)
+ features[collection] ||= []
+ return if features[collection].find { |f| f.name == name }
+ features[collection] << Feature.new(name, &block)
+ end
+
+ def features(collection)
+ self.class.features[collection] || []
+ end
+
def self.define_instance_states(&block)
machine = ::Deltacloud::StateMachine.new(&block)
@instance_state_machine = machine
diff --git a/server/libexec/lib/deltacloud/feature.rb b/server/libexec/lib/deltacloud/feature.rb
new file mode 100644
index 0000000..5e20ba3
--- /dev/null
+++ b/server/libexec/lib/deltacloud/feature.rb
@@ -0,0 +1,31 @@
+class Deltacloud::Feature
+ attr_reader :name, :constraints
+
+ class Constraint
+ attr_reader :name, :value, :unit
+
+ def initialize(name, value, opts)
+ @name = name
+ @value = value
+ @unit = opts[:unit] || "count"
+ end
+
+ def human_value
+ if unit == "count"
+ value.to_s
+ else
+ "#{value} #{unit}"
+ end
+ end
+ end
+
+ def initialize(name, &block)
+ @name = name
+ instance_eval &block
+ end
+
+ def constraint(name, value, opts = {})
+ @constraints ||= []
+ @constraints << Constraint.new(name, value, opts)
+ end
+end
--
1.6.6
14 years, 5 months
Re: [deltacloud-devel] [DELTACLOUD-INTERNAL] GoGrid driver for Deltacloud
by Michal Fojtik
On 19/01/10 15:39 -0800, David Lutterkort wrote:
>On Tue, 2010-01-19 at 12:12 +0100, Michal Fojtik wrote:
>> >In any event, it's not a top priority thing, but I'd like to get this
>> >figured out and done (if we decide it's worthwhile & feasible) in hte
>> >next month or so.
>>
>> I would like to prepare some small example of Deltacloud API in
>> sinatra and we could decide if there will be a way.
>
>I just looked at what you have in deltacloud-sinatra. Looks very nice,
>though I am having trouble running it. It keeps blowing up with various
>exceptions.
Yes, it's just demostration for now. I tested it only with 'shotgun' and it
provides only some basic listing functionality.
>BTW, attached is a patch to make deltacloudd a little friendlier.
Perfect. But 'shotgun' is now something like a 'personal development tool'.
In future I will switch it to 'thin' or 'mongrel'.
(btw. I especially like the 'which shotgun' part ;)
>But I like where this is going a lot. You should though do this on a
>branch off deltacloud-core; otherwise, you'll get huge headaches merging
>this when its ready.
Sure, but do we really want to merge this with a Rails version ?
I mean, we could add a new directory into 'core' when sinatra
version will be complete.
>> >Just the fact that Sinatra is ~ 2k lines of code makes it very
>> >appealing.
>>
>> Indeed. A few days ago I imported sinatra into Fedora Updates, so there will be
>> package as well.
>
>Cool.
Package is now ready for use in Fedora updates ;-) (with shotgun as well)
- Michal
14 years, 5 months
ERB to HAML cleanup + JQuery for tables
by Michal Fojtik
Hi again,
I cleaned up views in API to use only HAML (now there is a mix between ERB and
HAML). I guess it would be better to have only one framewerk in place to
avoid chaos ;-)
Secondary, I added a JQuery DataTables [1] library to make tables more 'nicer' ;-)
Library provides a Javascript sorting by column, pagination and 'search' box for
quick filtering (extra usefull for EC2 images list...)
Patch with all changes is available for review in attachment.
- Michal
[1] http://www.datatables.net/
14 years, 5 months
[PATCH] OpenNebula driver
by Daniel Molina Aranda
Hi,
We have finished a first version of the DeltaCloud driver for OpenNebula
[1]. If you have any problem with it, just let me know.
This is the information necessary to use the driver:
When using the driver for OpenNebula, the credentials passed in response to
the HTTP 401 authentication challenge should be your OpenNebula user and
password.
The address, in which the OCCI server is listening, needs to be defined in
an environment variable called OCCI_URL.
Regards,
[1] http://www.OpenNebula.org/
--
Daniel Molina, Cloud Technology Engineer/Researcher
DSA Research Group: web http://dsa-research.org and blog
http://blog.dsa-research.org
OpenNebula Open Source Toolkit for Cloud Computing:
http://www.OpenNebula.org
14 years, 5 months
Wrong links in API in breadcumb for storage
by Michal Fojtik
Hi,
It's just detail, but when you browse API through browser
storage_volumes and storage_snapshots gives you wrong links in breadcumb.
This solve it:
diff --git a/app/helpers/application_helper.rb
b/app/helpers/application_helper.rb
index aecd62b..48d8e4a 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -23,6 +23,7 @@ module ApplicationHelper
url = request.path.split('?') #remove extra query string parameters
levels = url[0].split('/') #break up url into different levels
levels.each_with_index do |level, index|
+ next if level.tr('_', ' ').eql?('storage')
unless level.blank?
if index == levels.size-1 ||
(level == levels[levels.size-2] &&
levels[levels.size-1].to_i > 0)
- Michal
--
Red Hat Czech, s.r.o.
Cell.: +420 722 291 817
Email: mfojtik(a)redhat.com
Web: www.cz.redhat.com
Red Hat Czech s.r.o., Purkynova 99/71, 612 45, Brno, Czech Republic
EMEA ENG-Virtualization R&D-856
14 years, 5 months