Class: Snap::Command
- Inherits:
-
Vagrant::Command::GroupBase
- Object
- Vagrant::Command::GroupBase
- Snap::Command
- Defined in:
- lib/vagrant_snap.rb
Instance Method Summary collapse
- #back(target = nil) ⇒ Object
- #delete(snapshot_name, target = nil) ⇒ Object
- #go(snapshot_name, target = nil) ⇒ Object
- #list(target = nil) ⇒ Object
- #take(target = nil) ⇒ Object
Instance Method Details
#back(target = nil) ⇒ Object
146 147 148 149 150 151 152 153 |
# File 'lib/vagrant_snap.rb', line 146 def back(target=nil) with_target(target) do |vmname, vagvmname| puts "[#{vagvmname}]" system "VBoxManage controlvm #{vmname} poweroff" system "VBoxManage snapshot #{vmname} restorecurrent" system "VBoxManage startvm #{vmname} --type headless" end end |
#delete(snapshot_name, target = nil) ⇒ Object
186 187 188 189 190 191 192 193 194 195 196 |
# File 'lib/vagrant_snap.rb', line 186 def delete(snapshot_name, target=nil) with_target(target) do |vmname, vagvmname| puts "[#{vagvmname}]" VBox::SnapShot.parse_tree( vmname ) if VBox::SnapShot.include?( snapshot_name ) system "VBoxManage snapshot #{vmname} delete #{snapshot_name}" else warn "#{snapshot_name} is not exist".red end end end |
#go(snapshot_name, target = nil) ⇒ Object
131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/vagrant_snap.rb', line 131 def go(snapshot_name, target=nil) with_target(target) do |vmname, vagvmname| puts "[#{vagvmname}]" VBox::SnapShot.parse_tree( vmname ) if VBox::SnapShot.include?( snapshot_name ) system "VBoxManage controlvm #{vmname} poweroff" system "VBoxManage snapshot #{vmname} restore #{snapshot_name}" system "VBoxManage startvm #{vmname} --type headless" else warn "#{snapshot_name} is not exist".red end end end |
#list(target = nil) ⇒ Object
117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/vagrant_snap.rb', line 117 def list(target=nil) with_target(target) do |vmname, vagvmname| puts "[#{vagvmname}]" VBox::SnapShot.parse_tree( vmname ) if VBox::SnapShot.tree result = VBox::SnapShot.show else result = "no snapshot" end puts result end end |
#take(target = nil) ⇒ Object
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 |
# File 'lib/vagrant_snap.rb', line 158 def take(target=nil) with_target(target) do |vmname, vagvmname| puts "[#{vagvmname}]" VBox::SnapShot.parse_tree( vmname ) if .name if VBox::SnapShot.include? .name warn "#{.name} is already exist".red next else new_name = .name end end unless new_name lastname = VBox::SnapShot.lastname new_name = if lastname.nil? "001" else n = lastname.succ n = n.succ while VBox::SnapShot.include? n n end end desc = .desc ? " --description '#{.desc}'" : "" system "VBoxManage snapshot #{vmname} take #{new_name} #{desc} --pause" end end |