Revision 36ce5e82

View differences:

src/vmm_mad/remotes/lib/vcenter_driver/virtual_machine.rb
1708 1708
            :quiesce     => true
1709 1709
        }
1710 1710

  
1711
        begin
1712
            @item.CreateSnapshot_Task(snapshot_hash).wait_for_completion
1713
        rescue Exception => e
1714
            raise "Cannot create snapshot for VM: #{e.message}\n#{e.backtrace}"
1711
        vcenter_version = @vi_client.vim.serviceContent.about.apiVersion rescue nil
1712

  
1713
        if vcenter_version != "5.5"
1714
            begin
1715
                @item.CreateSnapshot_Task(snapshot_hash).wait_for_completion
1716
            rescue Exception => e
1717
                raise "Cannot create snapshot for VM: #{e.message}\n#{e.backtrace}"
1718
            end
1719
        else
1720
            # B#5045 - If vcenter is 5.5 the snapshot may take longer than
1721
            # 15 minutes and it does not report that it has finished using
1722
            # wait_for_completion we use an active wait instead with a
1723
            # timeout of 1440 minutes = 24 hours
1724
            @item.CreateSnapshot_Task(snapshot_hash)
1725

  
1726
            snapshot_created  = false
1727
            elapsed_minutes   = 0
1728

  
1729
            until snapshot_created || elapsed_minutes == 1440
1730
                if !!@item['snapshot']
1731
                    current_snapshot = @item['snapshot.currentSnapshot'] rescue nil
1732
                    snapshot_found = find_snapshot(@item['snapshot.rootSnapshotList'], snapshot_name)
1733
                    snapshot_created = !!snapshot_found && !!current_snapshot && current_snapshot._ref == snapshot_found._ref
1734
                end
1735
                sleep(60)
1736
                elapsed_minutes += 1
1737
            end
1715 1738
        end
1716 1739

  
1717 1740
        return snap_id

Also available in: Unified diff