2014-03-23 23:12:07 +01:00
|
|
|
from bootstrapvz.base import Task
|
|
|
|
from .. import phases
|
2014-02-19 22:14:17 +01:00
|
|
|
import os
|
2013-07-01 23:54:18 +02:00
|
|
|
|
|
|
|
|
|
|
|
class RemoveDNSInfo(Task):
|
|
|
|
description = 'Removing resolv.conf'
|
|
|
|
phase = phases.system_modification
|
|
|
|
|
2014-01-05 15:57:11 +01:00
|
|
|
@classmethod
|
|
|
|
def run(cls, info):
|
2014-02-07 17:42:45 +00:00
|
|
|
if os.path.isfile(os.path.join(info.root, 'etc/resolv.conf')):
|
2014-02-19 22:14:17 +01:00
|
|
|
os.remove(os.path.join(info.root, 'etc/resolv.conf'))
|
2013-07-01 23:54:18 +02:00
|
|
|
|
|
|
|
|
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):
|
2014-02-07 17:42:45 +00:00
|
|
|
if os.path.isfile(os.path.join(info.root, 'etc/hostname')):
|
2014-02-19 22:14:17 +01:00
|
|
|
os.remove(os.path.join(info.root, 'etc/hostname'))
|
2013-09-22 15:41:43 +02:00
|
|
|
|
|
|
|
|
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):
|
2014-02-23 20:14:23 +01:00
|
|
|
network_config_path = os.path.join(os.path.dirname(__file__), 'network-configuration.json')
|
2014-03-23 23:12:07 +01:00
|
|
|
from ..tools import config_get
|
2014-02-23 21:14:21 +01:00
|
|
|
if_config = config_get(network_config_path, [info.release_codename])
|
2014-02-23 20:14:23 +01:00
|
|
|
|
2013-07-01 23:54:18 +02:00
|
|
|
interfaces_path = os.path.join(info.root, 'etc/network/interfaces')
|
|
|
|
with open(interfaces_path, 'a') as interfaces:
|
2014-02-23 20:14:23 +01:00
|
|
|
interfaces.write('\n'.join(if_config) + '\n')
|