Simon COURTOIS
2010-Sep-01 12:57 UTC
[Ovirt-devel] [PATCH 1/3] Adding the VM Pool migration for vms
Signed-off-by: Simon COURTOIS <scourtois at linagora.com> --- src/app/controllers/vm_controller.rb | 16 ++++++++++++++ src/app/views/vm/edit_vmpool.rhtml | 36 ++++++++++++++++++++++++++++++++ src/app/views/vm/show.rhtml | 3 ++ src/public/images/icon_vmpool_11px.png | Bin 0 -> 542 bytes 4 files changed, 55 insertions(+), 0 deletions(-) create mode 100644 src/app/views/vm/edit_vmpool.rhtml create mode 100644 src/public/images/icon_vmpool_11px.png diff --git a/src/app/controllers/vm_controller.rb b/src/app/controllers/vm_controller.rb index 9860843..f4a90b9 100644 --- a/src/app/controllers/vm_controller.rb +++ b/src/app/controllers/vm_controller.rb @@ -146,6 +146,22 @@ class VmController < ApplicationController render :layout => false end + def edit_vmpool + svc_modify(params[:id]) + @vm = Vm.find(params[:id]) + @vm_pools = VmResourcePool.find_all_by_parent_id(@vm.vm_resource_pool.parent.id) + render :layout => 'popup' + end + + def update_vmpool + svc_modify(params[:id]) + @vm = Vm.find(params[:id]) + @vm_pool = VmResourcePool.find(params[:vm][:vm_resource_pool_id]) + @vm.update_attribute(:vm_resource_pool, @vm_pool) + render :json => { :object => "vm", :success => true, + :alert => "VM Pool changed for this Virtual Machine" } + end + protected def _setup_provisioning_options @provisioning_options = [[Vm::PXE_OPTION_LABEL, Vm::PXE_OPTION_VALUE], diff --git a/src/app/views/vm/edit_vmpool.rhtml b/src/app/views/vm/edit_vmpool.rhtml new file mode 100644 index 0000000..cfa29a7 --- /dev/null +++ b/src/app/views/vm/edit_vmpool.rhtml @@ -0,0 +1,36 @@ +<%- content_for :title do -%> + Change VM Pool +<%- end -%> +<%- content_for :description do -%> + Please choose pool destination. +<%- end -%> + +<form method="POST" id="change_vmpool_form" action="<%= url_for :action => 'update_vmpool' %>"> + <div class="dialog_form"> + <%= error_messages_for 'change_vmpool' %> + + <% form_tag do %> + <!--[form:change_vmpool]--> + <%= hidden_field_tag 'id', @vm.id, :id => 'vm_id' %> + <%= label "vm", "vm_resource_pool_id", "Select the pool to migrate to" %> + <%= select "vm", "vm_resource_pool_id", @vm_pools.map { |pool| [pool.name, pool.id] } %> + <% end %> + + </div> + <%= popup_footer("$('#change_vmpool_form').submit()", "Change VM Pool") %> +</form> +<script type="text/javascript"> + $(function() { + + $('#change_vmpool_form').ajaxForm({ + dataType: 'json', + success: function(data, status) { + afterVm(data, status); + if (data.alert) { + $.jGrowl(data.alert); + } + } + }); + + }); +</script> diff --git a/src/app/views/vm/show.rhtml b/src/app/views/vm/show.rhtml index e7207aa..3413095 100644 --- a/src/app/views/vm/show.rhtml +++ b/src/app/views/vm/show.rhtml @@ -33,6 +33,9 @@ </a> <% end -%> <% end %> + <%= link_to image_tag("icon_vmpool_11px.png") + " Change VM Pool", + {:controller => 'vm', :action => 'edit_vmpool', :id => @vm}, + :rel=>"facebox[.bolder]", :class=>"selection_facebox" %> <a href="#confirm_cancel" rel="facebox[.bolder]"> <%= image_tag "icon_cancel_11px.png" %> Cancel queued tasks </a> diff --git a/src/public/images/icon_vmpool_11px.png b/src/public/images/icon_vmpool_11px.png new file mode 100644 index 0000000000000000000000000000000000000000..86e5970fcb706e5bd82882baafc4e03d7f648ee9 GIT binary patch literal 542 zcmV+(0^$9MP)<h;3K|Lk000e1NJLTq000aC000XJ1^@s6OK at yo00001b5ch_0Itp) z=>Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2igb{ z4g?!fhG5<R00Ev!L_t(2&vlVKYZO5MK;P`nWsjVKaD|8%Q=K3Pb`e7aqn>C)0%|M- z3qOj0MgD<kmC8cz4~S7Bf{jHAAr=uyA%fUQL<vE;gUg-S&F#$W?(B?Rs`J(FRS$-+ z_;`W;As)=%nwY)PT(4C3Vbm^5FJDi;SYG)sOn&wJ3DTAB`nk(z at oLM9s3DGw9bLV5 z|1Ls^JuwVJI-T~~wVU&2q}G`QOX<7_vt4YljdKdYUf}VFour%^KR!7sbL+usT%IDM zfZpH`f8qoo1lE>}j8p_bbLJ9Xzim8}Md82~xUv8jpta`Xr_Y=`ag2-8lPtY?$Is2* z6h($H#s#U$As^tf7 at x%?NkX^(m$mgTjE@~go1E`IHpxte(F&=w1v{Y3Vw?yuW<MLh zwy2F(nVPxHPLksB#BoAa<Vcg3Auc6wiogf-`i}R at PYI=@BBgg8QQ91(GgepLO3}P< zezvo%t_GpB&cVTYMWm at tqbNF6tJNj|y4~)xs2UyU_4<#*ut7KG=1w;njXU*vy--St gPP=Vdt=0m-KfYwn??4I``~Uy|07*qoM6N<$f<@--od5s; literal 0 HcmV?d00001 -- 1.7.2.1
Arthur Clément
2010-Sep-08 12:57 UTC
[Ovirt-devel] [PATCH 1/3] Adding the VM Pool migration for vms
ack & pushed On mercredi 01 septembre 2010 14:57:24 Simon COURTOIS wrote:> Signed-off-by: Simon COURTOIS <scourtois at linagora.com> > --- > src/app/controllers/vm_controller.rb | 16 ++++++++++++++ > src/app/views/vm/edit_vmpool.rhtml | 36 > ++++++++++++++++++++++++++++++++ src/app/views/vm/show.rhtml | > 3 ++ > src/public/images/icon_vmpool_11px.png | Bin 0 -> 542 bytes > 4 files changed, 55 insertions(+), 0 deletions(-) > create mode 100644 src/app/views/vm/edit_vmpool.rhtml > create mode 100644 src/public/images/icon_vmpool_11px.png > > diff --git a/src/app/controllers/vm_controller.rb > b/src/app/controllers/vm_controller.rb index 9860843..f4a90b9 100644 > --- a/src/app/controllers/vm_controller.rb > +++ b/src/app/controllers/vm_controller.rb > @@ -146,6 +146,22 @@ class VmController < ApplicationController > render :layout => false > end > > + def edit_vmpool > + svc_modify(params[:id]) > + @vm = Vm.find(params[:id]) > + @vm_pools > VmResourcePool.find_all_by_parent_id(@vm.vm_resource_pool.parent.id) + > render :layout => 'popup' > + end > + > + def update_vmpool > + svc_modify(params[:id]) > + @vm = Vm.find(params[:id]) > + @vm_pool = VmResourcePool.find(params[:vm][:vm_resource_pool_id]) > + @vm.update_attribute(:vm_resource_pool, @vm_pool) > + render :json => { :object => "vm", :success => true, > + :alert => "VM Pool changed for this Virtual Machine" > } + end > + > protected > def _setup_provisioning_options > @provisioning_options = [[Vm::PXE_OPTION_LABEL, Vm::PXE_OPTION_VALUE], > diff --git a/src/app/views/vm/edit_vmpool.rhtml > b/src/app/views/vm/edit_vmpool.rhtml new file mode 100644 > index 0000000..cfa29a7 > --- /dev/null > +++ b/src/app/views/vm/edit_vmpool.rhtml > @@ -0,0 +1,36 @@ > +<%- content_for :title do -%> > + Change VM Pool > +<%- end -%> > +<%- content_for :description do -%> > + Please choose pool destination. > +<%- end -%> > + > +<form method="POST" id="change_vmpool_form" action="<%= url_for :action => > 'update_vmpool' %>"> + <div class="dialog_form"> > + <%= error_messages_for 'change_vmpool' %> > + > + <% form_tag do %> > + <!--[form:change_vmpool]--> > + <%= hidden_field_tag 'id', @vm.id, :id => 'vm_id' %> > + <%= label "vm", "vm_resource_pool_id", "Select the pool to migrate > to" %> + <%= select "vm", "vm_resource_pool_id", @vm_pools.map { > |pool| [pool.name, pool.id] } %> + <% end %> > + > + </div> > + <%= popup_footer("$('#change_vmpool_form').submit()", "Change VM Pool") > %> +</form> > +<script type="text/javascript"> > + $(function() { > + > + $('#change_vmpool_form').ajaxForm({ > + dataType: 'json', > + success: function(data, status) { > + afterVm(data, status); > + if (data.alert) { > + $.jGrowl(data.alert); > + } > + } > + }); > + > + }); > +</script> > diff --git a/src/app/views/vm/show.rhtml b/src/app/views/vm/show.rhtml > index e7207aa..3413095 100644 > --- a/src/app/views/vm/show.rhtml > +++ b/src/app/views/vm/show.rhtml > @@ -33,6 +33,9 @@ > </a> > <% end -%> > <% end %> > + <%= link_to image_tag("icon_vmpool_11px.png") + " Change VM Pool", > + {:controller => 'vm', :action => 'edit_vmpool', > :id => @vm}, + :rel=>"facebox[.bolder]",:class=>"selection_facebox"> %> > <a href="#confirm_cancel" rel="facebox[.bolder]"> > <%= image_tag "icon_cancel_11px.png" %> Cancel queued tasks > </a> > diff --git a/src/public/images/icon_vmpool_11px.png > b/src/public/images/icon_vmpool_11px.png new file mode 100644 > index > 0000000000000000000000000000000000000000..86e5970fcb706e5bd82882baafc4e03d > 7f648ee9 GIT binary patch > literal 542 > zcmV+(0^$9MP)<h;3K|Lk000e1NJLTq000aC000XJ1^@s6OK at yo00001b5ch_0Itp) > z=>Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2igb{ > z4g?!fhG5<R00Ev!L_t(2&vlVKYZO5MK;P`nWsjVKaD|8%Q=K3Pb`e7aqn>C)0%|M- > z3qOj0MgD<kmC8cz4~S7Bf{jHAAr=uyA%fUQL<vE;gUg-S&F#$W?(B?Rs`J(FRS$-+ > z_;`W;As)=%nwY)PT(4C3Vbm^5FJDi;SYG)sOn&wJ3DTAB`nk(z at oLM9s3DGw9bLV5 > z|1Ls^JuwVJI-T~~wVU&2q}G`QOX<7_vt4YljdKdYUf}VFour%^KR!7sbL+usT%IDM > zfZpH`f8qoo1lE>}j8p_bbLJ9Xzim8}Md82~xUv8jpta`Xr_Y=`ag2-8lPtY?$Is2* > z6h($H#s#U$As^tf7 at x%?NkX^(m$mgTjE@~go1E`IHpxte(F&=w1v{Y3Vw?yuW<MLh > zwy2F(nVPxHPLksB#BoAa<Vcg3Auc6wiogf-`i}R at PYI=@BBgg8QQ91(GgepLO3}P< > zezvo%t_GpB&cVTYMWm at tqbNF6tJNj|y4~)xs2UyU_4<#*ut7KG=1w;njXU*vy--St > gPP=Vdt=0m-KfYwn??4I``~Uy|07*qoM6N<$f<@--od5s; > > literal 0 > HcmV?d00001-- Arthur CLEMENT Linagora Paris