Sha256: 6947d7438a568d00a91692353b593e1bfc983774fa6c63c920640484f65c2d48

Contents?: true

Size: 1.31 KB

Versions: 16

Compression:

Stored size: 1.31 KB

Contents

module Veewee
  module Provider
    module Virtualbox
      module BoxCommand

        def forwarding(name)
          command="#{@vboxcmd} showvminfo --details --machinereadable \"#{self.name}\""
          shell_results=shell_exec("#{command}")
          rules=shell_results.stdout.split(/\n/).grep(/^Forward/)
          result=nil
          rules.each do |rule|
            #Forwarding(0)
            nr=rule.split('=')[0].split('(')[1].split(')')[0].to_i + 1
            #  guestssh,tcp,,2222,,22
            details=rule.split('=')[1].split('"')[1].split(',')
            result = {
              :nr => nr,
              :name => details[0],
              :protocol => details[1],
              :host_ip => details[2],
              :host_port => details[3],
              :guest_ip => details[4],
              :guest_port => details[5]
            }
          end
          return result
        end

        def delete_forwarding(name)
          forward=self.forwarding(name)
          if self.running?
            command="#{@vboxcmd} controlvm \"#{self.name}\" natpf#{self.natinterface} delete \"#{name}\""
          else
            command="#{@vboxcmd} modifyvm \"#{self.name}\" --natpf#{self.natinterface} delete \"#{name}\""
          end
          shell_results=shell_exec("#{command}")
        end

      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
veewee-0.5.0.alpha4 lib/veewee/provider/virtualbox/box/helper/forwarding.rb
veewee-0.5.0.alpha3 lib/veewee/provider/virtualbox/box/helper/forwarding.rb
veewee-0.5.0.alpha2 lib/veewee/provider/virtualbox/box/helper/forwarding.rb
veewee-0.5.0.alpha1 lib/veewee/provider/virtualbox/box/helper/forwarding.rb
veewee-0.4.5.1 lib/veewee/provider/virtualbox/box/helper/forwarding.rb
veewee-0.4.5 lib/veewee/provider/virtualbox/box/helper/forwarding.rb
veewee-0.4.5.pre1 lib/veewee/provider/virtualbox/box/helper/forwarding.rb
veewee-0.4.4 lib/veewee/provider/virtualbox/box/helper/forwarding.rb
veewee-0.4.3 lib/veewee/provider/virtualbox/box/helper/forwarding.rb
veewee-0.4.2 lib/veewee/provider/virtualbox/box/helper/forwarding.rb
veewee-0.4.1 lib/veewee/provider/virtualbox/box/helper/forwarding.rb
veewee-0.4.0 lib/veewee/provider/virtualbox/box/helper/forwarding.rb
veewee-0.3.12 lib/veewee/provider/virtualbox/box/helper/forwarding.rb
veewee-0.3.11 lib/veewee/provider/virtualbox/box/helper/forwarding.rb
veewee-0.3.10 lib/veewee/provider/virtualbox/box/helper/forwarding.rb
veewee-0.3.9 lib/veewee/provider/virtualbox/box/helper/forwarding.rb