Sha256: 362f7782b205e6b89541359553d588c5139dca14e15134d0eca3074028235907

Contents?: true

Size: 952 Bytes

Versions: 2

Compression:

Stored size: 952 Bytes

Contents

module VagrantPlugins
  module GuestVyOS
    module Cap
      class RemovePublicKey
        def self.remove_public_key(machine, contents)
          contents = contents.chomp

          key_type, key_value, key_name = contents.split()

          commands = <<-EOS
source /opt/vyatta/etc/functions/script-template
show system login user vagrant authentication public-keys #{key_name} key | grep #{key_value} || exit 0
delete system login user vagrant authentication public-keys #{key_name}
commit
save
          EOS

          temp = Tempfile.new("vagrant")
          temp.binmode
          temp.write(commands)
          temp.close

          machine.communicate.tap do |comm|
            comm.upload(temp.path, "/tmp/vagrant-remove-public-key")
            comm.execute("bash /tmp/vagrant-remove-public-key")
            comm.execute("rm -f /tmp/vagrant-remove-public-key")
          end

          temp.unlink

        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
vagrant-vyos-1.1.1 lib/vagrant-vyos/cap/remove_public_key.rb
vagrant-vyos-1.1.0 lib/vagrant-vyos/cap/remove_public_key.rb