Python Library
by Michael Brown
I've written a native Python client library for Deltacloud. It has a very
similar interface to the Ruby client.
I want to make this library available for others to use. How should I go
about doing this?
Michael Brown
ITng Services
14 years
deltacloud-core-0.0.1-1.spec and RPM
by Michal Fojtik
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi all,
I have created a specfile [1] and RPM [2] for deltacloud-core based on
gem version which was recently published on gemcutter [3].
It should build without problems on Fedora 13/12.
Please let me known if you experience any problems with specfile or if
you have any issues with RPM.
- - Michal
[1] http://mifo.sk/RPMS/rubygem-deltacloud-core.spec
[2] http://mifo.sk/RPMS/rubygem-deltacloud-core-0.0.1-1.fc13.src.rpm
[3] http://rubygems.org/gems/deltacloud-core
- --
- --------------------------------------------------------
Michal Fojtik, mfojtik(a)redhat.com, +420 532 294 4307
Ruby / Ruby On Rails Developer
Deltacloud API: http://deltacloud.org
- --------------------------------------------------------
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iQEcBAEBAgAGBQJL1Y+XAAoJEEwRP1Pf2/iqjWsH/3UY1rtgYTiEEClQoYKrevvB
hPC3VT5w2DpEIQ7ZMVwOmslUBT2dw7v+3ISiNpJbWWZbfRbL1/goxEgUvD+5T259
j6/ei32tXrsymufKGMCUazvVCxOBvawbBb6UW0RMKD0i4bqhsudQ+QgiG0H7Dchb
nKsjdtLedvP1Lz2T8vVskITzR6JTHii0btANYBSopGNZhizWFBFObO43wjG+nQKf
+bu2JHPwsAqHNQt2VcHbAhikMtz7QHUV248y1NCCQHUKLGbTRGqu+orl/2hh3EPx
9lFxpaVw8+pVnN6UJbOodltI5T+ltWEfzELDROVmpH6/9Rug//HKYw1tIZ8xZ1U=
=/YoB
-----END PGP SIGNATURE-----
14 years
[PATCH 1/6] Updated model/observer calulate submit to provider time
by Martyn Taylor
From: martyntaylor <mtaylor(a)redhat.com>
---
src/app/models/task.rb | 8 +++++++-
src/app/models/task_observer.rb | 22 ++++++++++++++++++++++
src/db/migrate/20090831140000_create_tasks.rb | 1 +
src/spec/models/task_observer_spec.rb | 24 ++++++++++++++++++++++++
4 files changed, 54 insertions(+), 1 deletions(-)
create mode 100644 src/app/models/task_observer.rb
create mode 100644 src/spec/models/task_observer_spec.rb
diff --git a/src/app/models/task.rb b/src/app/models/task.rb
index 6cb907e..9f23ef2 100644
--- a/src/app/models/task.rb
+++ b/src/app/models/task.rb
@@ -28,6 +28,7 @@ class Task < ActiveRecord::Base
# moved associations here so that nested set :include directives work
STATE_QUEUED = "queued"
+ STATE_PENDING = "pending"
STATE_RUNNING = "running"
STATE_FINISHED = "finished"
STATE_PAUSED = "paused"
@@ -35,7 +36,7 @@ class Task < ActiveRecord::Base
STATE_CANCELED = "canceled"
COMPLETED_STATES = [STATE_FINISHED, STATE_FAILED, STATE_CANCELED]
- WORKING_STATES = [STATE_QUEUED, STATE_RUNNING, STATE_PAUSED]
+ WORKING_STATES = [STATE_QUEUED, STATE_RUNNING, STATE_PAUSED, STATE_PENDING]
validates_inclusion_of :type,
:in => %w( InstanceTask )
@@ -48,6 +49,7 @@ class Task < ActiveRecord::Base
# depending on subclass, action, state
TASK_STATES_OPTIONS = [["Queued", Task::STATE_QUEUED],
+ ["Pending", Task::STATE_PENDING],
["Running", Task::STATE_RUNNING],
["Paused", Task::STATE_PAUSED],
["Finished", Task::STATE_FINISHED],
@@ -92,6 +94,10 @@ class Task < ActiveRecord::Base
ret_val
end
+ def submission_time
+ time.started - time.submitted
+ end
+
def validate
errors.add("created_at", "Task started but does not have the creation time set") if time_started and created_at.nil?
errors.add("time_started", "Task ends but does not have the start time set") if time_ended and time_started.nil?
diff --git a/src/app/models/task_observer.rb b/src/app/models/task_observer.rb
new file mode 100644
index 0000000..3e2d803
--- /dev/null
+++ b/src/app/models/task_observer.rb
@@ -0,0 +1,22 @@
+class TaskObserver < ActiveRecord::Observer
+ def after_save(a_task)
+ if a_task.changed?
+ change = a_task.changes['state']
+ if change
+ update_timestamp(change[0], change[1], a_task)
+ end
+ end
+ end
+
+ def update_timestamp(state_from, state_to, a_task)
+ puts state_to
+ if state_to == Task::STATE_RUNNING
+ a_task.time_started = Time.now
+ elsif state_to == Task::STATE_PENDING
+ a_task.time_submitted = Time.now
+ end
+ end
+
+end
+
+TaskObserver.instance
\ No newline at end of file
diff --git a/src/db/migrate/20090831140000_create_tasks.rb b/src/db/migrate/20090831140000_create_tasks.rb
index a9e099f..2c3e0e2 100644
--- a/src/db/migrate/20090831140000_create_tasks.rb
+++ b/src/db/migrate/20090831140000_create_tasks.rb
@@ -28,6 +28,7 @@ class CreateTasks < ActiveRecord::Migration
t.string :task_target_type
t.string :args
t.timestamp :created_at
+ t.timestamp :time_submitted
t.timestamp :time_started
t.timestamp :time_ended
t.text :message
diff --git a/src/spec/models/task_observer_spec.rb b/src/spec/models/task_observer_spec.rb
new file mode 100644
index 0000000..5d31693
--- /dev/null
+++ b/src/spec/models/task_observer_spec.rb
@@ -0,0 +1,24 @@
+require 'spec_helper'
+
+describe TaskObserver do
+
+ before(:each) do
+ @timestamp = Time.now
+ @task = InstanceTask.new({})
+ end
+
+ it "should set started at timestamp when the task goes to state running" do
+ @task.state = Task::STATE_RUNNING
+ @task.save
+
+ @task.time_started.should >= @timestamp
+ end
+
+ it "should set time submitted timestamp when the task goes to state pending" do
+ @task.state = Task::STATE_PENDING
+ @task.save
+
+ @task.time_submitted.should >= @timestamp
+ end
+
+end
\ No newline at end of file
--
1.6.6.1
14 years
[PATCH] Edit Pool UI and backend
by Mo Morsi
also some various small fixes
---
src/app/controllers/pool_controller.rb | 14 ++++++++++++++
src/app/views/pool/edit.html.erb | 14 ++++++++++++++
src/app/views/pool/new.html.erb | 1 +
src/app/views/pool/show.html.erb | 1 +
src/spec/controllers/pool_controller_spec.rb | 13 ++++++++++++-
5 files changed, 42 insertions(+), 1 deletions(-)
create mode 100644 src/app/views/pool/edit.html.erb
diff --git a/src/app/controllers/pool_controller.rb b/src/app/controllers/pool_controller.rb
index cf751e0..6291aa2 100644
--- a/src/app/controllers/pool_controller.rb
+++ b/src/app/controllers/pool_controller.rb
@@ -81,6 +81,20 @@ class PoolController < ApplicationController
redirect_to :action => 'show', :id => @pool.id
end
+ def edit
+ @pool = Pool.find params[:id]
+ end
+
+ def update
+ @pool = Pool.find params[:id]
+ @name = params[:pool][:name]
+ unless @pool.nil? || @name.nil?
+ @pool.name = @name
+ @pool.save!
+ end
+ redirect_to :action => 'show', :id => @pool.id
+ end
+
def delete
end
diff --git a/src/app/views/pool/edit.html.erb b/src/app/views/pool/edit.html.erb
new file mode 100644
index 0000000..f1a0c6f
--- /dev/null
+++ b/src/app/views/pool/edit.html.erb
@@ -0,0 +1,14 @@
+<div class="dcloud_form">
+ <%= error_messages_for 'pool' %>
+
+ <h2>Edit Pool</h2>
+ <% form_tag({:action => 'update'}, :method => 'put') do -%>
+ <fieldset>
+ <legend>Pool</legend>
+ <ul>
+ <li><label>Name<span>Provide a descriptive name for this pool.</span></label><%= text_field :pool, :name, :value => @pool.name %></li>
+ </ul>
+ </fieldset>
+ <%= submit_tag "Save", :class => "submit" %>
+ <% end %>
+</div>
diff --git a/src/app/views/pool/new.html.erb b/src/app/views/pool/new.html.erb
index b1e329f..2a30a7a 100644
--- a/src/app/views/pool/new.html.erb
+++ b/src/app/views/pool/new.html.erb
@@ -5,6 +5,7 @@
<h2>Create a new Pool</h2><br />
<% form_tag :action => 'create' do -%>
+ <fieldset>
<legend>Pool</legend>
<ul>
<li><label>Name<span>Provide a descriptive name for this pool.</span></label><%= text_field :pool, :name %></li>
diff --git a/src/app/views/pool/show.html.erb b/src/app/views/pool/show.html.erb
index 015f13b..667240e 100644
--- a/src/app/views/pool/show.html.erb
+++ b/src/app/views/pool/show.html.erb
@@ -35,6 +35,7 @@
</tbody>
</table>
<% end %>
+<%= link_to "Edit Pool", {:action => "edit", :id => @pool.id}, :class=>"actionlink"%>
<%= link_to "Add a new instance", {:controller => "instance", :action => "new", :id => @pool}, :class=>"actionlink"%>
<%= link_to "Back end Accounts", {:action => "accounts", :id => @pool.id}, :class=>"actionlink"%>
<%= link_to "User access", {:controller => "permissions", :action => "list", :pool_id => @pool.id}, :class=>"actionlink" if has_view_perms? %>
diff --git a/src/spec/controllers/pool_controller_spec.rb b/src/spec/controllers/pool_controller_spec.rb
index 71131b8..3448186 100644
--- a/src/spec/controllers/pool_controller_spec.rb
+++ b/src/spec/controllers/pool_controller_spec.rb
@@ -2,6 +2,7 @@ require 'spec_helper'
describe PoolController do
+ fixtures :all
before(:each) do
@admin_permission = Factory :admin_permission
@admin = @admin_permission.user
@@ -26,7 +27,17 @@ describe PoolController do
post :create, :pool => { :name => 'foopool' }
end.should change(Pool, :count).by(1)
id = Pool.find(:first, :conditions => ['name = ?', 'foopool']).id
- response.should redirect_to("http://test.host/pool/show/#{id}")
+ response.should redirect_to("http://test.host/pool/#{id}")
+ end
+
+ it "should provider means to update pool" do
+ UserSession.create(@admin)
+ post :create, :pool => { :name => 'update-test-pool' }
+ pool_id = Pool.find(:first, :conditions => ['name = ?', 'update-test-pool']).id
+
+ post :update, :id => pool_id, :pool => {:name => 'new-update-test-pool'}
+ pool = Pool.find(:first, :conditions => ['name = ?', 'new-update-test-pool'])
+ pool.id.should == pool_id
end
it "should provide ui to view hardware profiles" do
--
1.6.2.5
14 years
New version of dcloudapi C library
by Chris Lalancette
Hey all,
I just pushed version 0.2 of the deltacloud C library (dcloudapi) to the
fedorahosted git repo:
git://git.fedorahosted.org/git/deltacloud/dcloudapi.git
The most important part of this new version is that it implements hardware
profiles and removes flavors, following the changes to the deltacloud API.
This version also adds proper versioning to the library, and has a few
other bug fixes.
--
Chris Lalancette
14 years