[PATCH] Fill in the addresses for an instance.
by Chris Lalancette
Since condor now exports the data we need about an instance,
we can take that information in dbomatic and put it in the
database. While we are at it, we also rename "IP addresses"
to "Public Addresses"; that way it can accomodate either
IPs or hostnames.
Signed-off-by: Chris Lalancette <clalance(a)redhat.com>
---
src/app/views/instance/index.haml | 6 +++---
src/app/views/instance/show.haml | 7 +++++--
src/db/migrate/20101018174458_rename_address.rb | 10 ++++++++++
src/dbomatic/dbomatic | 15 +++++++++++++--
4 files changed, 31 insertions(+), 7 deletions(-)
create mode 100644 src/db/migrate/20101018174458_rename_address.rb
diff --git a/src/app/views/instance/index.haml b/src/app/views/instance/index.haml
index 1d6db4a..8bca1ee 100644
--- a/src/app/views/instance/index.haml
+++ b/src/app/views/instance/index.haml
@@ -4,7 +4,7 @@
{:name => 'VM NAME', :sort_attr => 'name'}, |
{:name => 'TYPE', :sort_attr => 'hardware_profiles.name'}, |
{:name => 'TEMPLATE', :sort_attr => 'templates.name'}, |
- {:name => 'IP ADDRESS', :sort_attr => 'public_ip_addresses'}, |
+ {:name => 'PUBLIC ADDRESS', :sort_attr => 'public_addresses'}, |
{:name => 'PROVIDER', :sortable => false}, |
{:name => 'STARTED BY', :sort_attr => 'users.last_name'}, |
] |
@@ -103,10 +103,10 @@
- instances.each do |inst|
%tr
%td= check_box_tag 'id[]', inst.id
- %td=inst.state
+ %td= inst.state
%td= inst.name
%td= inst.hardware_profile.name
%td= inst.template.name
- %td= inst.public_ip_addresses
+ %td= inst.public_addresses
%td= inst.cloud_account ? inst.cloud_account.provider.name : ''
%td= "#{inst.owner.first_name} #{inst.owner.last_name}" # TODO, there is "started by" in comps pdf, but we don't save this info
diff --git a/src/app/views/instance/show.haml b/src/app/views/instance/show.haml
index 42236c8..9de3929 100644
--- a/src/app/views/instance/show.haml
+++ b/src/app/views/instance/show.haml
@@ -8,8 +8,11 @@
= label_tag :status, 'Status'
%span= @instance.state
%li
- = label_tag :ip_address, 'IP Address'
- %span= @instance.public_ip_addresses
+ = label_tag :public_addresses, 'Public Addresses'
+ %span= @instance.public_addresses
+ %li
+ = label_tag :private_addresses, 'Private Addresses'
+ %span= @instance.private_addresses
%li
= label_tag :operating_system, 'Operating system'
%span= @instance.template.xml.platform
diff --git a/src/db/migrate/20101018174458_rename_address.rb b/src/db/migrate/20101018174458_rename_address.rb
new file mode 100644
index 0000000..446b61f
--- /dev/null
+++ b/src/db/migrate/20101018174458_rename_address.rb
@@ -0,0 +1,10 @@
+class RenameAddress < ActiveRecord::Migration
+ def self.up
+ rename_column :instances, :public_address, :public_addresses
+ rename_column :instances, :private_address, :private_addresses
+ remove_column :instances, :public_ip_addresses
+ end
+
+ def self.down
+ end
+end
diff --git a/src/dbomatic/dbomatic b/src/dbomatic/dbomatic
index 20a28f2..562da34 100755
--- a/src/dbomatic/dbomatic
+++ b/src/dbomatic/dbomatic
@@ -90,7 +90,7 @@ end
# Handle the event log's xml
class CondorEventLog < Nokogiri::XML::SAX::Document
- attr_accessor :tag, :event_type, :event_cmd, :event_time, :trigger_type, :grid_resource, :execute_host, :hold_reason
+ attr_accessor :tag, :event_type, :event_cmd, :event_time, :trigger_type, :grid_resource, :execute_host, :hold_reason, :private_addresses, :public_addresses
def initialize(logger)
@logger = logger
@@ -118,6 +118,10 @@ class CondorEventLog < Nokogiri::XML::SAX::Document
@execute_host = string
elsif @tag == "HoldReason"
@hold_reason = string
+ elsif @tag == "DeltacloudPublicNetworkAddresses"
+ @public_addresses = string
+ elsif @tag == "DeltacloudPrivateNetworkAddresses"
+ @private_addresses = string
end
end
end
@@ -209,6 +213,12 @@ class CondorEventLog < Nokogiri::XML::SAX::Document
inst.save!
end
+ def update_instance_addresses(inst)
+ inst.public_addresses = @public_addresses
+ inst.private_addresses = @private_addresses
+ inst.save!
+ end
+
# Create a new entry for events which we have all the neccessary data for
def end_element(element)
begin
@@ -220,8 +230,9 @@ class CondorEventLog < Nokogiri::XML::SAX::Document
else
update_instance_state_event(inst)
update_instance_cloud_id(inst)
+ update_instance_addresses(inst)
end
- @tag = @event_type = @event_cmd = @event_time = @trigger_type = @grid_resource = @execute_host = nil
+ @tag = @event_type = @event_cmd = @event_time = @trigger_type = @grid_resource = @execute_host = @hold_reason = @public_addresses = @private_addresses = nil
end
rescue => e
@logger.error "#{e.backtrace.shift}: #{e.message}"
--
1.7.3.1
13 years, 8 months
Get ssh key for an instance
by Jason Guiditta
the first of these patches can be run either of the following two ways:
[src/]$ rake cucumber (I currently have 5 failures from next running this)
[src/]$ cucumber features/instance.feature
This is expected to fail without the follow-on patch applied.
[PATCH aggregator 1/2] BZ #642432 - test 'determine the key in use for an instance'.
[PATCH aggregator 2/2] BZ #642432 - no way to determine the key for an instance.
13 years, 8 months
[PATCH aggregator] BZ #643868 - Instance Management : Internal Server
by Jan Provazník
From: Jan Provaznik <jprovazn(a)redhat.com>
https://bugzilla.redhat.com/show_bug.cgi?id=643868
Actually this patch doesn't fix internal server error, but location of pool
link - when user clicks on a pool, he is redirected on the edit pool page (same as
when user click on the pool in Pools & Zones).
---
src/app/views/instance/index.haml | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/app/views/instance/index.haml b/src/app/views/instance/index.haml
index 1d6db4a..a5f8601 100644
--- a/src/app/views/instance/index.haml
+++ b/src/app/views/instance/index.haml
@@ -69,7 +69,7 @@
- @pools.each do |pool|
%tr
%td
- =link_to pool.name, pool_url(pool.id)
+ =link_to pool.name, edit_pool_url(pool.id)
%td N/A
%td
=((pool.quota.maximum_running_instances || 0)/100)*pool.quota.total_instances
--
1.7.2.3
13 years, 8 months
[PATCH cloud engine] BZ #641380: An "Inactive" user can still log in
by Tomas Sedovic
From: Tomas Sedovic <tsedovic(a)redhat.com>
https://bugzilla.redhat.com/show_bug.cgi?id=641380
Disabled the "inactive" option for new/edit user form for now as it's not
implemented yet.
---
src/app/views/users/_form.haml | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/app/views/users/_form.haml b/src/app/views/users/_form.haml
index 1017858..bb3c0c2 100644
--- a/src/app/views/users/_form.haml
+++ b/src/app/views/users/_form.haml
@@ -13,7 +13,7 @@
.grid_5
= radio_button_tag "user_status","Active",true
= label_tag "user_status_active", "Active"
- = radio_button_tag "user_status","Inactive"
+ = radio_button_tag "user_status","Inactive", false, :disabled => true
= label_tag "user_status_inactive", "Inactive"
%fieldset.clear
= form.label :first_name, t(:first_name), :class => "alpha grid_3"
--
1.7.2.3
13 years, 8 months
[PATCH aggregator] Fixed bug 641366
by Jan Provazník
From: Jan Provaznik <jprovazn(a)redhat.com>
When user tries to build image and there is not provider or provider account,
more explicit message is raised.
---
src/app/controllers/templates_controller.rb | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/src/app/controllers/templates_controller.rb b/src/app/controllers/templates_controller.rb
index 8c8466a..04d979f 100644
--- a/src/app/controllers/templates_controller.rb
+++ b/src/app/controllers/templates_controller.rb
@@ -142,6 +142,14 @@ class TemplatesController < ApplicationController
if i
image = Image.find_by_template_id(params[:image][:template_id],
:conditions => {:target => target})
+ # FIXME: for beta release we check explicitly that provider and provider
+ # account exists
+ unless provider = Provider.find_by_cloud_type(target)
+ raise "There is no provider of '#{target}' type"
+ end
+ if provider.cloud_accounts.empty?
+ raise "There is no provider account for '#{target}' provider"
+ end
ReplicatedImage.create!(
:image_id => image.id,
:provider_id => Provider.find_by_cloud_type(target)
--
1.7.2.3
13 years, 8 months
[PATCH aggregator] Fixed rake tasks for creating user
by Jan Provazník
From: Jan Provaznik <jprovazn(a)redhat.com>
create_*_user tasks pass quota info as quota is required when creating new user
---
src/lib/tasks/dc_tasks.rake | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/src/lib/tasks/dc_tasks.rake b/src/lib/tasks/dc_tasks.rake
index 4b9d4e4..880ee17 100644
--- a/src/lib/tasks/dc_tasks.rake
+++ b/src/lib/tasks/dc_tasks.rake
@@ -16,7 +16,9 @@ namespace :dc do
user = User.new(:login => args.login, :email => args.email,
:password => args.password,
:password_confirmation => args.password,
- :first_name => args.first_name, :last_name => args.last_name)
+ :first_name => args.first_name,
+ :last_name => args.last_name,
+ :quota => Quota.new)
registration = RegistrationService.new(user)
if registration.save
puts "User registered"
@@ -78,6 +80,7 @@ namespace :dc do
u.password, u.password_confirmation = 'password', 'password'
u.email = 'admin(a)deltacloud.org'
u.first_name = 'Administrator'
+ u.quota = Quota.new
if u.save
puts "Created user 'admin' with password 'password'"
end
--
1.7.2.3
13 years, 8 months
[PATCH] Make condor_refreshd refresh classads after 15 minutes.
by Chris Lalancette
In order to make some of the condor patches more palatable
to upstream, they requested that we stop using the phone-home
capability of condor to refresh our classads. Since we don't
expect condor to restart very often, it should be sufficient to
just advertise classads to condor every 15 minutes or when it
is kicked. This patch just puts the socket in a select with
a timeout and wakes up every 15 minutes to re-advertise.
Signed-off-by: Chris Lalancette <clalance(a)redhat.com>
---
src/condor_refreshd/condor_refreshd | 18 +++++++++++++++---
1 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/src/condor_refreshd/condor_refreshd b/src/condor_refreshd/condor_refreshd
index 74dbb82..4f1b93c 100755
--- a/src/condor_refreshd/condor_refreshd
+++ b/src/condor_refreshd/condor_refreshd
@@ -31,6 +31,7 @@ help = false
daemon = true
refreshd_log_dir = "/var/log/deltacloud-aggregator"
refreshd_pid_dir = "/var/run/deltacloud-aggregator"
+timeout = 15
optparse = OptionParser.new do |opts|
@@ -50,6 +51,9 @@ BANNER
opts.on( '-p', '--port PORT', 'Use PORT (default: 7890)') do |newport|
port = newport
end
+ opts.on( '-t', '--timeout TIMEOUT', 'Automatically refresh classads after TIMEOUT minutes') do |newtime|
+ timeout = newtime
+ end
end
begin
@@ -77,7 +81,7 @@ logger.level = Logger::DEBUG
logger.info "Starting condor_refreshd..."
socket = Socket.new(Socket::AF_INET, Socket::SOCK_DGRAM, 0)
-in_addr = Socket.pack_sockaddr_in(port, '0.0.0.0')
+in_addr = Socket.pack_sockaddr_in(port, '127.0.0.1')
socket.bind(in_addr)
# daemonize
@@ -94,9 +98,17 @@ begin
while true
begin
- packet = socket.recvfrom(1024)
- logger.info "Doing classad sync"
condormatic_classads_sync
+ results = select([socket], nil, nil, timeout * 60)
+
+ # if results was nil, we timed out waiting, and we need to do a sync
+ # but not read from the socket
+ if not results.nil? and results[0][0] == socket
+ socket.recvfrom(1024)
+ logger.info "Doing classad sync after getting data from the socket"
+ else
+ logger.info "Doing classad sync after timeout"
+ end
rescue => e
logger.error "#{e.backtrace.shift}: #{e.message}"
e.backtrace.each do |step|
--
1.7.3.1
13 years, 8 months
[PATCH cloud engine] BZ #640301
by Tomas Sedovic
From: Tomas Sedovic <tsedovic(a)redhat.com>
https://bugzilla.redhat.com/show_bug.cgi?id=640301
This allows the users to edit a URL of a provider that's been previously added
to the database.
Note that the backend provider must not change, this is only for cases when
the URL entry point changes. You can't use this to switch from EC2 to
Rackspace, for example.
Since actually swapping the provider backend would require some additional
work and possibly some user intervention, it would be better as separate
feature.
---
src/app/controllers/provider_controller.rb | 29 +++++++++++++++++++++------
src/app/views/provider/_form.haml | 13 ++++++-----
src/app/views/provider/edit.haml | 1 +
3 files changed, 30 insertions(+), 13 deletions(-)
create mode 100644 src/app/views/provider/edit.haml
diff --git a/src/app/controllers/provider_controller.rb b/src/app/controllers/provider_controller.rb
index 189c5cb..da5c9bb 100644
--- a/src/app/controllers/provider_controller.rb
+++ b/src/app/controllers/provider_controller.rb
@@ -57,7 +57,7 @@ class ProviderController < ApplicationController
if params[:test_connection]
test_connection(@provider)
- redirect_to :action => "new", :provider => {:name => @provider.name, :url => @provider.url}
+ render :action => "new"
else
@provider.set_cloud_type!
if @provider.save && @provider.populate_hardware_profiles
@@ -73,16 +73,29 @@ class ProviderController < ApplicationController
def update
require_privilege(Privilege::PROVIDER_MODIFY)
+ @providers = Provider.list_for_user(@current_user, Privilege::PROVIDER_MODIFY)
@provider = Provider.find(:first, :conditions => {:id => params[:provider][:id]})
- @provider.name = params[:provider][:name]
+ previous_cloud_type = @provider.cloud_type
- if @provider.save
- flash[:notice] = "Provider updated."
- redirect_to :action => "show", :id => @provider
- else
+ @provider.update_attributes(params[:provider])
+ if params[:test_connection]
+ test_connection(@provider)
render :action => "edit"
+ else
+ @provider.set_cloud_type!
+ if previous_cloud_type != @provider.cloud_type
+ @provider.errors.add :url, "points to a different provider"
+ end
+
+ if @provider.errors.empty? and @provider.save
+ flash[:notice] = "Provider updated."
+ redirect_to :action => "show", :id => @provider
+ else
+ flash[:notice] = "Cannot update the provider."
+ render :action => "edit"
+ end
+ kick_condor
end
- kick_condor
end
def destroy
@@ -130,10 +143,12 @@ class ProviderController < ApplicationController
end
def test_connection(provider)
+ @provider.errors.clear
if @provider.connect
flash[:notice] = "Successfuly Connected to Provider"
else
flash[:notice] = "Failed to Connect to Provider"
+ @provider.errors.add :url
end
end
diff --git a/src/app/views/provider/_form.haml b/src/app/views/provider/_form.haml
index 6f03d7d..14cd292 100644
--- a/src/app/views/provider/_form.haml
+++ b/src/app/views/provider/_form.haml
@@ -1,12 +1,13 @@
- readonly = controller.action_name == 'show' ? true : false
- new_provider = ['new', 'create'].include? controller.action_name
+- edit_provider = ['edit', 'update'].include? controller.action_name
= render :partial => 'providers'
#details.grid_13
%nav.subsubnav
= render_navigation(:level => 4)
- if new_provider
- form_action = 'create'
- - elsif controller.action_name == 'edit'
+ - elsif edit_provider
- form_action = 'update'
- form_for @provider, :url => {:controller => :provider, :action => form_action}, :class => "dcloud_form" do |f|
%fieldset
@@ -23,12 +24,12 @@
%div.grid_4.omega
= f.error_message_on :url, 'URL '
= f.error_message_on :name, 'Name '
- = f.text_field :name, :title => t('.provider_name'), :value => (@provider.name if @provider), :disabled => ('disabled' if controller.action_name == 'show'), :class => "clear grid_4 alpha"
- = f.text_field :url, :title => t('.provider_url'), :class => 'emailinput', :value => (@provider.url if @provider), :disabled => ('disabled' unless new_provider), :class => "grid_5"
- - if controller.action_name == 'edit':
+ = f.text_field :name, :title => t('.provider_name'), :value => (@provider.name if @provider), :disabled => ('disabled' if readonly), :class => "clear grid_4 alpha"
+ = f.text_field :url, :title => t('.provider_url'), :class => 'emailinput', :value => (@provider.url if @provider), :disabled => ('disabled' if readonly), :class => "grid_5"
+ - if edit_provider:
= f.hidden_field :id, :value => @provider.id
.clear.prefix_4.grid_5.suffix_4.alpha.omega
- - if !Provider.exists?(@provider)
+ - if new_provider or edit_provider
%span
(
%button.linkbutton.nospace{ :type => 'submit', :value => t('.test_connection'), :name => 'test_connection', :id => 'test_connection' }<>
@@ -40,7 +41,7 @@
*
\-
= t('.required_field')
- - if controller.action_name == 'edit'
+ - if edit_provider
%input{ :type => 'submit', :value => t(:save), :name => 'save_provider', :id => 'save_provider' }
- elsif new_provider
%input{ :type => 'submit', :value => t(:add), :name => 'add_provider', :id => 'add_provider' }
diff --git a/src/app/views/provider/edit.haml b/src/app/views/provider/edit.haml
new file mode 100644
index 0000000..c66fabf
--- /dev/null
+++ b/src/app/views/provider/edit.haml
@@ -0,0 +1 @@
+= render :partial => 'form'
--
1.7.2.3
13 years, 8 months