Aeolus Git
by Martyn Taylor
Gents,
There are still a few patches that make it to the list with either white
space errors, or the wrong prefix etc... This shouldn't really happen
if people have the correct git hooks/configs setup.
I created this tool a while back to make it easier for people to do set
stuff up properly and quickly, it will clone any aeolus git repo and
setup the git configs and git hooks. I had no takers last time I
posted, but it helps me a bunch, so would recommend using it. I've put
it in github:
site: https://github.com/mtaylor/aeolus-git
git: git@github.com:mtaylor/aeolus-git.git
aeolus-git --help for info
Cheers,
Martyn
12 years, 4 months
[PATCH conductor] obscured launch parameter if it is password
by Tomas Hrcka
---
.../views/deployments/launch_time_params.html.haml | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/src/app/views/deployments/launch_time_params.html.haml b/src/app/views/deployments/launch_time_params.html.haml
index 2f6e4ff..9e633f8 100644
--- a/src/app/views/deployments/launch_time_params.html.haml
+++ b/src/app/views/deployments/launch_time_params.html.haml
@@ -28,7 +28,10 @@
- id = "deployment[launch_parameters][#{assembly_name}][#{service.name}][#{parameter.name}]"
= label_tag id, parameter.name.titleize + ':'
- value = get_hash_multi(params, [:deployment, :launch_parameters, assembly_name, service.name, parameter.name])
- = text_field_tag id, (parameter.value or value)
+ - if parameter.type == "password"
+ = password_field_tag id, (parameter.value or value)
+ - else
+ = text_field_tag id, (parameter.value or value)
- else
= t('.reference', :assembly => parameter.reference_assembly, :parameter => parameter.reference_parameter)
--
1.7.6.4
12 years, 4 months
[PATCH] Updated image show UI
by Jan Provazník
This patchset updates image show view. The patchset requires newest imagefactory from src +
aplying a patch for imagefactory (see commit log of third patch). Tests are not included as
mocking of imagefactory/iwhd communication is not simple to do now.
12 years, 4 months
[PATCH aeolus-cli] Set language in HTTP_ACCEPT_LANGUAGE header
by Richard Su
The cli needs to pass the language to the conductor api so that error messages
the api returns are translated.
---
lib/aeolus_cli/model/base.rb | 10 +++++++++-
1 files changed, 9 insertions(+), 1 deletions(-)
diff --git a/lib/aeolus_cli/model/base.rb b/lib/aeolus_cli/model/base.rb
index ae83808..0ea195c 100644
--- a/lib/aeolus_cli/model/base.rb
+++ b/lib/aeolus_cli/model/base.rb
@@ -37,6 +37,14 @@ module Aeolus
end
end
end
+
+ def headers()
+ result = {}
+ if !ENV['LANG'].nil? && ENV['LANG'].size >= 2
+ result['ACCEPT_LANGUAGE'] = ENV['LANG'][0,2]
+ end
+ result
+ end
end
# Active Resrouce Uses dashes instead of underscores, this method overrides to use underscore
@@ -51,4 +59,4 @@ module Aeolus
end
end
end
-end
\ No newline at end of file
+end
--
1.7.6.4
12 years, 4 months
[PATCH aeolus-cli] RM 2803 - Add status checking on image builds and pushes - v2
by Richard Su
v2 - rebased
https://www.aeolusproject.org/redmine/issues/2803
---
lib/aeolus_cli.rb | 1 +
lib/aeolus_cli/command/config_parser.rb | 24 +++++++++-
lib/aeolus_cli/command/status_command.rb | 45 ++++++++++++++++++
man/aeolus-cli-build.1 | 2 +-
man/aeolus-cli-list.1 | 2 +-
man/aeolus-cli-push.1 | 2 +-
man/aeolus-cli-status.1 | 36 ++++++++++++++
man/aeolus-cli.1 | 4 +-
spec/command/config_parser_spec.rb | 7 +++
spec/command/status_command_spec.rb | 49 ++++++++++++++++++++
spec/spec_helper.rb | 1 +
.../command/status_command/providerimage.yml | 42 +++++++++++++++++
.../command/status_command/targetimage.yml | 38 +++++++++++++++
13 files changed, 247 insertions(+), 6 deletions(-)
create mode 100644 lib/aeolus_cli/command/status_command.rb
create mode 100644 man/aeolus-cli-status.1
create mode 100644 spec/command/status_command_spec.rb
create mode 100644 spec/vcr/cassettes/command/status_command/providerimage.yml
create mode 100644 spec/vcr/cassettes/command/status_command/targetimage.yml
diff --git a/lib/aeolus_cli.rb b/lib/aeolus_cli.rb
index 46dd8e5..a5a6bce 100644
--- a/lib/aeolus_cli.rb
+++ b/lib/aeolus_cli.rb
@@ -20,6 +20,7 @@ require File.join(File.dirname(__FILE__), 'aeolus_cli/command', 'build_command')
require File.join(File.dirname(__FILE__), 'aeolus_cli/command', 'push_command')
require File.join(File.dirname(__FILE__), 'aeolus_cli/command', 'import_command')
require File.join(File.dirname(__FILE__), 'aeolus_cli/command', 'delete_command')
+require File.join(File.dirname(__FILE__), 'aeolus_cli/command', 'status_command')
require File.join(File.dirname(__FILE__), 'aeolus_cli/command', 'config_parser')
require File.join(File.dirname(__FILE__), 'aeolus_cli/model', 'base')
diff --git a/lib/aeolus_cli/command/config_parser.rb b/lib/aeolus_cli/command/config_parser.rb
index 05e0ed4..e67ffb8 100644
--- a/lib/aeolus_cli/command/config_parser.rb
+++ b/lib/aeolus_cli/command/config_parser.rb
@@ -18,7 +18,7 @@ require 'logger'
module Aeolus
module CLI
class ConfigParser
- COMMANDS = %w(list build push import delete)
+ COMMANDS = %w(list build push import delete status)
attr_accessor :options, :command, :args
def initialize(argv)
@@ -138,9 +138,21 @@ module Aeolus
end
opts.separator ""
+ opts.separator "Status options:"
+ opts.on('-t', '--targetimage ID', 'target image status') do |id|
+ @options[:subcommand] = :target_image
+ @options[:targetimage] = id
+ end
+ opts.on('-P', '--providerimage ID', 'provider image status') do |id|
+ @options[:subcommand] = :provider_image
+ @options[:providerimage] = id
+ end
+
+ opts.separator ""
opts.separator "URL with credentials to Conductor are set in ~/.aeolus-cli"
opts.separator "Conductor URL should point to https://<host_where_conductor_runs>/conductor/api"
+
opts.separator ""
opts.separator "List Examples:"
opts.separator "aeolus-cli list --images # list available images"
@@ -178,6 +190,11 @@ module Aeolus
opts.separator "aeolus-cli delete --build $build_id # deletes a build and all associated targetimages"
opts.separator "aeolus-cli delete --targetimage $target_image # deletes a target image and all associated provider images"
opts.separator "aeolus-cli delete --providerimage $provider_image # deletes a provider image"
+
+ opts.separator ""
+ opts.separator "Status examples:"
+ opts.separator "aeolus-cli status --targetimage $target_image # status of target image build"
+ opts.separator "aeolus-cli status --providerimage $provider_image # status of provider image push"
end
begin
@@ -235,6 +252,11 @@ module Aeolus
delete_command.send(@options[:subcommand])
end
end
+
+ def status
+ status_command = StatusCommand.new(@options)
+ status_command.run
+ end
end
end
end
diff --git a/lib/aeolus_cli/command/status_command.rb b/lib/aeolus_cli/command/status_command.rb
new file mode 100644
index 0000000..a3f5a6a
--- /dev/null
+++ b/lib/aeolus_cli/command/status_command.rb
@@ -0,0 +1,45 @@
+# Copyright 2011 Red Hat, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+require 'rest_client'
+
+module Aeolus
+ module CLI
+ class StatusCommand < BaseCommand
+ attr_accessor :console
+ def initialize(opts={}, logger=nil)
+ super(opts, logger)
+ end
+
+ def run
+ begin
+ if @options[:targetimage]
+ ti = Aeolus::CLI::ProviderImage.find(@options[:targetimage])
+ puts "Build Status: " + ti.status
+ elsif @options[:providerimage]
+ pi = Aeolus::CLI::ProviderImage.find(@options[:providerimage])
+ puts "Push Status: " + pi.status
+ else
+ puts "Error: You must specify either a target or provider image to check their status"
+ quit(1)
+ end
+
+ quit(0)
+ rescue => e
+ handle_exception(e)
+ end
+ end
+ end
+ end
+end
diff --git a/man/aeolus-cli-build.1 b/man/aeolus-cli-build.1
index b3e4332..faf0b74 100644
--- a/man/aeolus-cli-build.1
+++ b/man/aeolus-cli-build.1
@@ -33,4 +33,4 @@ Build a new image for ec2 based on the specified template TDL file template.tdl
.TP
Martyn Taylor (mtaylor(a)redhat.com), Jason Guiditta (jguiditta(a)redhat.com)
.SH SEE ALSO
-aeolus-cli-list(1), aeolus-cli-push(1), aeolus-cli-import(1)
+aeolus-cli-list(1), aeolus-cli-push(1), aeolus-cli-import(1), aeolus-cli-status(1)
diff --git a/man/aeolus-cli-list.1 b/man/aeolus-cli-list.1
index d8b0dde..40c20ec 100644
--- a/man/aeolus-cli-list.1
+++ b/man/aeolus-cli-list.1
@@ -85,4 +85,4 @@ List all available accounts
.SH AUTHOR
Martyn Taylor (mtaylor(a)redhat.com), Jason Guiditta (jguiditta(a)redhat.com)
.SH SEE ALSO
-aeolus-cli-build(1), aeolus-cli-push(1), aeolus-cli-import(1), aeolus-cli-delete(1)
+aeolus-cli-build(1), aeolus-cli-push(1), aeolus-cli-import(1), aeolus-cli-delete(1), aeolus-cli-status(1)
diff --git a/man/aeolus-cli-push.1 b/man/aeolus-cli-push.1
index dfc4848..3f86d40 100644
--- a/man/aeolus-cli-push.1
+++ b/man/aeolus-cli-push.1
@@ -40,4 +40,4 @@ Push a target image to each of the specified accounts
.SH AUTHOR
Martyn Taylor (mtaylor(a)redhat.com), Jason Guiditta (jguiditta(a)redhat.com)
.SH SEE ALSO
-aeolus-cli-list(1), aeolus-cli-build(1), aeolus-cli-import(1)
+aeolus-cli-list(1), aeolus-cli-build(1), aeolus-cli-import(1), aeolus-cli-status(1)
diff --git a/man/aeolus-cli-status.1 b/man/aeolus-cli-status.1
new file mode 100644
index 0000000..e283071
--- /dev/null
+++ b/man/aeolus-cli-status.1
@@ -0,0 +1,36 @@
+.TH aeolus-cli 1 "November 23, 2011" "version 0.1" "USER COMMANDS"
+.SH NAME
+aeolus-cli status \- command for querying build and push status
+.SH SYNOPSIS
+.B aeolus-cli status [\-h|--help] [\-u|--username] [\-w|--password] [\-t|--targetimage [target-image-id]] [\-P|--providerimage [provider-image-id]]
+.SH DESCRIPTION
+aeolus-cli status command allows users to query for the status of builds and pushes.
+.SH OPTIONS
+.TP
+\-u, --user <username>
+Conductor username
+.TP
+\-w, --password <password>
+Conductor password
+.TP
+\-t, --targetimage
+A target image id to query for build status
+.TP
+\-P, --providerimage
+A provider image id to query for push status
+.TP
+Get usage information for this command and associated commmands
+\-h, --help
+.SH EXAMPLES
+.TP
+Retrieve build status for target image A
+.B aeolus-cli status
+\--targetimage A
+.TP
+Retrieve push status for provider image B
+.B aeolus-cli status
+\--providerimage B
+.TP
+Martyn Taylor (mtaylor(a)redhat.com), Jason Guiditta (jguiditta(a)redhat.com)
+.SH SEE ALSO
+aeolus-cli-list(1), aeolus-cli-build(1), aeolus-cli-push(1), aeolus-cli-import(1)
diff --git a/man/aeolus-cli.1 b/man/aeolus-cli.1
index 8e7dcb0..d10017c 100644
--- a/man/aeolus-cli.1
+++ b/man/aeolus-cli.1
@@ -5,7 +5,7 @@ aeolus-cli \- command line tool for managing aeolus images
.B aeolus-cli
[\-h]
.SH DESCRIPTION
-aeolus-cli is a tool that allows users to control their aeolus images through image builder and aeolus conductor. aeolus-cli offers four commands options; list, build, push, import. For more information on each command please run man aeolus-cli <command> or aeolus-cli --help
+aeolus-cli is a tool that allows users to control their aeolus images through image builder and aeolus conductor. aeolus-cli offers five commands options; list, build, push, import, status. For more information on each command please run man aeolus-cli <command> or aeolus-cli --help
.SH OPTIONS
.TP
\-h, --help
@@ -24,4 +24,4 @@ If setup differs from default one, those should be changed accordingly. Conducto
.SH AUTHOR
Martyn Taylor (mtaylor(a)redhat.com), Jason Guiditta (jguiditta(a)redhat.com)
.SH SEE ALSO
-aeolus-cli-build(1), aeolus-cli-push(1), aeolus-cli-list(1), aeolus-cli-import(1)
+aeolus-cli-build(1), aeolus-cli-push(1), aeolus-cli-list(1), aeolus-cli-import(1), aeolus-cli-status(1)
diff --git a/spec/command/config_parser_spec.rb b/spec/command/config_parser_spec.rb
index f4e48ec..7a39c20 100644
--- a/spec/command/config_parser_spec.rb
+++ b/spec/command/config_parser_spec.rb
@@ -83,6 +83,13 @@ module Aeolus
config_parser.options[:build].should == '12345'
end
+ it "should set options hash for valid status options" do
+ config_parser = ConfigParser.new(%w(status --targetimage 789))
+ config_parser.options[:targetimage].should == '789'
+ config_parser = ConfigParser.new(%w(status --providerimage 123))
+ config_parser.options[:providerimage].should == '123'
+ end
+
it "should set options hash for valid import options" do
config_parser = ConfigParser.new(%w(import --provider ec2-us-east-1a --description /path/to/file --id ami-123456 --target ec2))
config_parser.options[:provider].should == ['ec2-us-east-1a']
diff --git a/spec/command/status_command_spec.rb b/spec/command/status_command_spec.rb
new file mode 100644
index 0000000..ab4f119
--- /dev/null
+++ b/spec/command/status_command_spec.rb
@@ -0,0 +1,49 @@
+# Copyright 2011 Red Hat, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+require 'spec_helper'
+
+module Aeolus
+ module CLI
+ describe StatusCommand do
+ it "should return status for target image" do
+ VCR.use_cassette('command/status_command/targetimage') do
+ @options[:targetimage] = ['1a0b179b-eb8a-4ce5-96e5-2b01ef2089cb']
+
+ s = StatusCommand.new(@options, @output)
+ begin
+ s.run
+ rescue SystemExit => e
+ e.status.should == 0
+ end
+ $stdout.string.should include("Build Status: FAILED")
+ end
+ end
+
+ it "should return status for provider image" do
+ VCR.use_cassette('command/status_command/providerimage') do
+ @options[:providerimage] = ['1ad1ca1d-d6d8-4892-a255-c4d49c03ed9b']
+
+ s = StatusCommand.new(@options, @output)
+ begin
+ s.run
+ rescue SystemExit => e
+ e.status.should == 0
+ end
+ $stdout.string.should include("Push Status: COMPLETE")
+ end
+ end
+ end
+ end
+end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 7cb20ca..1c20c7a 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -32,6 +32,7 @@ require 'build_command'
require 'push_command'
require 'import_command'
require 'delete_command'
+require 'status_command'
require 'vcr_setup'
diff --git a/spec/vcr/cassettes/command/status_command/providerimage.yml b/spec/vcr/cassettes/command/status_command/providerimage.yml
new file mode 100644
index 0000000..3aba6f6
--- /dev/null
+++ b/spec/vcr/cassettes/command/status_command/providerimage.yml
@@ -0,0 +1,42 @@
+---
+- !ruby/struct:VCR::HTTPInteraction
+ request: !ruby/struct:VCR::Request
+ method: :get
+ uri: https://admin:password@localhost:443/conductor/api/provider_images/1ad1ca...
+ body:
+ headers:
+ accept:
+ - application/xml
+ response: !ruby/struct:VCR::Response
+ status: !ruby/struct:VCR::ResponseStatus
+ code: 200
+ message: OK
+ headers:
+ x-ua-compatible:
+ - IE=Edge,chrome=1
+ etag:
+ - "\"f06d14fc7ff951eef3ca560ad60f380d\""
+ content-type:
+ - application/xml; charset=utf-8
+ server:
+ - thin 1.2.11 codename Bat-Shit Crazy
+ date:
+ - Tue, 22 Nov 2011 23:47:13 GMT
+ x-runtime:
+ - "0.273658"
+ set-cookie:
+ - _session_id=BAh7CCIPc2Vzc2lvbl9pZCIlNDY1OWU3YzgxNGZkOWQ4ZmY1ZDE5MzVkY2VhYzA4ZmYiGXdhcmRlbi51c2VyLnVzZXIua2V5aQYiEGJyZWFkY3J1bWJzWwA%3D--661d13e5a47633d15df8970235041aea2a860b31; path=/; HttpOnly
+ cache-control:
+ - max-age=0, private, must-revalidate
+ transfer-encoding:
+ - chunked
+ body: |+
+ <provider_image href='https://localhost/conductor/api/provider_images/1ad1ca1d-d6d8-4892-a255-c...' id='1ad1ca1d-d6d8-4892-a255-c4d49c03ed9b'>
+ <object_type>provider_image</object_type>
+ <target_identifier>Mock_mock_1ad1ca1d-d6d8-4892-a255-c4d49c03ed9b</target_identifier>
+ <status>COMPLETE</status>
+ <provider>mock</provider>
+ <target_image href='https://localhost/conductor/api/target_images/31a7fee4-37de-42ac-a573-2ab...' id='31a7fee4-37de-42ac-a573-2ab844145698'></target_image>
+ </provider_image>
+
+ http_version: "1.1"
diff --git a/spec/vcr/cassettes/command/status_command/targetimage.yml b/spec/vcr/cassettes/command/status_command/targetimage.yml
new file mode 100644
index 0000000..3e77a6d
--- /dev/null
+++ b/spec/vcr/cassettes/command/status_command/targetimage.yml
@@ -0,0 +1,38 @@
+---
+- !ruby/struct:VCR::HTTPInteraction
+ request: !ruby/struct:VCR::Request
+ method: :get
+ uri: https://admin:password@localhost:443/conductor/api/provider_images/1a0b17...
+ body:
+ headers:
+ accept:
+ - application/xml
+ response: !ruby/struct:VCR::Response
+ status: !ruby/struct:VCR::ResponseStatus
+ code: 200
+ message: OK
+ headers:
+ x-ua-compatible:
+ - IE=Edge,chrome=1
+ etag:
+ - "\"a61cb9f4c82824a7fe5c8107f167cff1\""
+ content-type:
+ - application/xml; charset=utf-8
+ server:
+ - thin 1.2.11 codename Bat-Shit Crazy
+ date:
+ - Tue, 22 Nov 2011 23:45:27 GMT
+ x-runtime:
+ - "0.049840"
+ set-cookie:
+ - _session_id=BAh7CCIPc2Vzc2lvbl9pZCIlNjBhMDU4NTY2MWI2MGRjMWNlNjI2ZmY4YTFkYjQ2ODAiGXdhcmRlbi51c2VyLnVzZXIua2V5aQYiEGJyZWFkY3J1bWJzWwA%3D--ecfe1e213920f3ba82c9b9c191118ee60d03f44c; path=/; HttpOnly
+ cache-control:
+ - max-age=0, private, must-revalidate
+ transfer-encoding:
+ - chunked
+ body: |+
+ <provider_image href='https://localhost/conductor/api/provider_images/1a0b179b-eb8a-4ce5-96e5-2...' id='1a0b179b-eb8a-4ce5-96e5-2b01ef2089cb'>
+ <status>FAILED</status>
+ </provider_image>
+
+ http_version: "1.1"
--
1.7.6.4
12 years, 4 months
[PATCH conductor] Registering multiple catalogs to deployment Renaming CatalogEntriesController to DeployablesController
by Imre Farkas
From: Imre Farkas <ifarkas(a)redhat.com>
---
src/app/controllers/catalog_entries_controller.rb | 171 +------------------
src/app/controllers/deployables_controller.rb | 176 +++++++++++++++++++-
src/app/models/catalog_entry.rb | 2 +
src/app/views/catalog_entries/_form.html.haml | 27 ---
src/app/views/catalog_entries/_from_url.html.haml | 27 ---
src/app/views/catalog_entries/_list.html.haml | 38 -----
src/app/views/catalog_entries/_new.html.haml | 65 -------
.../catalog_entries/_new_from_image.html.haml | 24 ---
.../catalog_entries/_section_header.html.haml | 4 -
src/app/views/catalog_entries/_upload.html.haml | 27 ---
src/app/views/catalog_entries/edit.html.haml | 15 --
src/app/views/catalog_entries/index.html.haml | 3 -
src/app/views/catalog_entries/new.html.haml | 2 -
src/app/views/catalog_entries/show.html.haml | 58 -------
src/app/views/catalogs/show.html.haml | 12 +-
src/app/views/deployables/_form.html.haml | 27 +++
src/app/views/deployables/_from_url.html.haml | 27 +++
src/app/views/deployables/_list.html.haml | 38 +++++
src/app/views/deployables/_new.html.haml | 65 +++++++
.../views/deployables/_new_from_image.html.haml | 24 +++
.../views/deployables/_section_header.html.haml | 4 +
src/app/views/deployables/_upload.html.haml | 27 +++
src/app/views/deployables/edit.html.haml | 15 ++
src/app/views/deployables/index.html.haml | 3 +
src/app/views/deployables/new.html.haml | 2 +
src/app/views/deployables/show.html.haml | 62 +++++++
src/app/views/deployments/_overview.html.haml | 2 +-
.../deployments/launch_from_catalog.html.haml | 2 +-
src/config/locales/en.yml | 1 +
src/config/routes.rb | 4 +-
src/features/catalog_entries.feature | 89 ----------
src/features/deployables.feature | 89 ++++++++++
.../step_definitions/catalog_entry_steps.rb | 19 --
src/features/step_definitions/deployable_steps.rb | 19 ++
src/features/support/paths.rb | 4 +-
.../controllers/catalog_entries_controller_spec.rb | 46 -----
.../controllers/deployables_controller_spec.rb | 46 +++++
37 files changed, 641 insertions(+), 625 deletions(-)
delete mode 100644 src/app/views/catalog_entries/_form.html.haml
delete mode 100644 src/app/views/catalog_entries/_from_url.html.haml
delete mode 100644 src/app/views/catalog_entries/_list.html.haml
delete mode 100644 src/app/views/catalog_entries/_new.html.haml
delete mode 100644 src/app/views/catalog_entries/_new_from_image.html.haml
delete mode 100644 src/app/views/catalog_entries/_section_header.html.haml
delete mode 100644 src/app/views/catalog_entries/_upload.html.haml
delete mode 100644 src/app/views/catalog_entries/edit.html.haml
delete mode 100644 src/app/views/catalog_entries/index.html.haml
delete mode 100644 src/app/views/catalog_entries/new.html.haml
delete mode 100644 src/app/views/catalog_entries/show.html.haml
create mode 100644 src/app/views/deployables/_form.html.haml
create mode 100644 src/app/views/deployables/_from_url.html.haml
create mode 100644 src/app/views/deployables/_list.html.haml
create mode 100644 src/app/views/deployables/_new.html.haml
create mode 100644 src/app/views/deployables/_new_from_image.html.haml
create mode 100644 src/app/views/deployables/_section_header.html.haml
create mode 100644 src/app/views/deployables/_upload.html.haml
create mode 100644 src/app/views/deployables/edit.html.haml
create mode 100644 src/app/views/deployables/index.html.haml
create mode 100644 src/app/views/deployables/new.html.haml
create mode 100644 src/app/views/deployables/show.html.haml
delete mode 100644 src/features/catalog_entries.feature
create mode 100644 src/features/deployables.feature
delete mode 100644 src/features/step_definitions/catalog_entry_steps.rb
create mode 100644 src/features/step_definitions/deployable_steps.rb
delete mode 100644 src/spec/controllers/catalog_entries_controller_spec.rb
create mode 100644 src/spec/controllers/deployables_controller_spec.rb
diff --git a/src/app/controllers/catalog_entries_controller.rb b/src/app/controllers/catalog_entries_controller.rb
index a8adbb6..84c099a 100644
--- a/src/app/controllers/catalog_entries_controller.rb
+++ b/src/app/controllers/catalog_entries_controller.rb
@@ -15,181 +15,20 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA. A copy of the GNU General Public License is
# also available at http://www.gnu.org/copyleft/gpl.html.
-require 'uri'
class CatalogEntriesController < ApplicationController
- before_filter :require_user
-
- def index
- clear_breadcrumbs
- save_breadcrumb(catalog_catalog_entries_path(:viewstate => @viewstate ? @viewstate.id : nil))
- @deployables = Deployable.list_for_user(current_user, Privilege::VIEW)
- @catalog_entries = @deployables.collect { |d| d.catalog_entries.first }
- #@catalog_entries = CatalogEntry.list_for_user(current_user, Privilege::VIEW).apply_filters(:preset_filter_id => params[:catalog_entries_preset_filter], :search_filter => params[:catalog_entries_search])
- @catalog = @catalog_entries.first.catalog unless @catalog_entries.empty?
- set_header
- end
-
- def new
- @catalog_entry = params[:catalog_entry].nil? ? CatalogEntry.new() : CatalogEntry.new(params[:catalog_entry])
- @catalog_entry.deployable = Deployable.new unless @catalog_entry.deployable
- require_privilege(Privilege::CREATE, Deployable)
- if params[:create_from_image]
- @image = Aeolus::Image::Warehouse::Image.find(params[:create_from_image])
- @hw_profiles = HardwareProfile.frontend.list_for_user(current_user, Privilege::VIEW)
- @catalog_entry.deployable.name = @image.name
- load_catalogs
- else
- @catalog = Catalog.find(params[:catalog_id])
- require_privilege(Privilege::MODIFY, @catalog)
- end
- @form_option= params.has_key?(:from_url) ? 'from_url' : 'upload'
- respond_to do |format|
- format.html
- format.js {render :partial => @form_option}
- end
- end
-
- def show
- @catalog_entry = CatalogEntry.find(params[:id])
- require_privilege(Privilege::VIEW, @catalog_entry.deployable)
- save_breadcrumb(catalog_catalog_entry_path((a)catalog_entry.catalog, @catalog_entry), @catalog_entry.deployable.name)
- @providers = Provider.all
- @catalogs_options = Catalog.all.map {|c| [c.name, c.id]}
- add_permissions_inline((a)catalog_entry.deployable)
- end
def create
- if params[:cancel]
- redirect_to catalog_catalog_entries_path
- return
- end
-
-
@catalog_entry = CatalogEntry.new(params[:catalog_entry])
- if params[:create_from_image].present?
- @catalog = @catalog_entry.catalog
- @catalog_entry.deployable = Deployable.new unless @catalog_entry.deployable
- else
- @catalog = Catalog.find(params[:catalog_id])
- @catalog_entry.catalog = @catalog
- end
- require_privilege(Privilege::MODIFY, @catalog)
- require_privilege(Privilege::CREATE, Deployable)
- @catalog_entry.deployable.owner = current_user
-
- if params.has_key? :url
- xml = import_xml_from_url(params[:url])
- unless xml.nil?
- #store xml_filename for url (i.e. url ends to: foo || foo.xml)
- @catalog_entry.deployable.xml_filename = File.basename(URI.parse(params[:url]).path)
- @catalog_entry.deployable.xml = xml
- end
- elsif params[:create_from_image].present?
- hw_profile = HardwareProfile.frontend.find(params[:hardware_profile])
- require_privilege(Privilege::VIEW, hw_profile)
- @catalog_entry.deployable.set_from_image(params[:create_from_image], hw_profile)
- end
-
- if @catalog_entry.save
- flash[:notice] = t "catalog_entries.flash.notice.added"
- if params[:edit_xml]
- redirect_to edit_catalog_catalog_entry_path @catalog_entry.catalog.id, @catalog_entry.id, :edit_xml =>true
- else
- redirect_to catalog_catalog_entries_path(@catalog)
- end
- else
- flash[:warning]= t('catalog_entries.flash.warning.not_valid') if @catalog_entry.errors.has_key?(:xml)
- if params[:create_from_image].present?
- load_catalogs
- @image = Aeolus::Image::Warehouse::Image.find(params[:create_from_image])
- @hw_profiles = HardwareProfile.frontend.list_for_user(current_user, Privilege::VIEW)
- @catalog_entry.deployable.name = @image.name
- else
- params.delete(:edit_xml) if params[:edit_xml]
- @form_option = params[:catalog_entry].has_key?(:xml) ? 'upload' : 'from_url'
- @form_option = params[:catalog_entry][:deployable].has_key?(:xml) ? 'upload' : 'from_url'
- end
- render :new
- end
- end
-
- def edit
- @catalog_entry = CatalogEntry.find(params[:id])
- require_privilege(Privilege::MODIFY, @catalog_entry.deployable)
- @catalog = @catalog_entry.catalog
- end
-
- def update
- @catalog_entry = CatalogEntry.find(params[:id])
+ require_privilege(Privilege::MODIFY, @catalog_entry.catalog)
require_privilege(Privilege::MODIFY, @catalog_entry.deployable)
- params[:catalog_entry][:deployable].delete(:owner_id) if params[:catalog_entry] and params[:catalog_entry][:deployable]
- if @catalog_entry.update_attributes(params[:catalog_entry])
- flash[:notice] = t"catalog_entries.flash.notice.updated"
- redirect_to catalog_catalog_entry_path((a)catalog_entry.catalog, @catalog_entry)
+ if @catalog_entry.save
+ redirect_to catalog_deployable_path((a)catalog_entry.catalog, @catalog_entry.deployable), :notice => t('catalog_entries.flash.notice.added')
else
- render :action => 'edit'
+ flash[:warning] = t('catalog_entries.flash.warning.failed')
+ redirect_to catalog_deployable_path((a)catalog_entry.deployable.catalogs.first, @catalog_entry.deployable)
end
end
- def multi_destroy
- @catalog = nil
- CatalogEntry.find(params[:catalog_entries_selected]).to_a.each do |d|
- require_privilege(Privilege::MODIFY, d.catalog)
- require_privilege(Privilege::MODIFY, d.deployable)
- @catalog = d.catalog
- # Don't do this when we're managing deployables independently
- d.deployable.destroy
- d.destroy
- end
- redirect_to catalog_path(@catalog)
- end
-
- def destroy
- catalog_entry = CatalogEntry.find(params[:id])
- require_privilege(Privilege::MODIFY, catalog_entry.catalog)
- require_privilege(Privilege::MODIFY, catalog_entry.deployable)
- @catalog = catalog_entry.catalog
- # Don't do this when we're managing deployables independently
- catalog_entry.deployable.destroy
- catalog_entry.destroy
-
- respond_to do |format|
- format.html { redirect_to catalog_path(@catalog) }
- end
- end
-
- def filter
- original_path = Rails.application.routes.recognize_path(params[:current_path])
- original_params = Rack::Utils.parse_nested_query(URI.parse(params[:current_path]).query)
- redirect_to original_path.merge(original_params).merge("catalog_entries_preset_filter" => params[:catalog_entries_preset_filter], "catalog_entries_search" => params[:catalog_entries_search])
- end
-
- private
-
- def set_header
- @header = [
- { :name => 'checkbox', :class => 'checkbox', :sortable => false },
- { :name => t("catalog_entries.index.name"), :sort_attr => :name },
- { :name => t("catalogs.index.catalog_name"), :sortable => false },
- { :name => t("catalog_entries.index.deployable_xml"), :sortable => :url }
- ]
- end
-
- def load_catalogs
- @catalogs = Catalog.list_for_user(current_user, Privilege::MODIFY)
- end
-
- def import_xml_from_url(url)
- begin
- response = RestClient.get(url, :accept => :xml)
- if response.code == 200
- response
- end
- rescue RestClient::Exception, SocketError, URI::InvalidURIError
- flash[:error] = t('catalog_entries.flash.warning.not_valid_or_reachable', :url => url)
- nil
- end
- end
end
diff --git a/src/app/controllers/deployables_controller.rb b/src/app/controllers/deployables_controller.rb
index 6e96439..9c19932 100644
--- a/src/app/controllers/deployables_controller.rb
+++ b/src/app/controllers/deployables_controller.rb
@@ -15,11 +15,181 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA. A copy of the GNU General Public License is
# also available at http://www.gnu.org/copyleft/gpl.html.
+require 'uri'
class DeployablesController < ApplicationController
+ before_filter :require_user
+
+ def index
+ clear_breadcrumbs
+ save_breadcrumb(catalog_deployables_path(:viewstate => @viewstate ? @viewstate.id : nil))
+ @deployables = Deployable.list_for_user(current_user, Privilege::VIEW)
+ @catalog_entries = @deployables.collect { |d| d.catalog_entries.first }
+ #@catalog_entries = CatalogEntry.list_for_user(current_user, Privilege::VIEW).apply_filters(:preset_filter_id => params[:catalog_entries_preset_filter], :search_filter => params[:catalog_entries_search])
+ @catalog = @catalog_entries.first.catalog unless @catalog_entries.empty?
+ set_header
+ end
+
+ def new
+ @catalog_entry = params[:catalog_entry].nil? ? CatalogEntry.new() : CatalogEntry.new(params[:catalog_entry])
+ @catalog_entry.deployable = Deployable.new unless @catalog_entry.deployable
+ require_privilege(Privilege::CREATE, Deployable)
+ if params[:create_from_image]
+ @image = Aeolus::Image::Warehouse::Image.find(params[:create_from_image])
+ @hw_profiles = HardwareProfile.frontend.list_for_user(current_user, Privilege::VIEW)
+ @catalog_entry.deployable.name = @image.name
+ load_catalogs
+ else
+ @catalog = Catalog.find(params[:catalog_id])
+ require_privilege(Privilege::MODIFY, @catalog)
+ end
+ @form_option= params.has_key?(:from_url) ? 'from_url' : 'upload'
+ respond_to do |format|
+ format.html
+ format.js {render :partial => @form_option}
+ end
+ end
+
def show
- flash.keep
- @deployable = Deployable.find(params[:id])
- redirect_to catalog_entry_path((a)deployable.catalog_entries.first)
+ @catalog_entry = CatalogEntry.find(params[:id])
+ require_privilege(Privilege::VIEW, @catalog_entry.deployable)
+ save_breadcrumb(catalog_deployable_path((a)catalog_entry.catalog, @catalog_entry), @catalog_entry.deployable.name)
+ @providers = Provider.all
+ @catalogs_options = Catalog.all.map {|c| [c.name, c.id]}
+ add_permissions_inline((a)catalog_entry.deployable)
+ end
+
+ def create
+ if params[:cancel]
+ redirect_to catalog_deployables_path
+ return
+ end
+
+
+ @catalog_entry = CatalogEntry.new(params[:catalog_entry])
+ if params[:create_from_image].present?
+ @catalog = @catalog_entry.catalog
+ @catalog_entry.deployable = Deployable.new unless @catalog_entry.deployable
+ else
+ @catalog = Catalog.find(params[:catalog_id])
+ @catalog_entry.catalog = @catalog
+ end
+ require_privilege(Privilege::MODIFY, @catalog)
+ require_privilege(Privilege::CREATE, Deployable)
+ @catalog_entry.deployable.owner = current_user
+
+ if params.has_key? :url
+ xml = import_xml_from_url(params[:url])
+ unless xml.nil?
+ #store xml_filename for url (i.e. url ends to: foo || foo.xml)
+ @catalog_entry.deployable.xml_filename = File.basename(URI.parse(params[:url]).path)
+ @catalog_entry.deployable.xml = xml
+ end
+ elsif params[:create_from_image].present?
+ hw_profile = HardwareProfile.frontend.find(params[:hardware_profile])
+ require_privilege(Privilege::VIEW, hw_profile)
+ @catalog_entry.deployable.set_from_image(params[:create_from_image], hw_profile)
+ end
+
+ if @catalog_entry.save
+ flash[:notice] = t "catalog_entries.flash.notice.added"
+ if params[:edit_xml]
+ redirect_to edit_catalog_deployable_path @catalog_entry.catalog.id, @catalog_entry.id, :edit_xml =>true
+ else
+ redirect_to catalog_deployables_path(@catalog)
+ end
+ else
+ flash[:warning]= t('catalog_entries.flash.warning.not_valid') if @catalog_entry.errors.has_key?(:xml)
+ if params[:create_from_image].present?
+ load_catalogs
+ @image = Aeolus::Image::Warehouse::Image.find(params[:create_from_image])
+ @hw_profiles = HardwareProfile.frontend.list_for_user(current_user, Privilege::VIEW)
+ @catalog_entry.deployable.name = @image.name
+ else
+ params.delete(:edit_xml) if params[:edit_xml]
+ @form_option = params[:catalog_entry].has_key?(:xml) ? 'upload' : 'from_url'
+ @form_option = params[:catalog_entry][:deployable].has_key?(:xml) ? 'upload' : 'from_url'
+ end
+ render :new
+ end
+ end
+
+ def edit
+ @catalog_entry = CatalogEntry.find(params[:id])
+ require_privilege(Privilege::MODIFY, @catalog_entry.deployable)
+ @catalog = @catalog_entry.catalog
+ end
+
+ def update
+ @catalog_entry = CatalogEntry.find(params[:id])
+ require_privilege(Privilege::MODIFY, @catalog_entry.deployable)
+ params[:catalog_entry][:deployable].delete(:owner_id) if params[:catalog_entry] and params[:catalog_entry][:deployable]
+
+ if @catalog_entry.update_attributes(params[:catalog_entry])
+ flash[:notice] = t"catalog_entries.flash.notice.updated"
+ redirect_to catalog_deployable_path((a)catalog_entry.catalog, @catalog_entry)
+ else
+ render :action => 'edit'
+ end
+ end
+
+ def multi_destroy
+ @catalog = nil
+ CatalogEntry.find(params[:catalog_entries_selected]).to_a.each do |d|
+ require_privilege(Privilege::MODIFY, d.catalog)
+ require_privilege(Privilege::MODIFY, d.deployable)
+ @catalog = d.catalog
+ # Don't do this when we're managing deployables independently
+ d.deployable.destroy
+ d.destroy
+ end
+ redirect_to catalog_path(@catalog)
+ end
+
+ def destroy
+ catalog_entry = CatalogEntry.find(params[:id])
+ require_privilege(Privilege::MODIFY, catalog_entry.catalog)
+ require_privilege(Privilege::MODIFY, catalog_entry.deployable)
+ @catalog = catalog_entry.catalog
+ # Don't do this when we're managing deployables independently
+ catalog_entry.deployable.destroy
+ catalog_entry.destroy
+
+ respond_to do |format|
+ format.html { redirect_to catalog_path(@catalog) }
+ end
+ end
+
+ def filter
+ original_path = Rails.application.routes.recognize_path(params[:current_path])
+ original_params = Rack::Utils.parse_nested_query(URI.parse(params[:current_path]).query)
+ redirect_to original_path.merge(original_params).merge("catalog_entries_preset_filter" => params[:catalog_entries_preset_filter], "catalog_entries_search" => params[:catalog_entries_search])
+ end
+
+ private
+
+ def set_header
+ @header = [
+ { :name => 'checkbox', :class => 'checkbox', :sortable => false },
+ { :name => t("catalog_entries.index.name"), :sort_attr => :name },
+ { :name => t("catalogs.index.catalog_name"), :sortable => false },
+ { :name => t("catalog_entries.index.deployable_xml"), :sortable => :url }
+ ]
+ end
+
+ def load_catalogs
+ @catalogs = Catalog.list_for_user(current_user, Privilege::MODIFY)
+ end
+
+ def import_xml_from_url(url)
+ begin
+ response = RestClient.get(url, :accept => :xml)
+ if response.code == 200
+ response
+ end
+ rescue RestClient::Exception, SocketError, URI::InvalidURIError
+ flash[:error] = t('catalog_entries.flash.warning.not_valid_or_reachable', :url => url)
+ nil
+ end
end
end
diff --git a/src/app/models/catalog_entry.rb b/src/app/models/catalog_entry.rb
index 69c67b6..21a8b9b 100644
--- a/src/app/models/catalog_entry.rb
+++ b/src/app/models/catalog_entry.rb
@@ -39,6 +39,8 @@ class CatalogEntry < ActiveRecord::Base
validates_presence_of :catalog
validates_presence_of :deployable
+ validates_uniqueness_of :catalog_id, :scope => [:deployable_id]
+
# This probably goes away once we separate catalog entry creation from deployables
accepts_nested_attributes_for :deployable
PRESET_FILTERS_OPTIONS = []
diff --git a/src/app/views/catalog_entries/_form.html.haml b/src/app/views/catalog_entries/_form.html.haml
deleted file mode 100644
index 5c8b2bb..0000000
--- a/src/app/views/catalog_entries/_form.html.haml
+++ /dev/null
@@ -1,27 +0,0 @@
-- if @catalog_entry.errors.any?
- = render 'layouts/error_messages', :object => @catalog_entry
-%fieldset
- - if params[:edit_xml]
- = form.fields_for :deployable, @catalog_entry.deployable do |deployable_fields|
- %p
- = deployable_fields.label :xml, t('.deployable_xml')
- = deployable_fields.text_area :xml, :class => 'long'
- - else
- %p
- = form.label :catalog_id, t('catalog_entries.form.catalog')
- = @catalog.name
- .clear
- = form.fields_for :deployable, @catalog_entry.deployable do |deployable_fields|
- %p
- = deployable_fields.label :name, t('catalog_entries.index.name')
- = deployable_fields.text_field :name, :class => 'em long'
- %p
- = deployable_fields.label :description, t('.description')
- = deployable_fields.text_area :description, :class => 'long'
- %p
- = deployable_fields.label :xml, t('.deployable_xml')
- = link_to t("catalog_entries.properties.edit_deployable_xml"), edit_catalog_catalog_entry_path((a)catalog_entry.catalog.id, @catalog_entry.id, :edit_xml=>true)
-
-%fieldset.options
- = link_to t('cancel'), catalog_path(@catalog), :class => 'button danger'
- = submit_tag t('save'), :name => 'save', :class => 'button', :id => 'save_button'
diff --git a/src/app/views/catalog_entries/_from_url.html.haml b/src/app/views/catalog_entries/_from_url.html.haml
deleted file mode 100644
index 4d9b583..0000000
--- a/src/app/views/catalog_entries/_from_url.html.haml
+++ /dev/null
@@ -1,27 +0,0 @@
-= form_for @catalog_entry, :url => catalog_catalog_entries_path(@catalog), :html => {:class => 'generic', :multipart => true } do |form|
- - if @catalog_entry.errors.any?
- = render 'layouts/error_messages', :object => @catalog_entry
- %fieldset
- %p
- = form.label :catalog_id, t('catalog_entries.form.catalog')
- = @catalog.name
- .clear
- =form.fields_for :deployable, @catalog_entry.deployable do |deployable_fields|
- %fieldset
- %p
- = deployable_fields.label :name, t('catalog_entries.index.name')
- = deployable_fields.text_field :name, :class => 'em long'
- %p
- = deployable_fields.label :description, t('catalog_entries.form.description')
- = deployable_fields.text_area :description, :class => 'long'
- %fieldset
- %p
- = label_tag :url, t('catalog_entries.form.deployable_xml_url')
- = text_field_tag :url
- %p
- = check_box_tag(:edit_xml, true, false)
- = label_tag :edit_xml, t('catalog_entries.form.edit_xml_after_save')
-
- %fieldset.options
- = link_to t('cancel'), catalog_path(@catalog), :class => 'button danger'
- = submit_tag t('save'), :name => 'save', :class => 'button', :id => 'save_button'
diff --git a/src/app/views/catalog_entries/_list.html.haml b/src/app/views/catalog_entries/_list.html.haml
deleted file mode 100644
index 31e8481..0000000
--- a/src/app/views/catalog_entries/_list.html.haml
+++ /dev/null
@@ -1,38 +0,0 @@
-%section.admin-content-section
- %header
- %h2=t'catalog_entries.list.catalog_entries_list'
-
- .content
- - content_for :form_header do
- %li= restful_submit_tag t("catalog_entries.show.delete"), "destroy", multi_destroy_catalog_catalog_entries_path(@catalog), 'DELETE', :id => 'delete_button', :class => 'button danger'
-
- - content_for :filter_controls do
- %li
- = label_tag :catalog_entries_preset_filter, t('filter_table.viewing')
- = hidden_field_tag :current_path, request.fullpath
- = select_tag(:catalog_entries_preset_filter, preset_filters_options_for_select(CatalogEntry::PRESET_FILTERS_OPTIONS, params[:catalog_entries_preset_filter]), :include_blank => t("catalog_entries.preset_filters.all_catalog_entries"), :disabled => true)
- = restful_submit_tag t("filter_table.apply_filters"), "filter", filter_catalog_catalog_entries_path(@catalog), 'POST', :class => 'button', :id => 'apply_catalog_entries_preset_filter'
- %span.label.badge.dark= @catalog_entries.count
- %li.table-search-filter
- = text_field_tag :catalog_entries_search, params[:catalog_entries_search], :placeholder => t("filter_table.search")
- = restful_submit_tag "", "search", filter_catalog_catalog_entries_path(@catalog), 'POST', :class => 'button', :id => 'apply_catalog_entries_search'
-
- :javascript
- $(document).ready(function(){
- $("#apply_catalog_entries_preset_filter").hide();
- $("#catalog_entries_preset_filter").change(function() {
- $("#apply_catalog_entries_preset_filter").click();
- });
- });
-
- = filter_table(@header, @catalog_entries) do |catalog_entry|
- %tr{:class => cycle('nostripe','stripe')}
- %td{:class => 'checkbox'}
- - selected = params[:select] == 'all'
- = check_box_tag "catalog_entries_selected[]", catalog_entry.id, selected, :id => "catalog_entry_checkbox_#{catalog_entry.id}"
- %td
- = link_to catalog_entry.deployable.name, catalog_catalog_entry_path(@catalog, catalog_entry.id)
- %td
- = link_to catalog_entry.catalog.name, catalog_entry.catalog
- %td
- = link_to catalog_entry.deployable.xml_filename, catalog_catalog_entry_path(@catalog, catalog_entry.id)
diff --git a/src/app/views/catalog_entries/_new.html.haml b/src/app/views/catalog_entries/_new.html.haml
deleted file mode 100644
index c66ca64..0000000
--- a/src/app/views/catalog_entries/_new.html.haml
+++ /dev/null
@@ -1,65 +0,0 @@
-= render :partial => 'section_header'
-
-%section.admin-content-section
- %header
- %h2=t'catalog_entries.new.add_catalog_entry'
-
-%section.admin-content-section.image-upload
- %p.description=t'.choose_option_to_upload'
-
- %nav#image-upload-tabs.faceted
- %ul.tabs
- %li
- = link_to t('catalog_entries.new.upload'), new_catalog_catalog_entry_path(@catalog), :id => "upload", :class => "#{'selected' if @form_option == 'upload'}"
- %li
- = link_to t('catalog_entries.new.from_url'), new_catalog_catalog_entry_path(@catalog, :from_url => true), :id => "from_url", :class => "#{'selected' if @form_option == 'from_url'}"
-
- .form_option
- = render :partial => @form_option
-
-:javascript
- $(document).ready(function() {
- $("a#upload").click(function(ev){
- var entry_name = read_name_field();
- var entry_description = read_description_field();
- var $clicked_element = $(this)
- ev.preventDefault();
- $.get('#{new_catalog_catalog_entry_url(@catalog)}', function(data){
- change_selected($clicked_element, $('a#from_url'));
- $('.form_option').empty();
- $('.form_option').html(data).show();
- $('input#catalog_entry_name').val(entry_name);
- $('textarea#catalog_entry_description').val(entry_description);
- });
- });
- $("a#from_url").click(function(ev){
- var entry_name = read_name_field();
- var entry_description = read_description_field();
- var $clicked_element = $(this)
- ev.preventDefault();
- $.get('#{new_catalog_catalog_entry_url(@catalog, :from_url => true)}', function(data){
- change_selected($clicked_element, $("a#upload"));
- $('.form_option').empty();
- $('.form_option').html(data).show();
- $('input#catalog_entry_name').val(entry_name);
- $('textarea#catalog_entry_description').val(entry_description);
- });
- });
- });
-
- function change_selected($add_selected, $remove_selected){
- $remove_selected.removeClass('selected');
- $add_selected.addClass('selected');
- }
-
- function read_name_field() {
- if ($('input#catalog_entry_name').val()) {
- return $('input#catalog_entry_name').val();
- }
- }
-
- function read_description_field() {
- if ($('textarea#catalog_entry_description').val()) {
- return $('textarea#catalog_entry_description').val();
- }
- }
diff --git a/src/app/views/catalog_entries/_new_from_image.html.haml b/src/app/views/catalog_entries/_new_from_image.html.haml
deleted file mode 100644
index 81215e5..0000000
--- a/src/app/views/catalog_entries/_new_from_image.html.haml
+++ /dev/null
@@ -1,24 +0,0 @@
-%section.admin-content-section
- %header.admin-page-header
- %h2=t('.catalog_entry_name', :name => @catalog_entry.deployable.name)
-
- .content
- = form_for @catalog_entry, :html => {:class => 'generic'} do |form|
- = hidden_field_tag :create_from_image, params[:create_from_image]
- - if @catalog_entry.errors.any?
- = render 'layouts/error_messages', :object => @catalog_entry
- %fieldset
- %p
- %h2
- =t('.title')
- =t('.description', :name => @image.name)
- %p
- = form.label :name, t('catalog_entries.new.hw_profile')
- = select_tag :hardware_profile, options_from_collection_for_select(@hw_profiles, :id, :name, params[:hardware_profile])
- %p
- = form.label :catalog_id, t('catalog_entries.form.catalog')
- = form.select :catalog_id, @catalogs.collect{|c| [c.name, c.id]}
-
- %fieldset.options
- = link_to "#{t'catalog_entries.form.cancel'}", catalogs_path, :class => 'button danger'
- = submit_tag "#{t'catalog_entries.form.save'}", :name => 'save', :class => 'button', :id => 'save_button'
diff --git a/src/app/views/catalog_entries/_section_header.html.haml b/src/app/views/catalog_entries/_section_header.html.haml
deleted file mode 100644
index 2adf689..0000000
--- a/src/app/views/catalog_entries/_section_header.html.haml
+++ /dev/null
@@ -1,4 +0,0 @@
-%header.admin-page-header
- %h1{:class => controller.controller_name}=t'catalog_entries.index.catalog_entries'
- #obj_actions.button-group
- = link_to "#{t'catalog_entries.new_catalog_entry'}", new_catalog_catalog_entry_url(@catalog), :class => 'button primary', :id => 'new_catalog_entry_button'
diff --git a/src/app/views/catalog_entries/_upload.html.haml b/src/app/views/catalog_entries/_upload.html.haml
deleted file mode 100644
index 73c7d28..0000000
--- a/src/app/views/catalog_entries/_upload.html.haml
+++ /dev/null
@@ -1,27 +0,0 @@
-= form_for @catalog_entry, :url => catalog_catalog_entries_path(@catalog), :html => {:class => 'generic', :multipart => true } do |form|
- - if @catalog_entry.errors.any?
- = render 'layouts/error_messages', :object => @catalog_entry
- %fieldset
- %p
- = form.label :catalog_id, t('catalog_entries.form.catalog')
- = @catalog.name
- .clear
- = form.fields_for :deployable, @catalog_entry.deployable do |deployable_fields|
- %fieldset
- %p
- = deployable_fields.label :name, t('catalog_entries.index.name')
- = deployable_fields.text_field :name, :class => 'em long'
- %p
- = deployable_fields.label :description, t('catalog_entries.form.description')
- = deployable_fields.text_area :description, :class => 'long'
- %p
- = deployable_fields.label :xml, t('catalog_entries.form.choose_xml')
- = deployable_fields.file_field :xml
- %fieldset
- %p
- = check_box_tag(:edit_xml, true, false)
- = label_tag :edit_xml, t('catalog_entries.form.edit_xml_after_save')
-
- %fieldset.options
- = link_to t('cancel'), catalog_path(@catalog), :class => 'button danger'
- = submit_tag t('save'), :name => 'save', :class => 'button', :id => 'save_button'
diff --git a/src/app/views/catalog_entries/edit.html.haml b/src/app/views/catalog_entries/edit.html.haml
deleted file mode 100644
index 7737b68..0000000
--- a/src/app/views/catalog_entries/edit.html.haml
+++ /dev/null
@@ -1,15 +0,0 @@
-= render :partial => 'layouts/admin_nav'
-%header.admin-page-header
- %h1{:class => controller.controller_name}= @catalog_entry.deployable.name
- #obj_actions.button-container
- = link_to 'New Deployable', new_catalog_catalog_entry_path((a)catalog_entry.catalog, @catalog_entry), :class => 'button primary', :id => 'new_deployable_button'
- .button-group
- = link_to 'Cancel Editing', catalog_catalog_entries_path((a)catalog_entry.catalog), :class => 'button pill danger', :id => 'new_deployable_button'
-
-%section.admin-content-section.user
- %header
- %h2=t'catalog_entries.edit.editing_catalog_entry'
-
- .content
- = form_for @catalog_entry, :url => catalog_catalog_entry_path((a)catalog_entry.catalog, @catalog_entry), :html => { :method => :put, :class => 'generic' } do |f|
- = render :partial => "form", :locals => { :form => f }
diff --git a/src/app/views/catalog_entries/index.html.haml b/src/app/views/catalog_entries/index.html.haml
deleted file mode 100644
index 3fae6b6..0000000
--- a/src/app/views/catalog_entries/index.html.haml
+++ /dev/null
@@ -1,3 +0,0 @@
-= render :partial => 'layouts/admin_nav'
-= render :partial => 'section_header'
-= render :partial => 'list'
diff --git a/src/app/views/catalog_entries/new.html.haml b/src/app/views/catalog_entries/new.html.haml
deleted file mode 100644
index 893345f..0000000
--- a/src/app/views/catalog_entries/new.html.haml
+++ /dev/null
@@ -1,2 +0,0 @@
-= render :partial => 'layouts/admin_nav'
-= render :partial => params[:create_from_image] ? 'new_from_image' : 'new'
diff --git a/src/app/views/catalog_entries/show.html.haml b/src/app/views/catalog_entries/show.html.haml
deleted file mode 100644
index 177d494..0000000
--- a/src/app/views/catalog_entries/show.html.haml
+++ /dev/null
@@ -1,58 +0,0 @@
-= render :partial => 'layouts/admin_nav'
-%header.admin-page-header
- %h1{:class => controller.controller_name}= @catalog_entry.deployable.name
- #obj_actions.button-container
- .button-group
- = button_to t('catalog_entries.show.delete'), catalog_catalog_entry_path((a)catalog_entry.catalog, @catalog_entry), :method => 'delete', :confirm => "#{t'catalog_entries.show.confirm_delete'}", :class => 'button danger', :id => 'delete'
- = link_to t('catalog_entries.show.edit'), edit_catalog_catalog_entry_path((a)catalog_entry.catalog, @catalog_entry), :class => 'button', :id => 'edit_button'
-
- = link_to t('deployments.overview.launch'), launch_new_deployments_path(:deployable_id => @catalog_entry.deployable.id, :pool_id => @catalog_entry.catalog.pool), :id => :launch_deployment
-
-%section.admin-content-section.deployable
- %section.image
- %header
- %h2= t('.image')
- %pre= @catalog_entry.deployable.xml
-
-
- %section.build
- %header
- %h2= t('.build')
-
- = form_tag() do
- = select_tag :build_option, options_for_select([[t("rebuild_all"), 1]])
- = submit_tag t('.start'), :id => :start_build
-
- %p.description= t('.build_description')
-
- %ul#providers-list
- - @providers.each do |provider|
- %li
- %span.provider= provider.name
- %span.status Building 98%
- = form_tag()
- %button on/off
-
-
- %section.catalogs
- %header
- %h2= t('.catalogs')
-
- %p= t('.choose_catalog')
- = form_tag() do
- = select_tag :catalog, options_for_select(@catalogs_options)
- = submit_tag t('.add_catalog'), :id => :add_catalog
-
- %p
- %label= t('.catalog_name')
- = @catalog_entry.catalog.name
- %p
- %label= t('.environment')
- = @catalog_entry.catalog.pool.pool_family.name
-
-
- - if check_privilege(Privilege::PERM_VIEW,@permission_object)
- %section.roles
- %header
- %h2= t('users.users')
- = render :partial => 'permissions/permissions'
diff --git a/src/app/views/catalogs/show.html.haml b/src/app/views/catalogs/show.html.haml
index 6bb4819..4ba4b5b 100644
--- a/src/app/views/catalogs/show.html.haml
+++ b/src/app/views/catalogs/show.html.haml
@@ -20,19 +20,19 @@
.content
- content_for :form_header do
- %li= restful_submit_tag t("delete"), "destroy", multi_destroy_catalog_catalog_entries_path(@catalog), 'DELETE', :id => 'delete_button', :class => 'button danger'
- %li= link_to t("catalog_entries.new_catalog_entry"), new_catalog_catalog_entry_path(@catalog), :class => 'button', :id => 'new_catalog_entry_button'
+ %li= restful_submit_tag t("delete"), "destroy", multi_destroy_catalog_deployables_path(@catalog), 'DELETE', :id => 'delete_button', :class => 'button danger'
+ %li= link_to t("catalog_entries.new_catalog_entry"), new_catalog_deployable_path(@catalog), :class => 'button', :id => 'new_catalog_entry_button'
- content_for :filter_controls do
%li
= label_tag :catalog_entries_preset_filter, t('filter_table.viewing')
= hidden_field_tag :current_path, request.fullpath
= select_tag(:catalog_entries_preset_filter, preset_filters_options_for_select(CatalogEntry::PRESET_FILTERS_OPTIONS, params[:catalog_entries_preset_filter]), :include_blank => t("catalog_entries.preset_filters.all_catalog_entries"), :disabled => true)
- = restful_submit_tag t("filter_table.apply_filters"), "filter", filter_catalog_catalog_entries_path(@catalog), 'POST', :class => 'button', :id => 'apply_catalog_entries_preset_filter'
+ = restful_submit_tag t("filter_table.apply_filters"), "filter", filter_catalog_deployables_path(@catalog), 'POST', :class => 'button', :id => 'apply_catalog_entries_preset_filter'
%span.label.badge.dark= @catalog_entries.count
%li.table-search-filter
= text_field_tag :catalog_entries_search, params[:catalog_entries_search], :placeholder => t("filter_table.search")
- = restful_submit_tag "", "search", filter_catalog_catalog_entries_path(@catalog), 'POST', :class => 'button', :id => 'apply_catalog_entries_search'
+ = restful_submit_tag "", "search", filter_catalog_deployables_path(@catalog), 'POST', :class => 'button', :id => 'apply_catalog_entries_search'
:javascript
$(document).ready(function(){
@@ -48,6 +48,6 @@
- selected = params[:select] == 'all'
= check_box_tag "catalog_entries_selected[]", catalog_entry.id, selected, :id => "catalog_entry_checkbox_#{catalog_entry.id}"
%td
- = link_to catalog_entry.deployable.name, catalog_catalog_entry_path(@catalog, catalog_entry.id)
+ = link_to catalog_entry.deployable.name, catalog_deployable_path(@catalog, catalog_entry.deployable)
%td
- = link_to catalog_entry.deployable.xml_filename, catalog_catalog_entry_path(@catalog, catalog_entry.id, :deployable_xml => true)
+ = link_to catalog_entry.deployable.xml_filename, catalog_deployable_path(@catalog, catalog_entry.deployable, :deployable_xml => true)
diff --git a/src/app/views/deployables/_form.html.haml b/src/app/views/deployables/_form.html.haml
new file mode 100644
index 0000000..bbf0b25
--- /dev/null
+++ b/src/app/views/deployables/_form.html.haml
@@ -0,0 +1,27 @@
+- if @catalog_entry.errors.any?
+ = render 'layouts/error_messages', :object => @catalog_entry
+%fieldset
+ - if params[:edit_xml]
+ = form.fields_for :deployable, @catalog_entry.deployable do |deployable_fields|
+ %p
+ = deployable_fields.label :xml, t('.deployable_xml')
+ = deployable_fields.text_area :xml, :class => 'long'
+ - else
+ %p
+ = form.label :catalog_id, t('catalog_entries.form.catalog')
+ = @catalog.name
+ .clear
+ = form.fields_for :deployable, @catalog_entry.deployable do |deployable_fields|
+ %p
+ = deployable_fields.label :name, t('catalog_entries.index.name')
+ = deployable_fields.text_field :name, :class => 'em long'
+ %p
+ = deployable_fields.label :description, t('.description')
+ = deployable_fields.text_area :description, :class => 'long'
+ %p
+ = deployable_fields.label :xml, t('.deployable_xml')
+ = link_to t("catalog_entries.properties.edit_deployable_xml"), edit_catalog_deployable_path((a)catalog_entry.catalog.id, @catalog_entry.id, :edit_xml=>true)
+
+%fieldset.options
+ = link_to t('cancel'), catalog_path(@catalog), :class => 'button danger'
+ = submit_tag t('save'), :name => 'save', :class => 'button', :id => 'save_button'
diff --git a/src/app/views/deployables/_from_url.html.haml b/src/app/views/deployables/_from_url.html.haml
new file mode 100644
index 0000000..439d23e
--- /dev/null
+++ b/src/app/views/deployables/_from_url.html.haml
@@ -0,0 +1,27 @@
+= form_for @catalog_entry, :url => catalog_deployables_path(@catalog), :html => {:class => 'generic', :multipart => true } do |form|
+ - if @catalog_entry.errors.any?
+ = render 'layouts/error_messages', :object => @catalog_entry
+ %fieldset
+ %p
+ = form.label :catalog_id, t('catalog_entries.form.catalog')
+ = @catalog.name
+ .clear
+ =form.fields_for :deployable, @catalog_entry.deployable do |deployable_fields|
+ %fieldset
+ %p
+ = deployable_fields.label :name, t('catalog_entries.index.name')
+ = deployable_fields.text_field :name, :class => 'em long'
+ %p
+ = deployable_fields.label :description, t('catalog_entries.form.description')
+ = deployable_fields.text_area :description, :class => 'long'
+ %fieldset
+ %p
+ = label_tag :url, t('catalog_entries.form.deployable_xml_url')
+ = text_field_tag :url
+ %p
+ = check_box_tag(:edit_xml, true, false)
+ = label_tag :edit_xml, t('catalog_entries.form.edit_xml_after_save')
+
+ %fieldset.options
+ = link_to t('cancel'), catalog_path(@catalog), :class => 'button danger'
+ = submit_tag t('save'), :name => 'save', :class => 'button', :id => 'save_button'
diff --git a/src/app/views/deployables/_list.html.haml b/src/app/views/deployables/_list.html.haml
new file mode 100644
index 0000000..117e636
--- /dev/null
+++ b/src/app/views/deployables/_list.html.haml
@@ -0,0 +1,38 @@
+%section.admin-content-section
+ %header
+ %h2=t'catalog_entries.list.catalog_entries_list'
+
+ .content
+ - content_for :form_header do
+ %li= restful_submit_tag t("catalog_entries.show.delete"), "destroy", multi_destroy_catalog_deployables_path(@catalog), 'DELETE', :id => 'delete_button', :class => 'button danger'
+
+ - content_for :filter_controls do
+ %li
+ = label_tag :catalog_entries_preset_filter, t('filter_table.viewing')
+ = hidden_field_tag :current_path, request.fullpath
+ = select_tag(:catalog_entries_preset_filter, preset_filters_options_for_select(CatalogEntry::PRESET_FILTERS_OPTIONS, params[:catalog_entries_preset_filter]), :include_blank => t("catalog_entries.preset_filters.all_catalog_entries"), :disabled => true)
+ = restful_submit_tag t("filter_table.apply_filters"), "filter", filter_catalog_deployables_path(@catalog), 'POST', :class => 'button', :id => 'apply_catalog_entries_preset_filter'
+ %span.label.badge.dark= @catalog_entries.count
+ %li.table-search-filter
+ = text_field_tag :catalog_entries_search, params[:catalog_entries_search], :placeholder => t("filter_table.search")
+ = restful_submit_tag "", "search", filter_catalog_deployables_path(@catalog), 'POST', :class => 'button', :id => 'apply_catalog_entries_search'
+
+ :javascript
+ $(document).ready(function(){
+ $("#apply_catalog_entries_preset_filter").hide();
+ $("#catalog_entries_preset_filter").change(function() {
+ $("#apply_catalog_entries_preset_filter").click();
+ });
+ });
+
+ = filter_table(@header, @catalog_entries) do |catalog_entry|
+ %tr{:class => cycle('nostripe','stripe')}
+ %td{:class => 'checkbox'}
+ - selected = params[:select] == 'all'
+ = check_box_tag "catalog_entries_selected[]", catalog_entry.id, selected, :id => "catalog_entry_checkbox_#{catalog_entry.id}"
+ %td
+ = link_to catalog_entry.deployable.name, catalog_deployable_path(@catalog, catalog_entry.id)
+ %td
+ = link_to catalog_entry.catalog.name, catalog_entry.catalog
+ %td
+ = link_to catalog_entry.deployable.xml_filename, catalog_deployable_path(@catalog, catalog_entry.id)
diff --git a/src/app/views/deployables/_new.html.haml b/src/app/views/deployables/_new.html.haml
new file mode 100644
index 0000000..a1d1589
--- /dev/null
+++ b/src/app/views/deployables/_new.html.haml
@@ -0,0 +1,65 @@
+= render :partial => 'section_header'
+
+%section.admin-content-section
+ %header
+ %h2=t'catalog_entries.new.add_catalog_entry'
+
+%section.admin-content-section.image-upload
+ %p.description=t'.choose_option_to_upload'
+
+ %nav#image-upload-tabs.faceted
+ %ul.tabs
+ %li
+ = link_to t('catalog_entries.new.upload'), new_catalog_deployable_path(@catalog), :id => "upload", :class => "#{'selected' if @form_option == 'upload'}"
+ %li
+ = link_to t('catalog_entries.new.from_url'), new_catalog_deployable_path(@catalog, :from_url => true), :id => "from_url", :class => "#{'selected' if @form_option == 'from_url'}"
+
+ .form_option
+ = render :partial => @form_option
+
+:javascript
+ $(document).ready(function() {
+ $("a#upload").click(function(ev){
+ var entry_name = read_name_field();
+ var entry_description = read_description_field();
+ var $clicked_element = $(this)
+ ev.preventDefault();
+ $.get('#{new_catalog_deployable_url(@catalog)}', function(data){
+ change_selected($clicked_element, $('a#from_url'));
+ $('.form_option').empty();
+ $('.form_option').html(data).show();
+ $('input#catalog_entry_name').val(entry_name);
+ $('textarea#catalog_entry_description').val(entry_description);
+ });
+ });
+ $("a#from_url").click(function(ev){
+ var entry_name = read_name_field();
+ var entry_description = read_description_field();
+ var $clicked_element = $(this)
+ ev.preventDefault();
+ $.get('#{new_catalog_deployable_url(@catalog, :from_url => true)}', function(data){
+ change_selected($clicked_element, $("a#upload"));
+ $('.form_option').empty();
+ $('.form_option').html(data).show();
+ $('input#catalog_entry_name').val(entry_name);
+ $('textarea#catalog_entry_description').val(entry_description);
+ });
+ });
+ });
+
+ function change_selected($add_selected, $remove_selected){
+ $remove_selected.removeClass('selected');
+ $add_selected.addClass('selected');
+ }
+
+ function read_name_field() {
+ if ($('input#catalog_entry_name').val()) {
+ return $('input#catalog_entry_name').val();
+ }
+ }
+
+ function read_description_field() {
+ if ($('textarea#catalog_entry_description').val()) {
+ return $('textarea#catalog_entry_description').val();
+ }
+ }
diff --git a/src/app/views/deployables/_new_from_image.html.haml b/src/app/views/deployables/_new_from_image.html.haml
new file mode 100644
index 0000000..81215e5
--- /dev/null
+++ b/src/app/views/deployables/_new_from_image.html.haml
@@ -0,0 +1,24 @@
+%section.admin-content-section
+ %header.admin-page-header
+ %h2=t('.catalog_entry_name', :name => @catalog_entry.deployable.name)
+
+ .content
+ = form_for @catalog_entry, :html => {:class => 'generic'} do |form|
+ = hidden_field_tag :create_from_image, params[:create_from_image]
+ - if @catalog_entry.errors.any?
+ = render 'layouts/error_messages', :object => @catalog_entry
+ %fieldset
+ %p
+ %h2
+ =t('.title')
+ =t('.description', :name => @image.name)
+ %p
+ = form.label :name, t('catalog_entries.new.hw_profile')
+ = select_tag :hardware_profile, options_from_collection_for_select(@hw_profiles, :id, :name, params[:hardware_profile])
+ %p
+ = form.label :catalog_id, t('catalog_entries.form.catalog')
+ = form.select :catalog_id, @catalogs.collect{|c| [c.name, c.id]}
+
+ %fieldset.options
+ = link_to "#{t'catalog_entries.form.cancel'}", catalogs_path, :class => 'button danger'
+ = submit_tag "#{t'catalog_entries.form.save'}", :name => 'save', :class => 'button', :id => 'save_button'
diff --git a/src/app/views/deployables/_section_header.html.haml b/src/app/views/deployables/_section_header.html.haml
new file mode 100644
index 0000000..ed41a09
--- /dev/null
+++ b/src/app/views/deployables/_section_header.html.haml
@@ -0,0 +1,4 @@
+%header.admin-page-header
+ %h1{:class => controller.controller_name}=t'catalog_entries.index.catalog_entries'
+ #obj_actions.button-group
+ = link_to "#{t'catalog_entries.new_catalog_entry'}", new_catalog_deployable_url(@catalog), :class => 'button primary', :id => 'new_catalog_entry_button'
diff --git a/src/app/views/deployables/_upload.html.haml b/src/app/views/deployables/_upload.html.haml
new file mode 100644
index 0000000..7c2917e
--- /dev/null
+++ b/src/app/views/deployables/_upload.html.haml
@@ -0,0 +1,27 @@
+= form_for @catalog_entry, :url => catalog_deployables_path(@catalog), :html => {:class => 'generic', :multipart => true } do |form|
+ - if @catalog_entry.errors.any?
+ = render 'layouts/error_messages', :object => @catalog_entry
+ %fieldset
+ %p
+ = form.label :catalog_id, t('catalog_entries.form.catalog')
+ = @catalog.name
+ .clear
+ = form.fields_for :deployable, @catalog_entry.deployable do |deployable_fields|
+ %fieldset
+ %p
+ = deployable_fields.label :name, t('catalog_entries.index.name')
+ = deployable_fields.text_field :name, :class => 'em long'
+ %p
+ = deployable_fields.label :description, t('catalog_entries.form.description')
+ = deployable_fields.text_area :description, :class => 'long'
+ %p
+ = deployable_fields.label :xml, t('catalog_entries.form.choose_xml')
+ = deployable_fields.file_field :xml
+ %fieldset
+ %p
+ = check_box_tag(:edit_xml, true, false)
+ = label_tag :edit_xml, t('catalog_entries.form.edit_xml_after_save')
+
+ %fieldset.options
+ = link_to t('cancel'), catalog_path(@catalog), :class => 'button danger'
+ = submit_tag t('save'), :name => 'save', :class => 'button', :id => 'save_button'
diff --git a/src/app/views/deployables/edit.html.haml b/src/app/views/deployables/edit.html.haml
new file mode 100644
index 0000000..e76b3e2
--- /dev/null
+++ b/src/app/views/deployables/edit.html.haml
@@ -0,0 +1,15 @@
+= render :partial => 'layouts/admin_nav'
+%header.admin-page-header
+ %h1{:class => controller.controller_name}= @catalog_entry.deployable.name
+ #obj_actions.button-container
+ = link_to 'New Deployable', new_catalog_deployable_path((a)catalog_entry.catalog, @catalog_entry), :class => 'button primary', :id => 'new_deployable_button'
+ .button-group
+ = link_to 'Cancel Editing', catalog_deployables_path((a)catalog_entry.catalog), :class => 'button pill danger', :id => 'new_deployable_button'
+
+%section.admin-content-section.user
+ %header
+ %h2=t'catalog_entries.edit.editing_catalog_entry'
+
+ .content
+ = form_for @catalog_entry, :url => catalog_deployable_path((a)catalog_entry.catalog, @catalog_entry), :html => { :method => :put, :class => 'generic' } do |f|
+ = render :partial => "form", :locals => { :form => f }
diff --git a/src/app/views/deployables/index.html.haml b/src/app/views/deployables/index.html.haml
new file mode 100644
index 0000000..3fae6b6
--- /dev/null
+++ b/src/app/views/deployables/index.html.haml
@@ -0,0 +1,3 @@
+= render :partial => 'layouts/admin_nav'
+= render :partial => 'section_header'
+= render :partial => 'list'
diff --git a/src/app/views/deployables/new.html.haml b/src/app/views/deployables/new.html.haml
new file mode 100644
index 0000000..893345f
--- /dev/null
+++ b/src/app/views/deployables/new.html.haml
@@ -0,0 +1,2 @@
+= render :partial => 'layouts/admin_nav'
+= render :partial => params[:create_from_image] ? 'new_from_image' : 'new'
diff --git a/src/app/views/deployables/show.html.haml b/src/app/views/deployables/show.html.haml
new file mode 100644
index 0000000..86e34e3
--- /dev/null
+++ b/src/app/views/deployables/show.html.haml
@@ -0,0 +1,62 @@
+= render :partial => 'layouts/admin_nav'
+%header.admin-page-header
+ %h1{:class => controller.controller_name}= @catalog_entry.deployable.name
+ #obj_actions.button-container
+ .button-group
+ = button_to t('catalog_entries.show.delete'), catalog_deployable_path((a)catalog_entry.catalog, @catalog_entry), :method => 'delete', :confirm => "#{t'catalog_entries.show.confirm_delete'}", :class => 'button danger', :id => 'delete'
+ = link_to t('catalog_entries.show.edit'), edit_catalog_deployable_path((a)catalog_entry.catalog, @catalog_entry), :class => 'button', :id => 'edit_button'
+
+ = link_to t('deployments.overview.launch'), launch_new_deployments_path(:deployable_id => @catalog_entry.deployable.id, :pool_id => @catalog_entry.catalog.pool), :id => :launch_deployment
+
+%section.admin-content-section.deployable
+ %section.image
+ %header
+ %h2= t('.image')
+ %pre= @catalog_entry.deployable.xml
+
+
+ %section.build
+ %header
+ %h2= t('.build')
+
+ = form_tag() do
+ = select_tag :build_option, options_for_select([[t("rebuild_all"), 1]])
+ = submit_tag t('.start'), :id => :start_build
+
+ %p.description= t('.build_description')
+
+ %ul#providers-list
+ - @providers.each do |provider|
+ %li
+ %span.provider= provider.name
+ %span.status Building 98%
+ -#= form_tag()
+ -# %button on/off
+
+
+ %section.catalogs
+ %header
+ %h2= t('.catalogs')
+
+ %p= t('.choose_catalog')
+ = form_for(:catalog_entry, :url => catalog_entries_path) do |f|
+ = f.select :catalog_id, options_for_select(@catalogs_options)
+ = f.hidden_field(:deployable_id, :value => @catalog_entry.deployable.id)
+ = f.submit t('catalog_entries.show.add_catalog'), :id => :add_catalog
+
+ %table
+ %tr
+ %th
+ %label= t('.catalog_name')
+ %th
+ %label= t('.environment')
+ - @catalog_entry.deployable.catalog_entries.each do |catalog_entry|
+ %tr
+ %td= catalog_entry.catalog.name
+ %td= catalog_entry.catalog.pool.pool_family.name
+
+ - if check_privilege(Privilege::PERM_VIEW,@permission_object)
+ %section.roles
+ %header
+ %h2= t('users.users')
+ = render :partial => 'permissions/permissions'
diff --git a/src/app/views/deployments/_overview.html.haml b/src/app/views/deployments/_overview.html.haml
index e445c2b..e8da927 100644
--- a/src/app/views/deployments/_overview.html.haml
+++ b/src/app/views/deployments/_overview.html.haml
@@ -20,7 +20,7 @@
%p= @deployment.deployable_xml.description
%h3= t('.deployable_xml')
- =link_to @deployable.xml_filename, catalog_catalog_entry_path((a)deployable.catalogs.first, @deployable.catalog_entries.first.id, :deployable_xml => true)
+ =link_to @deployable.xml_filename, catalog_deployable_path((a)deployable.catalogs.first, @deployable.catalog_entries.first.id, :deployable_xml => true)
⇒
%h3= t('.image_ids')
diff --git a/src/app/views/deployments/launch_from_catalog.html.haml b/src/app/views/deployments/launch_from_catalog.html.haml
index 7f99d89..dd464f5 100644
--- a/src/app/views/deployments/launch_from_catalog.html.haml
+++ b/src/app/views/deployments/launch_from_catalog.html.haml
@@ -37,7 +37,7 @@
%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_catalog_entry_path(deployable.catalogs.first, deployable.catalog_entries.first.id, :deployable_xml => true)
+ %td= link_to deployable.xml_filename, catalog_deployable_path(deployable.catalogs.first, deployable.catalog_entries.first.id, :deployable_xml => true)
.align-center
%div= will_paginate @deployables
diff --git a/src/config/locales/en.yml b/src/config/locales/en.yml
index b6dc774..85dbd3f 100644
--- a/src/config/locales/en.yml
+++ b/src/config/locales/en.yml
@@ -639,6 +639,7 @@ en:
warning:
not_valid_or_reachable: "Catalog entry XML file is either invalid or no longer reachable at %{url}"
not_valid: "Deployable XML file doesn't resolve valid XML"
+ failed: Catalog entry was not created.
notice:
added: Catalog entry added.
updated: Catalog entry updated successfully!
diff --git a/src/config/routes.rb b/src/config/routes.rb
index 515d6b7..6f05a08 100644
--- a/src/config/routes.rb
+++ b/src/config/routes.rb
@@ -202,13 +202,13 @@ Conductor::Application.routes.draw do
delete 'multi_destroy', :on => :collection
post 'create'
post :filter, :on => :collection
- resources :catalog_entries do
+ resources :deployables do
delete 'multi_destroy', :on => :collection
post :filter, :on => :collection
end
end
- resources :catalog_entries
+ resources :catalog_entries, :only => :create
resources :deployables
diff --git a/src/features/catalog_entries.feature b/src/features/catalog_entries.feature
deleted file mode 100644
index d950c50..0000000
--- a/src/features/catalog_entries.feature
+++ /dev/null
@@ -1,89 +0,0 @@
-Feature: Manage Catalog Entries
- In order to manage catalog entries
- As an admin
- I want to add/edit/remove catalog entries
-
- Background:
- Given I am an authorised user
- And I am logged in
-
- Scenario: Create new catalog entry
- Given there is a "default" catalog
- When I am on the "default" catalog catalog entries page
- Then I should see "Catalog Entries"
- When I follow "new_catalog_entry_button"
- Then I should see "Add New Catalog Entry"
- When I fill in "catalog_entry[deployable_attributes][name]" with "test1"
- And I fill in "catalog_entry[deployable_attributes][description]" with "description"
- When I attach the file "features/upload_files/deployable.xml" to "catalog_entry[deployable_attributes][xml]"
- And I press "save_button"
- Then I should see "Catalog entry added"
-
- Scenario: Change the name
- Given there is a "default" catalog
- And a catalog entry "testdepl" exists
- When I am on the "default" catalog catalog entries page
- When I follow "testdepl"
- And I follow "edit_button"
- Then I should see "Editing Catalog Entry"
- When I fill in "catalog_entry[deployable_attributes][name]" with "testdepl-renamed"
- And I press "save_button"
- Then I should see "Catalog entry updated successfully!"
- And I should see "testdepl-renamed"
-
- Scenario: Show catalog entry details
- Given there is a "default" catalog
- And a catalog entry "testdepl" exists
- And I am on the "default" catalog catalog entries page
- When I follow "testdepl"
- Then I should see "testdepl"
- And I should see "Image"
- And I should see "Build"
- And I should see "Catalogs"
- And I should see "Users"
-
- Scenario: Launch a deployment
- Given there is a "default" catalog
- And a catalog entry "testdepl" exists
- And I am on testdepl's catalog entry page
- When I follow "launch_deployment"
- Then I should be on the launch new deployments page
-
- Scenario: Delete deployables
- Given there is a "default" catalog
- And a catalog entry "testdepl1" exists for "default" catalog
- And a catalog entry "testdepl2" exists for "default" catalog
- And I am on the "default" catalog catalog entries page
- When I check "testdepl1" catalog entry
- And I check "testdepl2" catalog entry
- And I press "delete_button"
- Then there should be only 0 catalog entries
- And I should be on the "default" catalog page
- And I should not see "testdepl1"
- And I should not see "testdepl2"
-
- Scenario: Delete deployable
- Given there is a "default" catalog
- And a catalog entry "testdepl1" exists for "default" catalog
- And I am on the "default" catalog page
- When I follow "testdepl1"
- And I press "delete"
- Then there should be only 0 catalog entries
- And I should be on the "default" catalog page
- And I should not see "testdepl1"
-
- #Scenario: Search Catalog Entries
- # Given there is a "testcatalog" catalog
- # And a catalog entry "mycatalog_entry" exists
- # And a catalog entry "somecatalog_entry" exists
- # And I am on the "testcatalog" catalog catalog entries page
- # Then I should see "mycatalog_entry"
- # And I should see "somecatalog_entry"
- # When I fill in "catalog_entries_search" with "some"
- # And I press "apply_catalog_entries_search"
- # Then I should see "somecatalog_entry"
- # And I should not see "mycatalog_entry"
- # When I fill in "catalog_entries_search" with "mycatalog_entry"
- # And I press "apply_catalog_entries_search"
- # Then I should see "mycatalog_entry"
- # And I should not see "somecatalog_entry"
diff --git a/src/features/deployables.feature b/src/features/deployables.feature
new file mode 100644
index 0000000..d950c50
--- /dev/null
+++ b/src/features/deployables.feature
@@ -0,0 +1,89 @@
+Feature: Manage Catalog Entries
+ In order to manage catalog entries
+ As an admin
+ I want to add/edit/remove catalog entries
+
+ Background:
+ Given I am an authorised user
+ And I am logged in
+
+ Scenario: Create new catalog entry
+ Given there is a "default" catalog
+ When I am on the "default" catalog catalog entries page
+ Then I should see "Catalog Entries"
+ When I follow "new_catalog_entry_button"
+ Then I should see "Add New Catalog Entry"
+ When I fill in "catalog_entry[deployable_attributes][name]" with "test1"
+ And I fill in "catalog_entry[deployable_attributes][description]" with "description"
+ When I attach the file "features/upload_files/deployable.xml" to "catalog_entry[deployable_attributes][xml]"
+ And I press "save_button"
+ Then I should see "Catalog entry added"
+
+ Scenario: Change the name
+ Given there is a "default" catalog
+ And a catalog entry "testdepl" exists
+ When I am on the "default" catalog catalog entries page
+ When I follow "testdepl"
+ And I follow "edit_button"
+ Then I should see "Editing Catalog Entry"
+ When I fill in "catalog_entry[deployable_attributes][name]" with "testdepl-renamed"
+ And I press "save_button"
+ Then I should see "Catalog entry updated successfully!"
+ And I should see "testdepl-renamed"
+
+ Scenario: Show catalog entry details
+ Given there is a "default" catalog
+ And a catalog entry "testdepl" exists
+ And I am on the "default" catalog catalog entries page
+ When I follow "testdepl"
+ Then I should see "testdepl"
+ And I should see "Image"
+ And I should see "Build"
+ And I should see "Catalogs"
+ And I should see "Users"
+
+ Scenario: Launch a deployment
+ Given there is a "default" catalog
+ And a catalog entry "testdepl" exists
+ And I am on testdepl's catalog entry page
+ When I follow "launch_deployment"
+ Then I should be on the launch new deployments page
+
+ Scenario: Delete deployables
+ Given there is a "default" catalog
+ And a catalog entry "testdepl1" exists for "default" catalog
+ And a catalog entry "testdepl2" exists for "default" catalog
+ And I am on the "default" catalog catalog entries page
+ When I check "testdepl1" catalog entry
+ And I check "testdepl2" catalog entry
+ And I press "delete_button"
+ Then there should be only 0 catalog entries
+ And I should be on the "default" catalog page
+ And I should not see "testdepl1"
+ And I should not see "testdepl2"
+
+ Scenario: Delete deployable
+ Given there is a "default" catalog
+ And a catalog entry "testdepl1" exists for "default" catalog
+ And I am on the "default" catalog page
+ When I follow "testdepl1"
+ And I press "delete"
+ Then there should be only 0 catalog entries
+ And I should be on the "default" catalog page
+ And I should not see "testdepl1"
+
+ #Scenario: Search Catalog Entries
+ # Given there is a "testcatalog" catalog
+ # And a catalog entry "mycatalog_entry" exists
+ # And a catalog entry "somecatalog_entry" exists
+ # And I am on the "testcatalog" catalog catalog entries page
+ # Then I should see "mycatalog_entry"
+ # And I should see "somecatalog_entry"
+ # When I fill in "catalog_entries_search" with "some"
+ # And I press "apply_catalog_entries_search"
+ # Then I should see "somecatalog_entry"
+ # And I should not see "mycatalog_entry"
+ # When I fill in "catalog_entries_search" with "mycatalog_entry"
+ # And I press "apply_catalog_entries_search"
+ # Then I should see "mycatalog_entry"
+ # And I should not see "somecatalog_entry"
diff --git a/src/features/step_definitions/catalog_entry_steps.rb b/src/features/step_definitions/catalog_entry_steps.rb
deleted file mode 100644
index 73bf7be..0000000
--- a/src/features/step_definitions/catalog_entry_steps.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-Given /^a catalog entry "([^"]*)" exists$/ do |arg1|
- deployable = FactoryGirl.create :deployable, :name => arg1
- entry = FactoryGirl.create :catalog_entry, :deployable => deployable
-end
-
-When /^I check "([^"]*)" catalog entry$/ do |arg1|
- dep = CatalogEntry.find_by_deployable_id(Deployable.find_by_name(arg1))
- check("catalog_entry_checkbox_#{dep.id}")
-end
-
-Then /^there should be only (\d+) catalog entries$/ do |arg1|
- CatalogEntry.count.should == arg1.to_i
-end
-
-Given /^a catalog entry "([^"]*)" exists for "([^"]*)" catalog$/ do |arg1, catalog_name|
- catalog = Catalog.find_by_name(catalog_name) || FactoryGirl.create(:catalog, :name => catalog_name)
- deployable = FactoryGirl.create :deployable, :name => arg1
- entry = FactoryGirl.create :catalog_entry, :deployable => deployable, :catalog => catalog
-end
diff --git a/src/features/step_definitions/deployable_steps.rb b/src/features/step_definitions/deployable_steps.rb
new file mode 100644
index 0000000..73bf7be
--- /dev/null
+++ b/src/features/step_definitions/deployable_steps.rb
@@ -0,0 +1,19 @@
+Given /^a catalog entry "([^"]*)" exists$/ do |arg1|
+ deployable = FactoryGirl.create :deployable, :name => arg1
+ entry = FactoryGirl.create :catalog_entry, :deployable => deployable
+end
+
+When /^I check "([^"]*)" catalog entry$/ do |arg1|
+ dep = CatalogEntry.find_by_deployable_id(Deployable.find_by_name(arg1))
+ check("catalog_entry_checkbox_#{dep.id}")
+end
+
+Then /^there should be only (\d+) catalog entries$/ do |arg1|
+ CatalogEntry.count.should == arg1.to_i
+end
+
+Given /^a catalog entry "([^"]*)" exists for "([^"]*)" catalog$/ do |arg1, catalog_name|
+ catalog = Catalog.find_by_name(catalog_name) || FactoryGirl.create(:catalog, :name => catalog_name)
+ deployable = FactoryGirl.create :deployable, :name => arg1
+ entry = FactoryGirl.create :catalog_entry, :deployable => deployable, :catalog => catalog
+end
diff --git a/src/features/support/paths.rb b/src/features/support/paths.rb
index e976e1c..ebf0bc1 100644
--- a/src/features/support/paths.rb
+++ b/src/features/support/paths.rb
@@ -30,7 +30,7 @@ module NavigationHelpers
deployable = Deployable.find_by_name($1)
catalog_entry = deployable.catalog_entries.first
catalog = catalog_entry.catalog
- catalog_catalog_entry_path(catalog, catalog_entry)
+ catalog_deployable_path(catalog, catalog_entry)
when /the account page/
account_path
@@ -159,7 +159,7 @@ module NavigationHelpers
when /^the "(.*)" catalog catalog entries page/
- url_for catalog_catalog_entries_path(Catalog.find_by_name($1))
+ url_for catalog_deployables_path(Catalog.find_by_name($1))
# Add more mappings here.
# Here is an example that pulls values out of the Regexp:
diff --git a/src/spec/controllers/catalog_entries_controller_spec.rb b/src/spec/controllers/catalog_entries_controller_spec.rb
deleted file mode 100644
index ed00c89..0000000
--- a/src/spec/controllers/catalog_entries_controller_spec.rb
+++ /dev/null
@@ -1,46 +0,0 @@
-#
-# Copyright (C) 2011 Red Hat, Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; version 2 of the License.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
-# MA 02110-1301, USA. A copy of the GNU General Public License is
-# also available at http://www.gnu.org/copyleft/gpl.html.
-
-require 'spec_helper'
-
-describe CatalogEntriesController do
-
- fixtures :all
- before(:each) do
- @admin_permission = FactoryGirl.create :admin_permission
- @admin = @admin_permission.user
- @image = mock(Aeolus::Image::Warehouse::Image, :id => '3c58e0d6-d11a-4e68-8b12-233783e56d35', :name => 'image1', :uuid => '3c58e0d6-d11a-4e68-8b12-233783e56d35')
- Aeolus::Image::Warehouse::Image.stub(:find).and_return(@image)
- end
-
- it "should provide ui to create new catalog entry from image" do
- mock_warden(@admin)
- get :new, :create_from_image => @image.id
- response.should be_success
- response.should render_template("new")
- end
-
- it "should create new catalog entry from image" do
- hw_profile = FactoryGirl.create(:front_hwp1)
- catalog = FactoryGirl.create(:catalog)
- mock_warden(@admin)
- post(:create, :create_from_image => @image.id, :hardware_profile => hw_profile.id, :catalog_entry => {:catalog_id => catalog.id})
- response.should redirect_to(catalog_catalog_entries_url(catalog.id))
- end
-
-end
diff --git a/src/spec/controllers/deployables_controller_spec.rb b/src/spec/controllers/deployables_controller_spec.rb
new file mode 100644
index 0000000..eb0a6f8
--- /dev/null
+++ b/src/spec/controllers/deployables_controller_spec.rb
@@ -0,0 +1,46 @@
+#
+# Copyright (C) 2011 Red Hat, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301, USA. A copy of the GNU General Public License is
+# also available at http://www.gnu.org/copyleft/gpl.html.
+
+require 'spec_helper'
+
+describe DeployablesController do
+
+ fixtures :all
+ before(:each) do
+ @admin_permission = FactoryGirl.create :admin_permission
+ @admin = @admin_permission.user
+ @image = mock(Aeolus::Image::Warehouse::Image, :id => '3c58e0d6-d11a-4e68-8b12-233783e56d35', :name => 'image1', :uuid => '3c58e0d6-d11a-4e68-8b12-233783e56d35')
+ Aeolus::Image::Warehouse::Image.stub(:find).and_return(@image)
+ end
+
+ it "should provide ui to create new catalog entry from image" do
+ mock_warden(@admin)
+ get :new, :create_from_image => @image.id
+ response.should be_success
+ response.should render_template("new")
+ end
+
+ it "should create new catalog entry from image" do
+ hw_profile = FactoryGirl.create(:front_hwp1)
+ catalog = FactoryGirl.create(:catalog)
+ mock_warden(@admin)
+ post(:create, :create_from_image => @image.id, :hardware_profile => hw_profile.id, :catalog_entry => {:catalog_id => catalog.id})
+ response.should redirect_to(catalog_deployables_url(catalog.id))
+ end
+
+end
--
1.7.6.4
12 years, 4 months
[PATCH aeolus-cli] Added provider content cleanup output
by Martyn Taylor
Depends on two patches
conductor => [PATCH aeolus-conductor] Return provider cleanup content via API
aeolus-image-rubygem => [PATCH aeolus-image-rubygem] Added convenience methods for checking providerimages on image/build
12 years, 4 months
[PATCH aeolus-image-rubygem] Added convenience methods for checking providerimages on image/build
by Martyn Taylor
From: Martyn Taylor <mtaylor(a)redhat.com>
---
lib/aeolus_image/model/warehouse/image.rb | 9 +++++++++
lib/aeolus_image/model/warehouse/image_build.rb | 9 +++++++++
spec/models/warehouse/image_build_spec.rb | 20 ++++++++++++++++----
spec/models/warehouse/image_spec.rb | 14 +++++++++++++-
4 files changed, 47 insertions(+), 5 deletions(-)
diff --git a/lib/aeolus_image/model/warehouse/image.rb b/lib/aeolus_image/model/warehouse/image.rb
index 8f505d4..6b12f73 100644
--- a/lib/aeolus_image/model/warehouse/image.rb
+++ b/lib/aeolus_image/model/warehouse/image.rb
@@ -49,6 +49,15 @@ module Aeolus
ImageBuild.where("($image == \"" + @uuid.to_s + "\")")
end
+ # Return all Provider Images associated with this Image
+ def provider_images
+ provider_images = []
+ image_builds.each do |b|
+ provider_images = provider_images + b.provider_images
+ end
+ provider_images
+ end
+
#TODO: We should get the image fields from the object body once we have it defined.
def name
unless @name
diff --git a/lib/aeolus_image/model/warehouse/image_build.rb b/lib/aeolus_image/model/warehouse/image_build.rb
index 2e94d08..234a3aa 100644
--- a/lib/aeolus_image/model/warehouse/image_build.rb
+++ b/lib/aeolus_image/model/warehouse/image_build.rb
@@ -26,6 +26,15 @@ module Aeolus
TargetImage.where("($build == \"" + @uuid.to_s + "\")")
end
+ # Convenience Method to get all provider images for this build
+ def provider_images
+ provider_images = []
+ target_images.each do |t|
+ provider_images = provider_images + t.provider_images
+ end
+ provider_images
+ end
+
# Deletes this image and all child objects
def delete!
begin
diff --git a/spec/models/warehouse/image_build_spec.rb b/spec/models/warehouse/image_build_spec.rb
index 15ae1cc..37fd573 100644
--- a/spec/models/warehouse/image_build_spec.rb
+++ b/spec/models/warehouse/image_build_spec.rb
@@ -32,9 +32,9 @@ module Aeolus
end
@image_build = ImageBuild.new(@object)
- @target_image_mock_with_no_build = mock(TargetImage, :build => nil)
- @target_image_mock_with_correct_build = mock(TargetImage, :build => @image_build)
- @other_target_image_mock_with_correct_build = mock(TargetImage, :build => @image_build)
+ @target_image_mock_with_no_build = mock(TargetImage, :build => nil, :provider_images => [mock(ProviderImage)])
+ @target_image_mock_with_correct_build = mock(TargetImage, :build => @image_build, :provider_images => [mock(ProviderImage)])
+ @other_target_image_mock_with_correct_build = mock(TargetImage, :build => @image_build, :provider_images => [mock(ProviderImage)])
@other_image_build_attributes = @image_build_attributes.merge(:uuid => 'other_uuid')
@other_object = mock(Object, :attr_list => @other_image_build_attributes.keys, :attrs => @other_image_build_attributes)
@@ -43,7 +43,7 @@ module Aeolus
end
@other_image_build = ImageBuild.new(@other_object)
- @target_image_mock_with_other_image_build = mock(TargetImage, :build => @other_image_build)
+ @target_image_mock_with_other_image_build = mock(TargetImage, :build => @other_image_build, :provider_images => [mock(ProviderImage)] * 2)
@all_target_images = [ @target_image_mock_with_no_build, @target_image_mock_with_correct_build, @other_target_image_mock_with_correct_build, @target_image_mock_with_other_image_build ]
@@ -154,6 +154,18 @@ module Aeolus
end
end
+ context "#provider_images" do
+ before(:each) do
+ TargetImage.stub(:where).and_return(@all_target_images)
+ end
+
+ context "should return collection" do
+ it "with correct amount of provider images" do
+ @image_build.provider_images.size.should == 5
+ end
+ end
+ end
+
context "#delete!" do
before(:each) do
diff --git a/spec/models/warehouse/image_spec.rb b/spec/models/warehouse/image_spec.rb
index bd17165..61d6752 100644
--- a/spec/models/warehouse/image_spec.rb
+++ b/spec/models/warehouse/image_spec.rb
@@ -87,10 +87,22 @@ module Aeolus
before(:each) do
@target_template = mock(Template, :body => @template_xml.to_s)
@target_image = [ mock(TargetImage, :target_template => @target_template) ]
- @image_builds = [ mock(ImageBuild, :target_images => @target_image) ]
+ @image_builds = [ mock(ImageBuild, :target_images => @target_image, :provider_images => [mock(ProviderImage)] * 2) ] * 2
@image.stub(:image_builds).and_return(@image_builds)
end
+ context "#provider_images" do
+ before(:each) do
+ ImageBuild.stub(:where).and_return(@image_builds)
+ end
+
+ context "should return collection" do
+ it "with correct amount of provider images" do
+ @image.provider_images.size.should == 4
+ end
+ end
+ end
+
# TODO: There shoud be a way to test equality of Nokogiri::XML documents better than string comparison
it "should return correct template" do
@image.template_xml.to_s.should be_eql((a)template_xml.to_s)
--
1.7.6.4
12 years, 4 months