aeolus-incubator / tim

Web application for managing virtual images to be deployed in the cloud
www.aeolusproject.org
MIT License
3 stars 6 forks source link

Added Factory Callback Support #13

Closed mtaylor closed 12 years ago

mtaylor commented 12 years ago

Adds in Factory Callback Support:

= Testing Instructions

== Checkout and Build ImageFactory and plugins

make rpm cd imagefactory-plugins/; make rpm

Openstack plugin has a dep not in fedora so will break install; just skip it.

yum install ~/rpmbuld/RPMS/imagefactory-* --skip-broken

== Run factory

sudo /usr/bin/imagefactoryd --debug --no_ssl --no_oauth --foreground

== Start up the test/dummy app

cd /test/dummy rake db:migrate; rails s

== Run commands from Rails Console

Open up a rails console;

cd /test/dummy .rake db:migrate; rails c

You can create images using the commands below. Check the test/dummy server log when creating Target and Provider Images for PUT requests. Then check to see if the model was updated properly.

== Commands

template_xml = ""

template = ImageManagement::Template.create(:xml => template_xml)

base_image = ImageManagement::BaseImage.new base_image.template = template base_image.save

image_version = ImageManagement::ImageVersion.new image_version.base_image = base_image image_version.save

target_image = ImageManagement::TargetImage.new(:target => "MockSphere") target_image.image_version = image_version target_image.save

provider_image = ImageManagement::ProviderImage.new(:provider => "MockSphere", :credentials => "") provider_image.target_image = target_image provider_image.save

jguiditta commented 12 years ago

I hope I can ack this, it looks like you accidentally pushed it to incubator already :)

mtaylor commented 12 years ago

On 09/06/2012 07:58 PM, jguiditta wrote:

I hope I can ack this, it looks like you accidentally pushed it to incubator already :)

— Reply to this email directly or view it on GitHub https://github.com/aeolus-incubator/image-management-engine/pull/13#issuecomment-8343316.

Yeah I accidentally pushed the branch to upstream too. It's not on master branch though, so shouldn't be a problem if it's nack'd for any reasons.

jguiditta commented 12 years ago

OK, this seems to mostly work, I do get callbacks from factory, but when pushing the provider images, I get this return, which looks not quite right to me:

Parameters: {"provider_image"=>{"icicle"=>nil, "parameters"=>nil, "p
rovider"=>"MockSphere", "_type"=>"ProviderImage", "status"=>"FAILED", 
"template"=>"<template><name>mock</name><os><name>RHELMock</name><vers
ion>1</version><arch>x86_64</arch><install type='iso'><iso>http://mock
host/RHELMock1-x86_64-DVD.iso</iso></install><rootpw>password</rootpw>
</os><description>Mock Template</description> </template>", "provider_
account_identifier"=>nil, "percent_complete"=>0, "status_detail"=>{"ac
tivity"=>"Initializing image prior to Cloud/OS customization", "error"
=>nil}, "identifier_on_provider"=>nil, "id"=>"d78b14b0-2b03-4b37-9a3d-
a5a248ef9c57"}, "id"=>"1"}
  ImageManagement::ProviderImage Load (0.2ms)  SELECT "provider_images
".* FROM "provider_images" WHERE "provider_images"."id" = 1 LIMIT 1
WARNING: Can't mass-assign protected attributes: icicle, parameters, _
type, template, provider_account_identifier, identifier_on_provider, i
d
  AREL (0.4ms)  UPDATE "provider_images" SET "progress" = 0, "updated_
at" = '2012-09-07 19:55:42.183837' WHERE "provider_images"."id" = 1
Redirected to http://localhost:3000/provider_images/1
Completed 302 Found in 197ms
jguiditta commented 12 years ago

Aside from that, everything seems to work fine, so I can probably merge this in on monday once we resolve the minor issue above (or you tell me that is correct)

jguiditta commented 12 years ago

Hmph, starting to think my setup may be messed up, the new tests give me 3 fails as well

mtaylor commented 12 years ago

That is strange. I have actually seen 1 extra test fail but I was unable to replicate it. You should only get the 2 failing tests we talked about:

Failures:

1) ImageManagement::ProviderImage ImageFactory interactions Successful Requests should create new target image with factory meta-data Failure/Error: pi = Factory.create(:provider_image) Errno::ECONNREFUSED: Connection refused - connect(2)

./app/models/image_management/provider_image.rb:28:in

`create_factory_provider_image'

./spec/models/provider_image_spec.rb:40

2) ImageManagement::TargetImage ImageFactory interactions Successful Requests should create new target image with factory meta-data Failure/Error: ti.save NoMethodError: undefined method `activity' for "":String

./app/models/image_management/target_image.rb:38:in

`populate_factory_fields'

./app/models/image_management/target_image.rb:27:in

`create_factory_target_image'

./spec/models/target_image_spec.rb:58

Finished in 17.08 seconds 67 examples, 2 failures

On 09/07/2012 10:52 PM, jguiditta wrote:

Hmph, starting to think my setup may be messed up, the new tests give me 3 fails as well

— Reply to this email directly or view it on GitHub https://github.com/aeolus-incubator/image-management-engine/pull/13#issuecomment-8380151.

mtaylor commented 12 years ago

The warning is fine this is expected. Factory sends back the full resource representation, we want to ignore everything except Status info.

The Failure is likely caused by some ImageFactory setup. I will hold off on pushing this patch until we get the issues resolved. I will ping you later this aftenoon / your morning. We can try and get your setup up and running.

Thanks

On 09/07/2012 09:01 PM, jguiditta wrote:

OK, this seems to mostly work, I do get callbacks from factory, but when pushing the provider images, I get this return, which looks not quite right to me:

Parameters: {"provider_image"=>{"icicle"=>nil, "parameters"=>nil, "p rovider"=>"MockSphere", "_type"=>"ProviderImage", "status"=>"FAILED", "template"=>"", "provider account_identifier"=>nil, "percent_complete"=>0, "status_detail"=>{"ac tivity"=>"Initializing image prior to Cloud/OS customization", "error" =>nil}, "identifier_on_provider"=>nil, "id"=>"d78b14b0-2b03-4b37-9a3d- a5a248ef9c57"}, "id"=>"1"} ImageManagement::ProviderImage Load (0.2ms) SELECT "provider_images ".* FROM "provider_images" WHERE "providerimages"."id" = 1 LIMIT 1 WARNING: Can't mass-assign protected attributes: icicle, parameters, type, template, provider_account_identifier, identifier_on_provider, i d AREL (0.4ms) UPDATE "providerimages" SET "progress" = 0, "updated at" = '2012-09-07 19:55:42.183837' WHERE "provider_images"."id" = 1 Redirected to http://localhost:3000/provider_images/1 Completed 302 Found in 197ms

— Reply to this email directly or view it on GitHub https://github.com/aeolus-incubator/image-management-engine/pull/13#issuecomment-8377075.

jguiditta commented 12 years ago

The other error I get is:

1) ImageManagement::TargetImagesController Target Images API Update Target Image via factory callback should update target image status attributes via json Failure/Error: response.code.should == "200" expected: "200" got: "422" (using ==)

./spec/controllers/target_images_controller_spec.rb:142

jguiditta commented 12 years ago

Pushed with above suggested change and a small whitespace fix