[Ovirt-devel] Re: [PATCH server] First attempt at refactoring the vm_controller using the service layer.

Scott Seago sseago at redhat.com
Mon Apr 20 15:22:22 UTC 2009


Scott Seago wrote:
> This code is based on David Lutterkort's proposal outlined in
> https://www.redhat.com/archives/ovirt-devel/2009-April/msg00086.html
>
> I've included service-layer methods for show, create, update, destroy, vm_action, and cancel_queued_tasks. These are the concrete actions that make sense as part of the API. Most of the remaining vm_controller methods are pure-WUI actions -- for things such as generating the web form for a new VM (the subsequent 'create' action _is_ part of the API).
>
> There's a certain amount of temporary code that we need in place while only some of the controllers have been converted, as we still need permissions pre-filters for non-converted create, etc. methods -- but for the converted controllers we don't want to perform actions in before_filters that will be done as part of the services layer. Any temporary methods, etc. that will go away when the last controller is converted have been marked clearly with FIXME comments.
>
> Signed-off-by: Scott Seago <sseago at redhat.com>
> ---
>  src/app/controllers/application.rb               |  113 +++++++----
>  src/app/controllers/hardware_controller.rb       |    3 +-
>  src/app/controllers/host_controller.rb           |    4 +-
>  src/app/controllers/nic_controller.rb            |    2 +-
>  src/app/controllers/permission_controller.rb     |   12 +-
>  src/app/controllers/pool_controller.rb           |    2 +-
>  src/app/controllers/quota_controller.rb          |    4 +-
>  src/app/controllers/storage_controller.rb        |    5 +-
>  src/app/controllers/storage_volume_controller.rb |    6 +-
>  src/app/controllers/task_controller.rb           |    9 +-
>  src/app/controllers/vm_controller.rb             |  230 +++++-----------------
>  src/app/models/vm.rb                             |    1 +
>  src/app/services/application_service.rb          |   56 ++++++
>  src/app/services/vm_service.rb                   |  189 ++++++++++++++++++
>  src/app/views/vm/_form.rhtml                     |    3 +-
>  15 files changed, 394 insertions(+), 245 deletions(-)
>  create mode 100644 src/app/services/application_service.rb
>  create mode 100644 src/app/services/vm_service.rb
>
> diff --git a/src/app/controllers/application.rb b/src/app/controllers/application.rb
> index fa88773..34283ec 100644
> --- a/src/app/controllers/application.rb
> +++ b/src/app/controllers/application.rb
> @@ -20,19 +20,35 @@
>  # Filters added to this controller apply to all controllers in the application.
>  # Likewise, all the methods added will be available for all controllers.
>  
> +# FIXME: once all controller classes include this, remove here
> +require 'services/vm_service'
> +
>   
Oops. that should have been 'application_service' instead of 
'vm_service'. Changing that locally now...

Scott




More information about the ovirt-devel mailing list