cli: add bind option
This commit is contained in:
parent
e293180d6e
commit
730f6f2744
|
@ -29,6 +29,8 @@ def main():
|
|||
'dafault: stable')
|
||||
parser.add_argument('-a', '--address', metavar="x.x.y.z",
|
||||
help='static ip address')
|
||||
parser.add_argument('-bind', '--bind', metavar="/path/to/bind",
|
||||
help='bind mount folder or device')
|
||||
parser.add_argument('-m', '--mode',
|
||||
default='private',
|
||||
choices=['private', 'zone', 'bridge'],
|
||||
|
|
|
@ -40,7 +40,8 @@ def use_aptcacherng():
|
|||
|
||||
class Machine(object):
|
||||
def __init__(self, name, release='stable', mode='private', address=None,
|
||||
proxy=False, macaddress=None, privateoff=False, **kwargs):
|
||||
proxy=False, macaddress=None, privateoff=False, bind=None,
|
||||
**kwargs):
|
||||
|
||||
if isinstance(name, list):
|
||||
self.name = name[0]
|
||||
|
@ -53,6 +54,7 @@ class Machine(object):
|
|||
self.path = os.path.join(self.basepath, self.name)
|
||||
self.release = release
|
||||
self.address = address
|
||||
self.bind = bind
|
||||
self.macaddress = macaddress
|
||||
self.proxy = proxy
|
||||
self.mode = mode
|
||||
|
|
|
@ -35,6 +35,10 @@ private_off = '''
|
|||
[Exec]
|
||||
PrivateUsers=no'''
|
||||
|
||||
bind_mount = '''
|
||||
[Files]
|
||||
Bind=%s
|
||||
'''
|
||||
|
||||
def get_default_gateway(macaddress):
|
||||
import socket
|
||||
|
@ -65,6 +69,12 @@ class MachineConfig:
|
|||
if self.machine.privateoff:
|
||||
with open(self.machine.config_file, 'a') as cf:
|
||||
cf.write(private_off)
|
||||
if self.machine.bind:
|
||||
p = self.machine.bind
|
||||
if not os.path.isdir(p):
|
||||
os.makedirs(p)
|
||||
with open(self.machine.config_file, 'a') as cf:
|
||||
cf.write(bind_mount % self.machine.bind)
|
||||
|
||||
|
||||
def netconf(self):
|
||||
|
|
Loading…
Reference in New Issue