[PATCH conductor] XML format for list of provider accounts
by Jan Provazník
From: Jan Provaznik <jprovazn(a)redhat.com>
task #1623 (https://www.aeolusproject.org/redmine/issues/1623)
---
.../controllers/provider_accounts_controller.rb | 5 ++
src/app/models/provider_account.rb | 2 +-
src/app/models/push_job.rb | 2 +-
src/features/provider_account.feature | 13 ++++++
.../step_definitions/provider_account_steps.rb | 44 ++++++++++++++++++++
5 files changed, 64 insertions(+), 2 deletions(-)
diff --git a/src/app/controllers/provider_accounts_controller.rb b/src/app/controllers/provider_accounts_controller.rb
index 9ae24c9..4dcd48d 100644
--- a/src/app/controllers/provider_accounts_controller.rb
+++ b/src/app/controllers/provider_accounts_controller.rb
@@ -13,6 +13,11 @@ class ProviderAccountsController < ApplicationController
end
@accounts = search.results
end
+
+ respond_to do |format|
+ format.html
+ format.xml { render :partial => 'list.xml' }
+ end
end
def show
diff --git a/src/app/models/provider_account.rb b/src/app/models/provider_account.rb
index b1c1bb8..88ebe5b 100644
--- a/src/app/models/provider_account.rb
+++ b/src/app/models/provider_account.rb
@@ -183,7 +183,7 @@ class ProviderAccount < ActiveRecord::Base
element.content = h[:value]
credential_node << element
end
- doc.to_xml
+ doc
end
def creds_label_hash
diff --git a/src/app/models/push_job.rb b/src/app/models/push_job.rb
index e028b84..9983953 100644
--- a/src/app/models/push_job.rb
+++ b/src/app/models/push_job.rb
@@ -28,7 +28,7 @@ class PushJob < Struct.new(:provider_image_id, :hydra)
# TODO: what if a provider has multiple accounts
# for now pick first account
provider_account = provider_image.provider.provider_accounts.first
- cred_block = provider_account.build_credentials.html_safe
+ cred_block = provider_account.build_credentials.to_xml.html_safe
response = RestClient.post(YAML.load_file("#{RAILS_ROOT}/config/image_factory_console.yml")['pushurl'], :image_id => provider_image.image.uuid,
:provider => provider_image.provider.name,
:credentials => cred_block
diff --git a/src/features/provider_account.feature b/src/features/provider_account.feature
index 3e6c8c9..97048b5 100644
--- a/src/features/provider_account.feature
+++ b/src/features/provider_account.feature
@@ -15,6 +15,19 @@ Feature: Manage Provider Accounts
Then I should see "New Account"
And there should be no provider accounts
+ Scenario: List providers in XML format
+ Given I accept XML
+ And there is ec2 provider account "ec2_account"
+ And there is mock provider account "mock_account"
+ When I go to the provider accounts page
+ Then I should get a XML document
+ And there should be these mock provider accounts:
+ | name | provider | provider_type | username | password |
+ | mock_account | provider1 | mock |||
+ And there should be these ec2 provider accounts:
+ | name | provider | provider_type | access_key | secret_access_key |
+ | ec2_account | amazon-ec2 | ec2 |||
+
Scenario: Create a new Provider Account
Given there is a provider named "testprovider"
And there are no provider accounts
diff --git a/src/features/step_definitions/provider_account_steps.rb b/src/features/step_definitions/provider_account_steps.rb
index 2b6c49c..60fd8f4 100644
--- a/src/features/step_definitions/provider_account_steps.rb
+++ b/src/features/step_definitions/provider_account_steps.rb
@@ -51,3 +51,47 @@ Given /^that there are these provider accounts:$/ do |table|
Factory.create(:provider_account, :name => hash['name'], :username => hash['username'])
end
end
+
+Given /^there is ec2 provider account "([^"]*)"$/ do |arg1|
+ Factory(:ec2_provider_account, :label => arg1)
+end
+
+Given /^there is mock provider account "([^"]*)"$/ do |arg1|
+ Factory(:mock_provider_account, :label => arg1)
+end
+
+Then /^there should be these mock provider accounts:$/ do |table|
+ accounts = @xml_response.root.xpath('/provider_accounts/provider_account').map do |n|
+ {:name => n.xpath('name').text,
+ :provider => n.xpath('provider').text,
+ :username => n.xpath('username').text,
+ :password => n.xpath('password').text,
+ :provider_type => n.xpath('provider_type').text}
+ end
+ table.hashes.each do |hash|
+ p = accounts.find {|n| n[:name] == hash[:name]}
+ p.should_not be_nil
+ p[:provider].should == hash[:provider]
+ p[:username].should == hash[:username]
+ p[:password].should == hash[:password]
+ p[:provider_type].should == hash[:provider_type]
+ end
+end
+
+Then /^there should be these ec2 provider accounts:$/ do |table|
+ accounts = @xml_response.root.xpath('/provider_accounts/provider_account').map do |n|
+ {:name => n.xpath('name').text,
+ :provider => n.xpath('provider').text,
+ :access_key => n.xpath('access_key').text,
+ :secret_access_key => n.xpath('secret_access_key').text,
+ :provider_type => n.xpath('provider_type').text}
+ end
+ table.hashes.each do |hash|
+ p = accounts.find {|n| n[:name] == hash[:name]}
+ p.should_not be_nil
+ p[:provider].should == hash[:provider]
+ p[:access_key].should == hash[:access_key]
+ p[:secret_access_key].should == hash[:secret_access_key]
+ p[:provider_type].should == hash[:provider_type]
+ end
+end
--
1.7.4
12 years, 10 months
[PATCH conductor] XML format for list of provider accounts
by Jan Provazník
From: Jan Provaznik <jprovazn(a)redhat.com>
task #1623 (https://www.aeolusproject.org/redmine/issues/1623)
---
.../controllers/provider_accounts_controller.rb | 5 ++
src/app/models/provider_account.rb | 2 +-
src/app/models/push_job.rb | 2 +-
src/features/provider_account.feature | 13 ++++++
.../step_definitions/provider_account_steps.rb | 44 ++++++++++++++++++++
5 files changed, 64 insertions(+), 2 deletions(-)
diff --git a/src/app/controllers/provider_accounts_controller.rb b/src/app/controllers/provider_accounts_controller.rb
index 9ae24c9..4dcd48d 100644
--- a/src/app/controllers/provider_accounts_controller.rb
+++ b/src/app/controllers/provider_accounts_controller.rb
@@ -13,6 +13,11 @@ class ProviderAccountsController < ApplicationController
end
@accounts = search.results
end
+
+ respond_to do |format|
+ format.html
+ format.xml { render :partial => 'list.xml' }
+ end
end
def show
diff --git a/src/app/models/provider_account.rb b/src/app/models/provider_account.rb
index b1c1bb8..88ebe5b 100644
--- a/src/app/models/provider_account.rb
+++ b/src/app/models/provider_account.rb
@@ -183,7 +183,7 @@ class ProviderAccount < ActiveRecord::Base
element.content = h[:value]
credential_node << element
end
- doc.to_xml
+ doc
end
def creds_label_hash
diff --git a/src/app/models/push_job.rb b/src/app/models/push_job.rb
index e028b84..9983953 100644
--- a/src/app/models/push_job.rb
+++ b/src/app/models/push_job.rb
@@ -28,7 +28,7 @@ class PushJob < Struct.new(:provider_image_id, :hydra)
# TODO: what if a provider has multiple accounts
# for now pick first account
provider_account = provider_image.provider.provider_accounts.first
- cred_block = provider_account.build_credentials.html_safe
+ cred_block = provider_account.build_credentials.to_xml.html_safe
response = RestClient.post(YAML.load_file("#{RAILS_ROOT}/config/image_factory_console.yml")['pushurl'], :image_id => provider_image.image.uuid,
:provider => provider_image.provider.name,
:credentials => cred_block
diff --git a/src/features/provider_account.feature b/src/features/provider_account.feature
index 3e6c8c9..97048b5 100644
--- a/src/features/provider_account.feature
+++ b/src/features/provider_account.feature
@@ -15,6 +15,19 @@ Feature: Manage Provider Accounts
Then I should see "New Account"
And there should be no provider accounts
+ Scenario: List providers in XML format
+ Given I accept XML
+ And there is ec2 provider account "ec2_account"
+ And there is mock provider account "mock_account"
+ When I go to the provider accounts page
+ Then I should get a XML document
+ And there should be these mock provider accounts:
+ | name | provider | provider_type | username | password |
+ | mock_account | provider1 | mock |||
+ And there should be these ec2 provider accounts:
+ | name | provider | provider_type | access_key | secret_access_key |
+ | ec2_account | amazon-ec2 | ec2 |||
+
Scenario: Create a new Provider Account
Given there is a provider named "testprovider"
And there are no provider accounts
diff --git a/src/features/step_definitions/provider_account_steps.rb b/src/features/step_definitions/provider_account_steps.rb
index 2b6c49c..60fd8f4 100644
--- a/src/features/step_definitions/provider_account_steps.rb
+++ b/src/features/step_definitions/provider_account_steps.rb
@@ -51,3 +51,47 @@ Given /^that there are these provider accounts:$/ do |table|
Factory.create(:provider_account, :name => hash['name'], :username => hash['username'])
end
end
+
+Given /^there is ec2 provider account "([^"]*)"$/ do |arg1|
+ Factory(:ec2_provider_account, :label => arg1)
+end
+
+Given /^there is mock provider account "([^"]*)"$/ do |arg1|
+ Factory(:mock_provider_account, :label => arg1)
+end
+
+Then /^there should be these mock provider accounts:$/ do |table|
+ accounts = @xml_response.root.xpath('/provider_accounts/provider_account').map do |n|
+ {:name => n.xpath('name').text,
+ :provider => n.xpath('provider').text,
+ :username => n.xpath('username').text,
+ :password => n.xpath('password').text,
+ :provider_type => n.xpath('provider_type').text}
+ end
+ table.hashes.each do |hash|
+ p = accounts.find {|n| n[:name] == hash[:name]}
+ p.should_not be_nil
+ p[:provider].should == hash[:provider]
+ p[:username].should == hash[:username]
+ p[:password].should == hash[:password]
+ p[:provider_type].should == hash[:provider_type]
+ end
+end
+
+Then /^there should be these ec2 provider accounts:$/ do |table|
+ accounts = @xml_response.root.xpath('/provider_accounts/provider_account').map do |n|
+ {:name => n.xpath('name').text,
+ :provider => n.xpath('provider').text,
+ :access_key => n.xpath('access_key').text,
+ :secret_access_key => n.xpath('secret_access_key').text,
+ :provider_type => n.xpath('provider_type').text}
+ end
+ table.hashes.each do |hash|
+ p = accounts.find {|n| n[:name] == hash[:name]}
+ p.should_not be_nil
+ p[:provider].should == hash[:provider]
+ p[:access_key].should == hash[:access_key]
+ p[:secret_access_key].should == hash[:secret_access_key]
+ p[:provider_type].should == hash[:provider_type]
+ end
+end
--
1.7.4
12 years, 10 months
Content integration and visualization with the updated cmd line tooling.
by Carl Trieloff
First we agreed that the dirty bit and marking that an instance has been
updated by some our other management API via conductor (Aeolus) would
remain unchanged.
We also agreed that the main goal is to notify the user of the status of
an instance, and that actions results from this status for the near term
would be user actions.
The states that we need to indicate on any given image are:
- unmanaged
- managed by (list ) and whether that management agent has mutated the
content. (example of list can be JON, Kattello, Opsware etc)
- build from artefacts, for example a JOES, i.e. if you start another
instance you will get what is current in the content source repositories.
Carl.
12 years, 10 months
[PATCH 00/11][image_factory] Miscellanous patches
by Mark McLoughlin
Hi,
This is a fairly random batches of patches that are independent of the
more significant changes I'm working on. I thought it would be good to
send these out separately for review.
Cheers,
Mark.
12 years, 10 months
[PATCH conductor] XML format for list of providers
by Jan Provazník
From: Jan Provaznik <jprovazn(a)redhat.com>
task #1622 (https://www.aeolusproject.org/redmine/issues/1622)
---
src/app/controllers/providers_controller.rb | 10 ++++++----
src/app/views/providers/_providers.xml.haml | 7 +++++++
src/features/provider.feature | 14 ++++++++++++++
src/features/step_definitions/provider_steps.rb | 16 ++++++++++++++++
4 files changed, 43 insertions(+), 4 deletions(-)
create mode 100644 src/app/views/providers/_providers.xml.haml
diff --git a/src/app/controllers/providers_controller.rb b/src/app/controllers/providers_controller.rb
index 2278896..2f2e7e8 100644
--- a/src/app/controllers/providers_controller.rb
+++ b/src/app/controllers/providers_controller.rb
@@ -5,15 +5,17 @@ class ProvidersController < ApplicationController
def index
@params = params
@search_term = params[:q]
+
if @search_term.blank?
load_providers
- return
+ else
+ @providers = Provider.search { keywords(params[:q]) }.results
end
- search = Provider.search do
- keywords(params[:q])
+ respond_to do |format|
+ format.html
+ format.xml { render :partial => 'providers.xml' }
end
- @providers = search.results
end
def new
diff --git a/src/app/views/providers/_providers.xml.haml b/src/app/views/providers/_providers.xml.haml
new file mode 100644
index 0000000..e7b6f24
--- /dev/null
+++ b/src/app/views/providers/_providers.xml.haml
@@ -0,0 +1,7 @@
+!!! XML
+%providers
+ - @providers.each do |p|
+ %provider
+ %name= p.name
+ %url= p.url
+ %type= p.provider_type.codename
diff --git a/src/features/provider.feature b/src/features/provider.feature
index 29bf918..8c55748 100644
--- a/src/features/provider.feature
+++ b/src/features/provider.feature
@@ -21,6 +21,20 @@ Feature: Manage Providers
| provider2 |
| provider3 |
+ Scenario: List providers in XML format
+ Given I accept XML
+ And there are these providers:
+ | name |
+ | provider1 |
+ | provider2 |
+ | provider3 |
+ When I go to the providers page
+ Then I should get a XML document
+ And XML should contain 3 providers
+ And each provider should have "name"
+ And each provider should have "url"
+ And each provider should have "provider_type"
+
Scenario: Show provider details
Given there is a provider named "testprovider"
And I am on the providers page
diff --git a/src/features/step_definitions/provider_steps.rb b/src/features/step_definitions/provider_steps.rb
index f679ba9..57572d7 100644
--- a/src/features/step_definitions/provider_steps.rb
+++ b/src/features/step_definitions/provider_steps.rb
@@ -68,3 +68,19 @@ end
Then /^there should not be a realm$/ do
Realm.find(:all, :conditions => { :provider_id => @provider.id} ).size.should == 0
end
+
+Given /^I accept XML$/ do
+ header 'Accept', 'application/xml'
+end
+
+Then /^I should get a XML document$/ do
+ @xml_response = Nokogiri::XML(response.body)
+end
+
+Then /^XML should contain (\d+) providers$/ do |arg1|
+ @xml_response.root.xpath('/providers/provider').count.should == arg1.to_i
+end
+
+Then /^each provider should have "([^"]*)"$/ do |arg1|
+ @xml_response.root.xpath("/providers/provider/#{arg1}").text.should_not be_nil
+end
--
1.7.4
12 years, 10 months
[PATCH conductor] XML format for list of providers
by Jan Provazník
From: Jan Provaznik <jprovazn(a)redhat.com>
task #1622 (https://www.aeolusproject.org/redmine/issues/1622)
---
src/app/controllers/providers_controller.rb | 10 ++++++----
src/app/views/providers/_providers.xml.haml | 7 +++++++
src/features/provider.feature | 14 ++++++++++++++
src/features/step_definitions/provider_steps.rb | 16 ++++++++++++++++
4 files changed, 43 insertions(+), 4 deletions(-)
create mode 100644 src/app/views/providers/_providers.xml.haml
diff --git a/src/app/controllers/providers_controller.rb b/src/app/controllers/providers_controller.rb
index 2278896..2f2e7e8 100644
--- a/src/app/controllers/providers_controller.rb
+++ b/src/app/controllers/providers_controller.rb
@@ -5,15 +5,17 @@ class ProvidersController < ApplicationController
def index
@params = params
@search_term = params[:q]
+
if @search_term.blank?
load_providers
- return
+ else
+ @providers = Provider.search { keywords(params[:q]) }.results
end
- search = Provider.search do
- keywords(params[:q])
+ respond_to do |format|
+ format.html
+ format.xml { render :partial => 'providers.xml' }
end
- @providers = search.results
end
def new
diff --git a/src/app/views/providers/_providers.xml.haml b/src/app/views/providers/_providers.xml.haml
new file mode 100644
index 0000000..e7b6f24
--- /dev/null
+++ b/src/app/views/providers/_providers.xml.haml
@@ -0,0 +1,7 @@
+!!! XML
+%providers
+ - @providers.each do |p|
+ %provider
+ %name= p.name
+ %url= p.url
+ %type= p.provider_type.codename
diff --git a/src/features/provider.feature b/src/features/provider.feature
index 29bf918..8c55748 100644
--- a/src/features/provider.feature
+++ b/src/features/provider.feature
@@ -21,6 +21,20 @@ Feature: Manage Providers
| provider2 |
| provider3 |
+ Scenario: List providers in XML format
+ Given I accept XML
+ And there are these providers:
+ | name |
+ | provider1 |
+ | provider2 |
+ | provider3 |
+ When I go to the providers page
+ Then I should get a XML document
+ And XML should contain 3 providers
+ And each provider should have "name"
+ And each provider should have "url"
+ And each provider should have "provider_type"
+
Scenario: Show provider details
Given there is a provider named "testprovider"
And I am on the providers page
diff --git a/src/features/step_definitions/provider_steps.rb b/src/features/step_definitions/provider_steps.rb
index f679ba9..57572d7 100644
--- a/src/features/step_definitions/provider_steps.rb
+++ b/src/features/step_definitions/provider_steps.rb
@@ -68,3 +68,19 @@ end
Then /^there should not be a realm$/ do
Realm.find(:all, :conditions => { :provider_id => @provider.id} ).size.should == 0
end
+
+Given /^I accept XML$/ do
+ header 'Accept', 'application/xml'
+end
+
+Then /^I should get a XML document$/ do
+ @xml_response = Nokogiri::XML(response.body)
+end
+
+Then /^XML should contain (\d+) providers$/ do |arg1|
+ @xml_response.root.xpath('/providers/provider').count.should == arg1.to_i
+end
+
+Then /^each provider should have "([^"]*)"$/ do |arg1|
+ @xml_response.root.xpath("/providers/provider/#{arg1}").text.should_not be_nil
+end
--
1.7.4
12 years, 10 months