Class: VMCMicro::Switcher::Linux

Inherits:
Base
  • Object
show all
Defined in:
lib/mcf-vmc-plugin/micro/switcher/linux.rb

Instance Method Summary collapse

Methods inherited from Base

#domain, #initialize, #ip, #nat?, #offline!, #offline?, #online!, #ready?, #reset_to_nat!, #running?, #set_host_dns!, #start!, #unset_host_dns!, #vmx

Constructor Details

This class inherits a constructor from VMCMicro::Switcher::Base

Instance Method Details

#set_nameserver(domain, ip) ⇒ Object



4
5
6
7
8
# File 'lib/mcf-vmc-plugin/micro/switcher/linux.rb', line 4

def set_nameserver(domain, ip)
  VMCMicro.run_command("sudo", "sed -i'.backup' '1 i nameserver #{ip}' /etc/resolv.conf")
  # lock resolv.conf so Network Manager doesn't clear out the file when offline
  VMCMicro.run_command("sudo", "chattr +i /etc/resolv.conf")
end

#unset_nameserver(domain, ip) ⇒ Object



10
11
12
13
# File 'lib/mcf-vmc-plugin/micro/switcher/linux.rb', line 10

def unset_nameserver(domain, ip)
  VMCMicro.run_command("sudo", "chattr -i /etc/resolv.conf")
  VMCMicro.run_command("sudo", "sed -i'.backup' '/#{ip}/d' /etc/resolv.conf")
end