Adds ability to set DNS entries on network create. Also allows 2 dns servers per network to be specified.

This commit is contained in:
Jason Koelker
2011-07-22 22:37:51 +00:00
committed by Tarmac
2 changed files with 20 additions and 8 deletions

View File

@@ -566,12 +566,14 @@ class NetworkCommands(object):
def create(self, label=None, fixed_range=None, num_networks=None, def create(self, label=None, fixed_range=None, num_networks=None,
network_size=None, multi_host=None, vlan_start=None, network_size=None, multi_host=None, vlan_start=None,
vpn_start=None, fixed_range_v6=None, gateway_v6=None, vpn_start=None, fixed_range_v6=None, gateway_v6=None,
flat_network_bridge=None, bridge_interface=None): flat_network_bridge=None, bridge_interface=None,
dns1=None, dns2=None):
"""Creates fixed ips for host by range """Creates fixed ips for host by range
arguments: label, fixed_range, [num_networks=FLAG], arguments: label, fixed_range, [num_networks=FLAG],
[network_size=FLAG], [multi_host=FLAG], [vlan_start=FLAG], [network_size=FLAG], [multi_host=FLAG], [vlan_start=FLAG],
[vpn_start=FLAG], [fixed_range_v6=FLAG], [gateway_v6=FLAG], [vpn_start=FLAG], [fixed_range_v6=FLAG], [gateway_v6=FLAG],
[flat_network_bridge=FLAG], [bridge_interface=FLAG] [flat_network_bridge=FLAG], [bridge_interface=FLAG]
[dns1=FLAG], [dns2]
If you wish to use a later argument fill in the gaps with ""s If you wish to use a later argument fill in the gaps with ""s
Ex: network create private 10.0.0.0/8 1 16 T "" "" "" "" xenbr1 eth1 Ex: network create private 10.0.0.0/8 1 16 T "" "" "" "" xenbr1 eth1
network create private 10.0.0.0/8 1 16 network create private 10.0.0.0/8 1 16
@@ -605,6 +607,8 @@ class NetworkCommands(object):
bridge_interface = FLAGS.flat_interface or FLAGS.vlan_interface bridge_interface = FLAGS.flat_interface or FLAGS.vlan_interface
if not gateway_v6: if not gateway_v6:
gateway_v6 = FLAGS.gateway_v6 gateway_v6 = FLAGS.gateway_v6
if not dns1 and FLAGS.flat_network_dns:
dns1 = FLAGS.flat_network_dns
net_manager = utils.import_object(FLAGS.network_manager) net_manager = utils.import_object(FLAGS.network_manager)
try: try:
@@ -619,24 +623,30 @@ class NetworkCommands(object):
cidr_v6=fixed_range_v6, cidr_v6=fixed_range_v6,
gateway_v6=gateway_v6, gateway_v6=gateway_v6,
bridge=flat_network_bridge, bridge=flat_network_bridge,
bridge_interface=bridge_interface) bridge_interface=bridge_interface,
dns1=dns1,
dns2=dns2)
except ValueError, e: except ValueError, e:
print e print e
raise e raise e
def list(self): def list(self):
"""List all created networks""" """List all created networks"""
print "%-18s\t%-15s\t%-15s\t%-15s\t%-15s\t%-15s" % (_('network'), print "%-18s\t%-15s\t%-15s\t%-15s\t%-15s\t%-15s\t%-15s" % (
_('network'),
_('netmask'), _('netmask'),
_('start address'), _('start address'),
_('DNS'), _('DNS1'),
_('DNS2'),
_('VlanID'), _('VlanID'),
'project') 'project')
for network in db.network_get_all(context.get_admin_context()): for network in db.network_get_all(context.get_admin_context()):
print "%-18s\t%-15s\t%-15s\t%-15s\t%-15s\t%-15s" % (network.cidr, print "%-18s\t%-15s\t%-15s\t%-15s\t%-15s\t%-15s\t%-15s" % (
network.cidr,
network.netmask, network.netmask,
network.dhcp_start, network.dhcp_start,
network.dns, network.dns1,
network.dns2,
network.vlan, network.vlan,
network.project_id) network.project_id)

View File

@@ -55,7 +55,8 @@ networks = [{'id': 0,
'bridge_interface': 'fake_fa0', 'bridge_interface': 'fake_fa0',
'gateway': '192.168.0.1', 'gateway': '192.168.0.1',
'broadcast': '192.168.0.255', 'broadcast': '192.168.0.255',
'dns': '192.168.0.1', 'dns1': '192.168.0.1',
'dns2': '192.168.0.2',
'vlan': None, 'vlan': None,
'host': None, 'host': None,
'project_id': 'fake_project', 'project_id': 'fake_project',
@@ -73,7 +74,8 @@ networks = [{'id': 0,
'bridge_interface': 'fake_fa1', 'bridge_interface': 'fake_fa1',
'gateway': '192.168.1.1', 'gateway': '192.168.1.1',
'broadcast': '192.168.1.255', 'broadcast': '192.168.1.255',
'dns': '192.168.0.1', 'dns1': '192.168.0.1',
'dns2': '192.168.0.2',
'vlan': None, 'vlan': None,
'host': None, 'host': None,
'project_id': 'fake_project', 'project_id': 'fake_project',