On Fri, 2013-04-05 at 00:23 +1100, [email protected] wrote:
> From: Dies Koper <[email protected]>
> 
> ---
>  .../drivers/fgcp/fgcp_driver_cimi_methods.rb       | 48 
> +++++++++++++++++++++-
>  1 file changed, 46 insertions(+), 2 deletions(-)

ACK, with one comment:

> diff --git a/server/lib/deltacloud/drivers/fgcp/fgcp_driver_cimi_methods.rb 
> b/server/lib/deltacloud/drivers/fgcp/fgcp_driver_cimi_methods.rb
> index e147960..fee12d7 100644
> --- a/server/lib/deltacloud/drivers/fgcp/fgcp_driver_cimi_methods.rb
> +++ b/server/lib/deltacloud/drivers/fgcp/fgcp_driver_cimi_methods.rb
 
> +    def start_system(credentials, opts={})
> +      safely do
> +        client = new_client(credentials)
> +        context = opts[:env]
> +        vsys_id = opts[:id]
> +        xml = client.list_vservers(vsys_id)['vservers']
> +        return unless xml and xml[0]['vserver']
> +
> +        xml[0]['vserver'].each do |vserver|
> +          begin
> +            client.start_vserver(vserver['vserverId'][0])
> +          rescue Exception => ex
> +            raise ex if not ex.message =~ /(ALREADY_STARTED|ILLEGAL_STATE).*/
> +          end
> +        end
> +      end
> +    end
> +
> +    def stop_system(credentials, opts={})
> +      safely do
> +        client = new_client(credentials)
> +        context = opts[:env]
> +        vsys_id = opts[:id]
> +        xml = client.list_vservers(vsys_id)['vservers']
> +        return unless xml and xml[0]['vserver']
> +
> +        xml[0]['vserver'].each do |vserver|
> +          begin
> +            client.stop_vserver(vserver['vserverId'][0])
> +          rescue Exception => ex
> +            raise ex if not ex.message =~ /(ALREADY_STOPPED|ILLEGAL_STATE).*/
> +          end
> +        end
> +      end
> +    end

Can we get giant FIXME's around the xml[0]['vserver'] in either method
that points out that (1) this work really should be done in the
background (what happens when somebody tries to start a system with a
gigantic number of instances in it ?) and (2) that error handling needs
to be improved - it seems the CIMI standard is quiet on the behavior if
one of those machine operations fails. Should we try and continue with
the others ? Should there be any automatic cleanup ?

David


Reply via email to