[PATCH aeolus-cli] Catch 401 Unauthorized response and display a more helpful error
by Martyn Taylor
From: Matt Wagner <matt.wagner(a)redhat.com>
Resolves https://bugzilla.redhat.com/show_bug.cgi?id=767342
---
lib/aeolus_cli/command/base_command.rb | 7 +++-
spec/command/base_command_spec.rb | 16 +++++++++
spec/spec_helper.rb | 6 +---
.../command/base_command/invalid_credentials.yml | 34 ++++++++++++++++++++
4 files changed, 56 insertions(+), 7 deletions(-)
create mode 100644 spec/vcr/cassettes/command/base_command/invalid_credentials.yml
diff --git a/lib/aeolus_cli/command/base_command.rb b/lib/aeolus_cli/command/base_command.rb
index d6afc6f..16573c5 100644
--- a/lib/aeolus_cli/command/base_command.rb
+++ b/lib/aeolus_cli/command/base_command.rb
@@ -90,7 +90,10 @@ module Aeolus
code = doc.xpath("/error/code").text
message = doc.xpath("/error/message").text
- if message.to_s.empty?
+ if e.is_a?(ActiveResource::UnauthorizedAccess)
+ code = "Unauthorized"
+ message = "Invalid Credentials, please check ~/.aeolus-cli"
+ elsif message.to_s.empty?
case code
when "BuildDeleteFailure" : message = "An error occured when deleting the Build from the Image Warehouse"
when "BuildNotFound" : message = "Could not find the specified Build"
@@ -189,4 +192,4 @@ module Aeolus
end
end
end
-end
\ No newline at end of file
+end
diff --git a/spec/command/base_command_spec.rb b/spec/command/base_command_spec.rb
index 8a3b1a2..bc8a0c1 100644
--- a/spec/command/base_command_spec.rb
+++ b/spec/command/base_command_spec.rb
@@ -78,6 +78,22 @@ module Aeolus
errors.length.should == 0
end
end
+
+ describe "#handle_exception" do
+ it "should display a user message when an authorised response is returned from Conductor" do
+ VCR.use_cassette('command/base_command/invalid_credentials') do
+ lc = ListCommand.new
+ Aeolus::CLI::Base.password = "wrong_password"
+ begin
+ lc.accounts
+ rescue SystemExit => e
+ e.status.should == 1
+ end
+ $stdout.string.should include("Invalid Credentials, please check ~/.aeolus-cli")
+ end
+ end
+ end
+
end
end
end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 1c20c7a..2c3ccd7 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -64,12 +64,8 @@ RSpec.configure do |config|
YAML::load(File.open(File.join(File.dirname(__FILE__), "/../examples/aeolus-cli")))
end
end
- Aeolus::CLI::BaseCommand.class_eval do
- def handle_exception(e)
- raise e
- end
- end
end
+
config.before(:each) do
@output = double('output')
@stdout_orig = $stdout
diff --git a/spec/vcr/cassettes/command/base_command/invalid_credentials.yml b/spec/vcr/cassettes/command/base_command/invalid_credentials.yml
new file mode 100644
index 0000000..529af9b
--- /dev/null
+++ b/spec/vcr/cassettes/command/base_command/invalid_credentials.yml
@@ -0,0 +1,34 @@
+---
+- !ruby/struct:VCR::HTTPInteraction
+ request: !ruby/struct:VCR::Request
+ method: :get
+ uri: https://admin:wrong_password@localhost:443/conductor/api/provider_account...
+ body:
+ headers:
+ accept-language:
+ - en
+ accept:
+ - application/xml
+ response: !ruby/struct:VCR::Response
+ status: !ruby/struct:VCR::ResponseStatus
+ code: 401
+ message: Unauthorized
+ headers:
+ x-ua-compatible:
+ - IE=Edge,chrome=1
+ content-type:
+ - application/xml; charset=utf-8
+ server:
+ - thin 1.2.11 codename Bat-Shit Crazy
+ date:
+ - Wed, 14 Dec 2011 11:03:57 GMT
+ x-runtime:
+ - "0.159056"
+ set-cookie:
+ - _session_id=BAh7ByIPc2Vzc2lvbl9pZCIlZjJkNGVmNTZiYTQ2MTRlZGQyZDdlYjliODFjYmE5NmYiEGJyZWFkY3J1bWJzWwA%3D--18809bd7ff24d210f991c9d382b9aa27804aa043; path=/; HttpOnly
+ cache-control:
+ - no-cache
+ transfer-encoding:
+ - chunked
+ body: " "
+ http_version: "1.1"
\ No newline at end of file
--
1.7.6.4
12 years, 5 months
[PATCH conductor] Fix message on launch from catalog
by Imre Farkas
From: Imre Farkas <ifarkas(a)redhat.com>
https://bugzilla.redhat.com/show_bug.cgi?id=761456
---
src/app/stylesheets/custom.scss | 4 +
.../deployments/launch_from_catalog.html.haml | 66 ++++++++++---------
src/config/locales/en.yml | 1 +
3 files changed, 40 insertions(+), 31 deletions(-)
diff --git a/src/app/stylesheets/custom.scss b/src/app/stylesheets/custom.scss
index 31953e2..692c61c 100644
--- a/src/app/stylesheets/custom.scss
+++ b/src/app/stylesheets/custom.scss
@@ -241,3 +241,7 @@ form.generic section.services {
list-style-type: none;
}
}
+
+#no-catalog-entry {
+ margin-bottom: 30px;
+}
diff --git a/src/app/views/deployments/launch_from_catalog.html.haml b/src/app/views/deployments/launch_from_catalog.html.haml
index 0c70fcf..53cb9ce 100644
--- a/src/app/views/deployments/launch_from_catalog.html.haml
+++ b/src/app/views/deployments/launch_from_catalog.html.haml
@@ -5,38 +5,42 @@
= link_to t('edit'), edit_catalog_path(@catalog), :class => 'button pill', :id => 'edit_button'
.corner
%section.content-section
- .align-center
- %strong= t(".hint", :pool => @catalog.pool.name)
- %ul.catalog_pretty
- - @deployables.each do |deployable|
- %li.collapse_entity
- .summary
- .info
- %h2= deployable.name
- %p= deployable.description
- .controls
- = link_to t(".details"),"#", :class => "collapse"
- = button_to t(".select"), launch_time_params_deployments_path(:deployment => { :name => deployable.name, :pool_id => @catalog.pool.id }, :deployable_id => deployable.id ), :class=> "button pill"
- .details.collapsible.collapsed
- %table
- %tr
- %th
- %strong= t'.image_id'
- %th=t'.profile'
- %th=t'.hdd'
- %th=t'.ram'
- %th=t'.arch'
- %th
- %strong=t'.deployable_xml'
- -deployable.fetch_images.compact.each do |image|
+ - if @deployables.length > 0
+ .align-center
+ %strong= t(".hint", :pool => @catalog.pool.name)
+ %ul.catalog_pretty
+ - @deployables.each do |deployable|
+ %li.collapse_entity
+ .summary
+ .info
+ %h2= deployable.name
+ %p= deployable.description
+ .controls
+ = link_to t(".details"),"#", :class => "collapse"
+ = button_to t(".select"), launch_time_params_deployments_path(:deployment => { :name => deployable.name, :pool_id => @catalog.pool.id }, :deployable_id => deployable.id ), :class=> "button pill"
+ .details.collapsible.collapsed
+ %table
%tr
- %td
- %strong= image.id
- %td= deployable.hw_profile_for_image(image.id).name
- %td= deployable.hw_profile_for_image(image.id).storage
- %td= deployable.hw_profile_for_image(image.id).memory
- %td= deployable.hw_profile_for_image(image.id).architecture
- %td= link_to deployable.xml_filename, catalog_deployable_path(deployable.catalogs.first, deployable.catalog_entries.first.id, :deployable_xml => true)
+ %th
+ %strong= t'.image_id'
+ %th=t'.profile'
+ %th=t'.hdd'
+ %th=t'.ram'
+ %th=t'.arch'
+ %th
+ %strong=t'.deployable_xml'
+ -deployable.fetch_images.compact.each do |image|
+ %tr
+ %td
+ %strong= image.id
+ %td= deployable.hw_profile_for_image(image.id).name
+ %td= deployable.hw_profile_for_image(image.id).storage
+ %td= deployable.hw_profile_for_image(image.id).memory
+ %td= deployable.hw_profile_for_image(image.id).architecture
+ %td= link_to deployable.xml_filename, catalog_deployable_path(deployable.catalogs.first, deployable.catalog_entries.first.id, :deployable_xml => true)
+ - else
+ #no-catalog-entry.align-center
+ %strong= t(".no_catalog_entry")
.align-center
%div= will_paginate @deployables
diff --git a/src/config/locales/en.yml b/src/config/locales/en.yml
index dc25790..10d44c4 100644
--- a/src/config/locales/en.yml
+++ b/src/config/locales/en.yml
@@ -183,6 +183,7 @@ en:
launch_from_catalog:
profile: Profile
hint: Choose a deployable to launch in the "%{pool}" pool
+ no_catalog_entry: 'No available catalog entry. Please add one first!'
details: Details
select: Select
image_id: Image ID
--
1.7.6.4
12 years, 5 months
[PATCH conductor] Fixing the appearance of the cancel button on deployables#new
by Imre Farkas
From: Imre Farkas <ifarkas(a)redhat.com>
https://bugzilla.redhat.com/show_bug.cgi?id=760905
---
src/app/stylesheets/custom.scss | 16 ++++++++++++++++
1 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/src/app/stylesheets/custom.scss b/src/app/stylesheets/custom.scss
index 31953e2..0f4d7d5 100644
--- a/src/app/stylesheets/custom.scss
+++ b/src/app/stylesheets/custom.scss
@@ -241,3 +241,19 @@ form.generic section.services {
list-style-type: none;
}
}
+
+form#new_deployable{
+ a.button{
+ font-family: sans-serif;
+ font-size: 11px;
+ font-weight: bold;
+ color: #333333;
+ }
+
+ .button:hover,
+ .button:focus,
+ .button:active,
+ .button.active {
+ color: #ffffff;
+ }
+}
--
1.7.6.4
12 years, 5 months
[PATCH conductor] pool_family_id param added to new_pool_path
by Imre Farkas
From: Imre Farkas <ifarkas(a)redhat.com>
https://bugzilla.redhat.com/show_bug.cgi?id=761119
---
src/app/controllers/pools_controller.rb | 1 +
src/app/views/pool_families/_list.html.haml | 2 +-
2 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/src/app/controllers/pools_controller.rb b/src/app/controllers/pools_controller.rb
index 7e4503a..699376e 100644
--- a/src/app/controllers/pools_controller.rb
+++ b/src/app/controllers/pools_controller.rb
@@ -109,6 +109,7 @@ class PoolsController < ApplicationController
def new
require_privilege(Privilege::CREATE, Pool)
@pool = Pool.new
+ @pool.pool_family = PoolFamily.find(params[:pool_family_id]) unless params[:pool_family_id].blank?
@quota = Quota.new
respond_to do |format|
format.html
diff --git a/src/app/views/pool_families/_list.html.haml b/src/app/views/pool_families/_list.html.haml
index 1cf70ec..7e2c7b7 100644
--- a/src/app/views/pool_families/_list.html.haml
+++ b/src/app/views/pool_families/_list.html.haml
@@ -15,7 +15,7 @@
.section-controls
#obj_actions
= link_to t(:edit), edit_pool_family_path(pool_family), :class => 'rounded-link'
- = link_to t("pools.new_pool"), new_pool_path, :class => 'rounded-link'
+ = link_to t("pools.new_pool"), new_pool_path(:pool_family_id => pool_family.id), :class => 'rounded-link'
= link_to t("images.new.new_image"), new_image_path( :environment => pool_family.id), :class => 'rounded-link'
- unless pool_family.pools.blank?
%tr
--
1.7.6.4
12 years, 5 months
BZ 761279/766137 - Handling of imported images (rev N)
by Matt Wagner
Hi all,
Sending this out for hopefully the last time. This is a resent of my previous send[1], but with a few changes:
* In the course of rebasing on master, I had to deal with the fact that app/models/image.rb was removed. Rather than re-adding it, it was decided that it was best to move the image-import logic to aeolus-image-rubygem and then create a small bit of code to call it from Conductor. So the aeolus-image-rubygem change is semi-significant.
* The issue that tsedovic found in images#show is resolved. (It ended up requiring a ridiculous amount of code.)
* I'm omitting the aeolus-cli changes from the patch, because nothing has changed from last time and the series was essentially ACKed. They're still necessary.
Best,
Matt
[1] http://lists.fedorahosted.org/pipermail/aeolus-devel/2011-December/007384...
12 years, 5 months
[PATCH conductor] Fix deployable xml link on the launch overview page
by Tomas Sedovic
From: Tomas Sedovic <tomas(a)sedovic.cz>
When a user clicked on the Deployable XML link, they were shown the deployables
list instead of getting the xml.
---
src/app/controllers/deployables_controller.rb | 6 ++++++
src/app/views/deployments/_overview.html.haml | 2 +-
src/config/routes.rb | 1 +
3 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/src/app/controllers/deployables_controller.rb b/src/app/controllers/deployables_controller.rb
index ef44628..07556fb 100644
--- a/src/app/controllers/deployables_controller.rb
+++ b/src/app/controllers/deployables_controller.rb
@@ -86,6 +86,12 @@ class DeployablesController < ApplicationController
end
end
+ def definition
+ @deployable = Deployable.find(params[:deployable_id])
+ require_privilege(Privilege::VIEW, @deployable)
+ render :xml => @deployable.xml
+ end
+
def create
if params[:cancel]
redirect_to catalog_deployables_path
diff --git a/src/app/views/deployments/_overview.html.haml b/src/app/views/deployments/_overview.html.haml
index e68ee50..6a6ba3c 100644
--- a/src/app/views/deployments/_overview.html.haml
+++ b/src/app/views/deployments/_overview.html.haml
@@ -23,7 +23,7 @@
%p= @deployment.deployable_xml.description
%h3= t('.deployable_xml')
- =link_to @deployable.xml_filename, catalog_deployable_path((a)deployable.catalogs.first, @deployable.catalog_entries.first.id, :deployable_xml => true)
+ = link_to @deployable.xml_filename, catalog_deployable_definition_path((a)deployable.catalogs.first, @deployable)
⇒
%h3= t('.image_ids')
diff --git a/src/config/routes.rb b/src/config/routes.rb
index 09e96be..4216027 100644
--- a/src/config/routes.rb
+++ b/src/config/routes.rb
@@ -204,6 +204,7 @@ Conductor::Application.routes.draw do
delete 'multi_destroy', :on => :collection
post :filter, :on => :collection
post :build
+ get :definition
end
end
--
1.7.6.4
12 years, 5 months