Skip to content

Use XAPI to edit DNS entries within xsconsole #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 10 additions & 12 deletions XSConsoleData.py
Original file line number Diff line number Diff line change
Expand Up @@ -524,18 +524,16 @@ def SaveToResolveConf(self):
# Double-check authentication
Auth.Inst().AssertAuthenticated()

file = None
try:
file = open("/etc/resolv.conf", "w")
now = datetime.datetime.now().strftime("; created by xsconsole %I:%M%p on %B %d, %Y\n")
file.write(now)
for other in self.dns.othercontents([]):
file.write(other+"\n")
for server in self.dns.nameservers([]):
file.write("nameserver "+server+"\n")
finally:
if file is not None: file.close()
self.UpdateFromResolveConf()
for pif in Data.Inst().derived.managementpifs([]):
ipv6 = pif['primary_address_type'].lower() == 'ipv6'
mode = pif['ipv6_configuration_mode'] if ipv6 else pif['ip_configuration_mode']
ip = pif['IPv6'][0].split('/')[0] if ipv6 else pif['IP']
netmask = pif['IPv6'][0].split('/')[1] if ipv6 else pif['netmask']
gw = pif['ipv6_gateway'] if ipv6 else pif['gateway']
dns = ','.join(self.dns.nameservers([]))
self.ReconfigureManagement(pif, mode, ip, netmask, gw, dns)

self.UpdateFromResolveConf()


def ScanDmiDecode(self, inLines):
Expand Down