2013-07-01 23:54:18 +02:00
|
|
|
from base import Task
|
|
|
|
from common import phases
|
|
|
|
import os.path
|
|
|
|
|
|
|
|
|
|
|
|
class RemoveDNSInfo(Task):
|
|
|
|
description = 'Removing resolv.conf'
|
|
|
|
phase = phases.system_modification
|
|
|
|
|
2014-01-05 15:57:11 +01:00
|
|
|
@classmethod
|
|
|
|
def run(cls, info):
|
2013-07-01 23:54:18 +02:00
|
|
|
from os import remove
|
|
|
|
remove(os.path.join(info.root, 'etc/resolv.conf'))
|
|
|
|
|
|
|
|
|
2013-09-22 15:41:43 +02:00
|
|
|
class RemoveHostname(Task):
|
|
|
|
description = 'Removing the hostname file'
|
|
|
|
phase = phases.system_modification
|
|
|
|
|
2014-01-05 15:57:11 +01:00
|
|
|
@classmethod
|
|
|
|
def run(cls, info):
|
2013-09-22 15:41:43 +02:00
|
|
|
from os import remove
|
|
|
|
remove(os.path.join(info.root, 'etc/hostname'))
|
|
|
|
|
|
|
|
|
2013-07-01 23:54:18 +02:00
|
|
|
class ConfigureNetworkIF(Task):
|
|
|
|
description = 'Configuring network interfaces'
|
|
|
|
phase = phases.system_modification
|
|
|
|
|
2014-01-05 15:57:11 +01:00
|
|
|
@classmethod
|
|
|
|
def run(cls, info):
|
2013-07-01 23:54:18 +02:00
|
|
|
interfaces_path = os.path.join(info.root, 'etc/network/interfaces')
|
2014-01-09 21:25:22 +01:00
|
|
|
if_config = []
|
|
|
|
with open('common/tasks/network-configuration.json') as stream:
|
|
|
|
import json
|
|
|
|
if_config = json.loads(stream.read())
|
2013-07-01 23:54:18 +02:00
|
|
|
with open(interfaces_path, 'a') as interfaces:
|
2014-01-09 21:25:22 +01:00
|
|
|
interfaces.write(''.join(if_config.get(info.manifest.system['release'])))
|