[PATCH conductor] BZ 787046 - reduce number of iwhd operations in deployments/overview

Imre Farkas ifarkas at redhat.com
Mon Feb 6 16:03:56 UTC 2012


On 02/03/2012 03:04 AM, Richard Su wrote:
> https://bugzilla.redhat.com/show_bug.cgi?id=787046
>
> The instance object makes multiple calls to iwhd to retrieve the image
> and image_build. We can reduce the number of calls by storing the result
> in an instance variable and reuse it on subsequent requests.
> ---
>   src/app/models/instance.rb |    6 +++---
>   1 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/src/app/models/instance.rb b/src/app/models/instance.rb
> index 03bc119..68ed3bb 100644
> --- a/src/app/models/instance.rb
> +++ b/src/app/models/instance.rb
> @@ -178,11 +178,11 @@ class Instance<  ActiveRecord::Base
>
>
>     def image
> -    Aeolus::Image::Warehouse::Image.find(image_uuid) if image_uuid
> +    @image ||= Aeolus::Image::Warehouse::Image.find(image_uuid) if image_uuid
>     end
>
>     def image_build
> -    Aeolus::Image::Warehouse::ImageBuild.find(image_build_uuid) if image_build_uuid
> +    @image_build ||= Aeolus::Image::Warehouse::ImageBuild.find(image_build_uuid) if image_build_uuid
>     end
>
>     def build
> @@ -357,7 +357,7 @@ class Instance<  ActiveRecord::Base
>       # try to get architecture of the image associated with this instance
>       # for imported images template is empty ->  architecture is not set,
>       # in this case we omit this check
> -    return Aeolus::Image::Warehouse::Image.find(build.image.uuid).os.arch
> +    return image.os.arch
>     rescue
>       logger.warn "failed to get image architecture for instance '#{name}', skipping architecture check: #{$!}"
>       logger.warn $!.backtrace.join("\n  ")

ACK



More information about the aeolus-devel mailing list