Merge lp:~rvb/maas/subnet-creation into lp:~maas-maintainers/maas/networking

Proposed by Raphaël Badin
Status: Merged
Approved by: Raphaël Badin
Approved revision: no longer in the source branch.
Merged at revision: 4123
Proposed branch: lp:~rvb/maas/subnet-creation
Merge into: lp:~maas-maintainers/maas/networking
Prerequisite: lp:~rvb/maas/connect-interf-subnet
Diff against target: 151 lines (+54/-13)
5 files modified
src/maasserver/models/interface.py (+7/-3)
src/maasserver/models/subnet.py (+12/-0)
src/maasserver/models/tests/test_interface.py (+21/-7)
src/maasserver/models/tests/test_subnet.py (+10/-0)
src/metadataserver/models/tests/test_commissioningscript.py (+4/-3)
To merge this branch: bzr merge lp:~rvb/maas/subnet-creation
Reviewer Review Type Date Requested Status
Raphaël Badin (community) Approve
Blake Rouse Pending
Review via email: mp+265415@code.launchpad.net

This proposal supersedes a proposal from 2015-07-20.

Commit message

During commissioning, create unknown Subnets.

To post a comment you must log in.
Revision history for this message
Blake Rouse (blake-rouse) wrote : Posted in a previous version of this proposal

Looks good. Other than the comment below.

review: Approve
Revision history for this message
Raphaël Badin (rvb) : Posted in a previous version of this proposal
Revision history for this message
Raphaël Badin (rvb) wrote :

Just changed the target branch. Self-approving.

review: Approve
Revision history for this message
MAAS Lander (maas-lander) wrote :
Download full text (83.0 KiB)

The attempt to merge lp:~rvb/maas/subnet-creation into lp:~maas-maintainers/maas/networking failed. Below is the output from the failed tests.

Ign http://security.ubuntu.com trusty-security InRelease
Hit http://security.ubuntu.com trusty-security Release.gpg
Ign http://nova.clouds.archive.ubuntu.com trusty InRelease
Ign http://nova.clouds.archive.ubuntu.com trusty-updates InRelease
Hit http://security.ubuntu.com trusty-security Release
Hit http://nova.clouds.archive.ubuntu.com trusty Release.gpg
Hit http://nova.clouds.archive.ubuntu.com trusty-updates Release.gpg
Hit http://nova.clouds.archive.ubuntu.com trusty Release
Hit http://nova.clouds.archive.ubuntu.com trusty-updates Release
Hit http://security.ubuntu.com trusty-security/main Sources
Hit http://security.ubuntu.com trusty-security/universe Sources
Hit http://security.ubuntu.com trusty-security/main amd64 Packages
Hit http://security.ubuntu.com trusty-security/universe amd64 Packages
Hit http://security.ubuntu.com trusty-security/main Translation-en
Hit http://security.ubuntu.com trusty-security/universe Translation-en
Hit http://nova.clouds.archive.ubuntu.com trusty/main Sources
Hit http://nova.clouds.archive.ubuntu.com trusty/universe Sources
Hit http://nova.clouds.archive.ubuntu.com trusty/main amd64 Packages
Hit http://nova.clouds.archive.ubuntu.com trusty/universe amd64 Packages
Hit http://nova.clouds.archive.ubuntu.com trusty/main Translation-en
Hit http://nova.clouds.archive.ubuntu.com trusty/universe Translation-en
Hit http://nova.clouds.archive.ubuntu.com trusty-updates/main Sources
Hit http://nova.clouds.archive.ubuntu.com trusty-updates/universe Sources
Hit http://nova.clouds.archive.ubuntu.com trusty-updates/main amd64 Packages
Hit http://nova.clouds.archive.ubuntu.com trusty-updates/universe amd64 Packages
Hit http://nova.clouds.archive.ubuntu.com trusty-updates/main Translation-en
Hit http://nova.clouds.archive.ubuntu.com trusty-updates/universe Translation-en
Ign http://nova.clouds.archive.ubuntu.com trusty/main Translation-en_US
Ign http://nova.clouds.archive.ubuntu.com trusty/universe Translation-en_US
Reading package lists...
sudo DEBIAN_FRONTEND=noninteractive apt-get -y \
     --no-install-recommends install apache2 authbind bind9 bind9utils build-essential bzr-builddeb chromium-browser chromium-chromedriver curl daemontools debhelper dh-apport dh-systemd distro-info dnsutils firefox freeipmi-tools git gjs ipython isc-dhcp-common libjs-angularjs libjs-jquery libjs-jquery-hotkeys libjs-yui3-full libjs-yui3-min libpq-dev make nodejs-legacy npm pep8 phantomjs postgresql pyflakes python-apt python-bson python-bzrlib python-convoy python-coverage python-crochet python-cssselect python-curtin python-dev python-distro-info python-django python-django-piston python-django-south python-djorm-ext-pgarray python-docutils python-extras python-fixtures python-flake8 python-formencode python-hivex python-httplib2 python-jinja2 python-jsonschema python-lockfile python-lxml python-mock python-netaddr python-netifaces python-nose python-oauth python-openssl python-paramiko python-pexpect python-pip python-pocket-lint python-psycopg2 python-pyinotify python-pyparsing python-seamicroc...

Revision history for this message
MAAS Lander (maas-lander) wrote :
Download full text (83.1 KiB)

The attempt to merge lp:~rvb/maas/subnet-creation into lp:~maas-maintainers/maas/networking failed. Below is the output from the failed tests.

Ign http://security.ubuntu.com trusty-security InRelease
Hit http://security.ubuntu.com trusty-security Release.gpg
Ign http://nova.clouds.archive.ubuntu.com trusty InRelease
Hit http://security.ubuntu.com trusty-security Release
Ign http://nova.clouds.archive.ubuntu.com trusty-updates InRelease
Hit http://nova.clouds.archive.ubuntu.com trusty Release.gpg
Get:1 http://nova.clouds.archive.ubuntu.com trusty-updates Release.gpg [933 B]
Hit http://nova.clouds.archive.ubuntu.com trusty Release
Get:2 http://nova.clouds.archive.ubuntu.com trusty-updates Release [63.5 kB]
Hit http://security.ubuntu.com trusty-security/main Sources
Hit http://security.ubuntu.com trusty-security/universe Sources
Hit http://nova.clouds.archive.ubuntu.com trusty/main Sources
Hit http://security.ubuntu.com trusty-security/main amd64 Packages
Hit http://security.ubuntu.com trusty-security/universe amd64 Packages
Hit http://nova.clouds.archive.ubuntu.com trusty/universe Sources
Hit http://security.ubuntu.com trusty-security/main Translation-en
Hit http://nova.clouds.archive.ubuntu.com trusty/main amd64 Packages
Hit http://security.ubuntu.com trusty-security/universe Translation-en
Hit http://nova.clouds.archive.ubuntu.com trusty/universe amd64 Packages
Hit http://nova.clouds.archive.ubuntu.com trusty/main Translation-en
Hit http://nova.clouds.archive.ubuntu.com trusty/universe Translation-en
Get:3 http://nova.clouds.archive.ubuntu.com trusty-updates/main Sources [215 kB]
Get:4 http://nova.clouds.archive.ubuntu.com trusty-updates/universe Sources [125 kB]
Get:5 http://nova.clouds.archive.ubuntu.com trusty-updates/main amd64 Packages [570 kB]
Get:6 http://nova.clouds.archive.ubuntu.com trusty-updates/universe amd64 Packages [296 kB]
Hit http://nova.clouds.archive.ubuntu.com trusty-updates/main Translation-en
Hit http://nova.clouds.archive.ubuntu.com trusty-updates/universe Translation-en
Ign http://nova.clouds.archive.ubuntu.com trusty/main Translation-en_US
Ign http://nova.clouds.archive.ubuntu.com trusty/universe Translation-en_US
Fetched 1,270 kB in 3s (342 kB/s)
Reading package lists...
sudo DEBIAN_FRONTEND=noninteractive apt-get -y \
     --no-install-recommends install apache2 authbind bind9 bind9utils build-essential bzr-builddeb chromium-browser chromium-chromedriver curl daemontools debhelper dh-apport dh-systemd distro-info dnsutils firefox freeipmi-tools git gjs ipython isc-dhcp-common libjs-angularjs libjs-jquery libjs-jquery-hotkeys libjs-yui3-full libjs-yui3-min libpq-dev make nodejs-legacy npm pep8 phantomjs postgresql pyflakes python-apt python-bson python-bzrlib python-convoy python-coverage python-crochet python-cssselect python-curtin python-dev python-distro-info python-django python-django-piston python-django-south python-djorm-ext-pgarray python-docutils python-extras python-fixtures python-flake8 python-formencode python-hivex python-httplib2 python-jinja2 python-jsonschema python-lockfile python-lxml python-mock python-netaddr python-netifaces python-nose python-oauth python-openssl python-paramiko python-pexp...

Revision history for this message
MAAS Lander (maas-lander) wrote :
Download full text (56.2 KiB)

The attempt to merge lp:~rvb/maas/subnet-creation into lp:~maas-maintainers/maas/networking failed. Below is the output from the failed tests.

Ign http://security.ubuntu.com trusty-security InRelease
Hit http://security.ubuntu.com trusty-security Release.gpg
Ign http://nova.clouds.archive.ubuntu.com trusty InRelease
Hit http://security.ubuntu.com trusty-security Release
Ign http://nova.clouds.archive.ubuntu.com trusty-updates InRelease
Hit http://nova.clouds.archive.ubuntu.com trusty Release.gpg
Get:1 http://nova.clouds.archive.ubuntu.com trusty-updates Release.gpg [933 B]
Hit http://nova.clouds.archive.ubuntu.com trusty Release
Get:2 http://nova.clouds.archive.ubuntu.com trusty-updates Release [63.5 kB]
Hit http://security.ubuntu.com trusty-security/main Sources
Hit http://security.ubuntu.com trusty-security/universe Sources
Hit http://security.ubuntu.com trusty-security/main amd64 Packages
Hit http://nova.clouds.archive.ubuntu.com trusty/main Sources
Hit http://security.ubuntu.com trusty-security/universe amd64 Packages
Hit http://security.ubuntu.com trusty-security/main Translation-en
Hit http://security.ubuntu.com trusty-security/universe Translation-en
Hit http://nova.clouds.archive.ubuntu.com trusty/universe Sources
Hit http://nova.clouds.archive.ubuntu.com trusty/main amd64 Packages
Hit http://nova.clouds.archive.ubuntu.com trusty/universe amd64 Packages
Hit http://nova.clouds.archive.ubuntu.com trusty/main Translation-en
Hit http://nova.clouds.archive.ubuntu.com trusty/universe Translation-en
Ign http://nova.clouds.archive.ubuntu.com trusty/main Translation-en_US
Ign http://nova.clouds.archive.ubuntu.com trusty/universe Translation-en_US
Get:3 http://nova.clouds.archive.ubuntu.com trusty-updates/main Sources [215 kB]
Get:4 http://nova.clouds.archive.ubuntu.com trusty-updates/universe Sources [125 kB]
Get:5 http://nova.clouds.archive.ubuntu.com trusty-updates/main amd64 Packages [570 kB]
Get:6 http://nova.clouds.archive.ubuntu.com trusty-updates/universe amd64 Packages [296 kB]
Hit http://nova.clouds.archive.ubuntu.com trusty-updates/main Translation-en
Hit http://nova.clouds.archive.ubuntu.com trusty-updates/universe Translation-en
Fetched 1,270 kB in 3s (348 kB/s)
Reading package lists...
sudo DEBIAN_FRONTEND=noninteractive apt-get -y \
     --no-install-recommends install apache2 authbind bind9 bind9utils build-essential bzr-builddeb chromium-browser chromium-chromedriver curl daemontools debhelper dh-apport dh-systemd distro-info dnsutils firefox freeipmi-tools git gjs ipython isc-dhcp-common libjs-angularjs libjs-jquery libjs-jquery-hotkeys libjs-yui3-full libjs-yui3-min libpq-dev make nodejs-legacy npm pep8 phantomjs postgresql pyflakes python-apt python-bson python-bzrlib python-convoy python-coverage python-crochet python-cssselect python-curtin python-dev python-distro-info python-django python-django-piston python-django-south python-djorm-ext-pgarray python-docutils python-extras python-fixtures python-flake8 python-formencode python-hivex python-httplib2 python-jinja2 python-jsonschema python-lockfile python-lxml python-mock python-netaddr python-netifaces python-nose python-oauth python-openssl python-paramiko python-pexp...

Revision history for this message
MAAS Lander (maas-lander) wrote :
Download full text (48.8 KiB)

The attempt to merge lp:~rvb/maas/subnet-creation into lp:~maas-maintainers/maas/networking failed. Below is the output from the failed tests.

Ign http://security.ubuntu.com trusty-security InRelease
Hit http://security.ubuntu.com trusty-security Release.gpg
Hit http://security.ubuntu.com trusty-security Release
Ign http://nova.clouds.archive.ubuntu.com trusty InRelease
Ign http://nova.clouds.archive.ubuntu.com trusty-updates InRelease
Hit http://nova.clouds.archive.ubuntu.com trusty Release.gpg
Hit http://nova.clouds.archive.ubuntu.com trusty-updates Release.gpg
Hit http://nova.clouds.archive.ubuntu.com trusty Release
Hit http://nova.clouds.archive.ubuntu.com trusty-updates Release
Hit http://security.ubuntu.com trusty-security/main Sources
Hit http://security.ubuntu.com trusty-security/universe Sources
Hit http://nova.clouds.archive.ubuntu.com trusty/main Sources
Hit http://security.ubuntu.com trusty-security/main amd64 Packages
Hit http://security.ubuntu.com trusty-security/universe amd64 Packages
Hit http://nova.clouds.archive.ubuntu.com trusty/universe Sources
Hit http://security.ubuntu.com trusty-security/main Translation-en
Hit http://security.ubuntu.com trusty-security/universe Translation-en
Hit http://nova.clouds.archive.ubuntu.com trusty/main amd64 Packages
Hit http://nova.clouds.archive.ubuntu.com trusty/universe amd64 Packages
Hit http://nova.clouds.archive.ubuntu.com trusty/main Translation-en
Hit http://nova.clouds.archive.ubuntu.com trusty/universe Translation-en
Hit http://nova.clouds.archive.ubuntu.com trusty-updates/main Sources
Hit http://nova.clouds.archive.ubuntu.com trusty-updates/universe Sources
Hit http://nova.clouds.archive.ubuntu.com trusty-updates/main amd64 Packages
Hit http://nova.clouds.archive.ubuntu.com trusty-updates/universe amd64 Packages
Hit http://nova.clouds.archive.ubuntu.com trusty-updates/main Translation-en
Hit http://nova.clouds.archive.ubuntu.com trusty-updates/universe Translation-en
Ign http://nova.clouds.archive.ubuntu.com trusty/main Translation-en_US
Ign http://nova.clouds.archive.ubuntu.com trusty/universe Translation-en_US
Reading package lists...
sudo DEBIAN_FRONTEND=noninteractive apt-get -y \
     --no-install-recommends install apache2 authbind bind9 bind9utils build-essential bzr-builddeb chromium-browser chromium-chromedriver curl daemontools debhelper dh-apport dh-systemd distro-info dnsutils firefox freeipmi-tools git gjs ipython isc-dhcp-common libjs-angularjs libjs-jquery libjs-jquery-hotkeys libjs-yui3-full libjs-yui3-min libpq-dev make nodejs-legacy npm pep8 phantomjs postgresql pyflakes python-apt python-bson python-bzrlib python-convoy python-coverage python-crochet python-cssselect python-curtin python-dev python-distro-info python-django python-django-piston python-django-south python-djorm-ext-pgarray python-docutils python-extras python-fixtures python-flake8 python-formencode python-hivex python-httplib2 python-jinja2 python-jsonschema python-lockfile python-lxml python-mock python-netaddr python-netifaces python-nose python-oauth python-openssl python-paramiko python-pexpect python-pip python-pocket-lint python-psycopg2 python-pyinotify python-pyparsing python-seamicroc...

Revision history for this message
MAAS Lander (maas-lander) wrote :
Download full text (83.1 KiB)

The attempt to merge lp:~rvb/maas/subnet-creation into lp:~maas-maintainers/maas/networking failed. Below is the output from the failed tests.

Ign http://security.ubuntu.com trusty-security InRelease
Hit http://security.ubuntu.com trusty-security Release.gpg
Hit http://security.ubuntu.com trusty-security Release
Ign http://nova.clouds.archive.ubuntu.com trusty InRelease
Ign http://nova.clouds.archive.ubuntu.com trusty-updates InRelease
Hit http://nova.clouds.archive.ubuntu.com trusty Release.gpg
Get:1 http://nova.clouds.archive.ubuntu.com trusty-updates Release.gpg [933 B]
Hit http://nova.clouds.archive.ubuntu.com trusty Release
Get:2 http://nova.clouds.archive.ubuntu.com trusty-updates Release [63.5 kB]
Hit http://security.ubuntu.com trusty-security/main Sources
Hit http://security.ubuntu.com trusty-security/universe Sources
Hit http://security.ubuntu.com trusty-security/main amd64 Packages
Hit http://security.ubuntu.com trusty-security/universe amd64 Packages
Hit http://nova.clouds.archive.ubuntu.com trusty/main Sources
Hit http://security.ubuntu.com trusty-security/main Translation-en
Hit http://security.ubuntu.com trusty-security/universe Translation-en
Hit http://nova.clouds.archive.ubuntu.com trusty/universe Sources
Hit http://nova.clouds.archive.ubuntu.com trusty/main amd64 Packages
Hit http://nova.clouds.archive.ubuntu.com trusty/universe amd64 Packages
Hit http://nova.clouds.archive.ubuntu.com trusty/main Translation-en
Hit http://nova.clouds.archive.ubuntu.com trusty/universe Translation-en
Ign http://nova.clouds.archive.ubuntu.com trusty/main Translation-en_US
Ign http://nova.clouds.archive.ubuntu.com trusty/universe Translation-en_US
Get:3 http://nova.clouds.archive.ubuntu.com trusty-updates/main Sources [215 kB]
Get:4 http://nova.clouds.archive.ubuntu.com trusty-updates/universe Sources [125 kB]
Get:5 http://nova.clouds.archive.ubuntu.com trusty-updates/main amd64 Packages [570 kB]
Get:6 http://nova.clouds.archive.ubuntu.com trusty-updates/universe amd64 Packages [296 kB]
Hit http://nova.clouds.archive.ubuntu.com trusty-updates/main Translation-en
Hit http://nova.clouds.archive.ubuntu.com trusty-updates/universe Translation-en
Fetched 1,270 kB in 9s (140 kB/s)
Reading package lists...
sudo DEBIAN_FRONTEND=noninteractive apt-get -y \
     --no-install-recommends install apache2 authbind bind9 bind9utils build-essential bzr-builddeb chromium-browser chromium-chromedriver curl daemontools debhelper dh-apport dh-systemd distro-info dnsutils firefox freeipmi-tools git gjs ipython isc-dhcp-common libjs-angularjs libjs-jquery libjs-jquery-hotkeys libjs-yui3-full libjs-yui3-min libpq-dev make nodejs-legacy npm pep8 phantomjs postgresql pyflakes python-apt python-bson python-bzrlib python-convoy python-coverage python-crochet python-cssselect python-curtin python-dev python-distro-info python-django python-django-piston python-django-south python-djorm-ext-pgarray python-docutils python-extras python-fixtures python-flake8 python-formencode python-hivex python-httplib2 python-jinja2 python-jsonschema python-lockfile python-lxml python-mock python-netaddr python-netifaces python-nose python-oauth python-openssl python-paramiko python-pexp...

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/maasserver/models/interface.py'
--- src/maasserver/models/interface.py 2015-07-20 09:03:26 +0000
+++ src/maasserver/models/interface.py 2015-07-22 10:47:10 +0000
@@ -42,6 +42,7 @@
42 VerboseRegexValidator,42 VerboseRegexValidator,
43)43)
44from maasserver.models.cleansave import CleanSave44from maasserver.models.cleansave import CleanSave
45from maasserver.models.space import Space
45from maasserver.models.timestampedmodel import TimestampedModel46from maasserver.models.timestampedmodel import TimestampedModel
46from netaddr import IPNetwork47from netaddr import IPNetwork
47from provisioningserver.logger import get_maas_logger48from provisioningserver.logger import get_maas_logger
@@ -140,10 +141,13 @@
140 try:141 try:
141 subnet = Subnet.objects.get(cidr=cidr, vlan__fabric=fabric)142 subnet = Subnet.objects.get(cidr=cidr, vlan__fabric=fabric)
142 except Subnet.DoesNotExist:143 except Subnet.DoesNotExist:
143 maaslog.warning(144 vlan = fabric.get_default_vlan()
144 "Skipping unknown subnet %s connected to interface %s "145 space = Space.objects.get_default_space()
146 subnet = Subnet.objects.create_from_cidr(
147 cidr=cidr, vlan=vlan, space=space)
148 maaslog.info(
149 "Creating subnet %s connected to interface %s "
145 "of node %s.", cidr, self, self.get_node())150 "of node %s.", cidr, self, self.get_node())
146 continue
147151
148 # This code needs to deal with both:152 # This code needs to deal with both:
149 # - legacy statically configured IPs (subnet=None, mac=mac) for153 # - legacy statically configured IPs (subnet=None, mac=mac) for
150154
=== modified file 'src/maasserver/models/subnet.py'
--- src/maasserver/models/subnet.py 2015-06-26 01:03:50 +0000
+++ src/maasserver/models/subnet.py 2015-07-22 10:47:10 +0000
@@ -22,6 +22,7 @@
22from django.db.models import (22from django.db.models import (
23 CharField,23 CharField,
24 ForeignKey,24 ForeignKey,
25 Manager,
25 PROTECT,26 PROTECT,
26)27)
27from djorm_pgarray.fields import ArrayField28from djorm_pgarray.fields import ArrayField
@@ -46,6 +47,15 @@
46 return VLAN.objects.get_default_vlan()47 return VLAN.objects.get_default_vlan()
4748
4849
50class SubnetManager(Manager):
51 """Manager for :class:`Subnet` model."""
52
53 def create_from_cidr(self, cidr, vlan, space):
54 """Create a subnet from the given CIDR."""
55 name = "subnet-" + unicode(cidr)
56 return self.create(name=name, cidr=cidr, vlan=vlan, space=space)
57
58
49class Subnet(CleanSave, TimestampedModel):59class Subnet(CleanSave, TimestampedModel):
5060
51 class Meta(DefaultMeta):61 class Meta(DefaultMeta):
@@ -54,6 +64,8 @@
54 ('name', 'space'),64 ('name', 'space'),
55 )65 )
5666
67 objects = SubnetManager()
68
57 name = CharField(69 name = CharField(
58 blank=False, editable=True, max_length=255,70 blank=False, editable=True, max_length=255,
59 validators=[SUBNET_NAME_VALIDATOR],71 validators=[SUBNET_NAME_VALIDATOR],
6072
=== modified file 'src/maasserver/models/tests/test_interface.py'
--- src/maasserver/models/tests/test_interface.py 2015-07-17 11:14:36 +0000
+++ src/maasserver/models/tests/test_interface.py 2015-07-22 10:47:10 +0000
@@ -20,7 +20,10 @@
20 IPADDRESS_TYPE,20 IPADDRESS_TYPE,
21)21)
22from maasserver.models import (22from maasserver.models import (
23 Fabric,
23 MACAddress,24 MACAddress,
25 Space,
26 Subnet,
24 VLAN,27 VLAN,
25)28)
26from maasserver.models.interface import (29from maasserver.models.interface import (
@@ -192,16 +195,27 @@
192195
193class UpdateIpAddressesTest(MAASServerTestCase):196class UpdateIpAddressesTest(MAASServerTestCase):
194197
195 def test__ignores_missing_subnet(self):198 def test__creates_missing_subnet(self):
196 mac = factory.make_MACAddress_with_Node()199 mac = factory.make_MACAddress_with_Node()
197 interface = factory.make_Interface(200 interface = factory.make_Interface(
198 mac=mac, type=INTERFACE_TYPE.PHYSICAL)201 mac=mac, type=INTERFACE_TYPE.PHYSICAL)
199 cidr_list = [202 network = factory.make_ip4_or_6_network()
200 unicode(factory.make_ip4_or_6_network()) for _ in range(3)]203 cidr = unicode(network)
201204 address = unicode(network.ip)
202 interface.update_ip_addresses(cidr_list)205 interface.update_ip_addresses([cidr])
203206
204 self.assertItemsEqual([], interface.ip_addresses.all())207 default_fabric = Fabric.objects.get_default_fabric()
208 default_space = Space.objects.get_default_space()
209 subnets = Subnet.objects.filter(
210 cidr=unicode(network.cidr), vlan__fabric=default_fabric,
211 space=default_space)
212 self.assertEqual(1, len(subnets))
213 self.assertEqual(1, interface.ip_addresses.count())
214 self.assertThat(
215 interface.ip_addresses.first(),
216 MatchesStructure.byEquality(
217 alloc_type=IPADDRESS_TYPE.DHCP, subnet=subnets[0],
218 ip=address))
205219
206 def test__creates_dhcp_ip_addresses(self):220 def test__creates_dhcp_ip_addresses(self):
207 mac = factory.make_MACAddress_with_Node()221 mac = factory.make_MACAddress_with_Node()
208222
=== modified file 'src/maasserver/models/tests/test_subnet.py'
--- src/maasserver/models/tests/test_subnet.py 2015-06-19 09:53:30 +0000
+++ src/maasserver/models/tests/test_subnet.py 2015-07-22 10:47:10 +0000
@@ -52,3 +52,13 @@
52 self.assertEqual(52 self.assertEqual(
53 {'gateway_ip': ["Gateway IP must be within CIDR range."]},53 {'gateway_ip': ["Gateway IP must be within CIDR range."]},
54 error.message_dict)54 error.message_dict)
55
56 def test_create_from_cidr_creates_subnet(self):
57 vlan = factory.make_VLAN()
58 cidr = unicode(factory.make_ip4_or_6_network().cidr)
59 space = factory.make_Space()
60 name = "subnet-" + cidr
61 subnet = Subnet.objects.create_from_cidr(cidr, vlan, space)
62 self.assertThat(subnet, MatchesStructure.byEquality(
63 name=name, vlan=vlan, cidr=cidr, space=space,
64 gateway_ip=None, dns_servers=[]))
5565
=== modified file 'src/metadataserver/models/tests/test_commissioningscript.py'
--- src/metadataserver/models/tests/test_commissioningscript.py 2015-07-16 15:44:24 +0000
+++ src/metadataserver/models/tests/test_commissioningscript.py 2015-07-22 10:47:10 +0000
@@ -1413,9 +1413,10 @@
14131413
1414 update_node_network_information(node, self.IP_ADDR_OUTPUT, 0)1414 update_node_network_information(node, self.IP_ADDR_OUTPUT, 0)
1415 eth0 = Interface.objects.get(mac__node=node, name='eth0')1415 eth0 = Interface.objects.get(mac__node=node, name='eth0')
1416 self.assertEqual(1, eth0.ip_addresses.count())1416 address = unicode(IPNetwork(cidr).ip)
1417 ipv4_ip = eth0.ip_addresses.get(ip=address)
1417 self.assertThat(1418 self.assertThat(
1418 eth0.ip_addresses.first(),1419 ipv4_ip,
1419 MatchesStructure.byEquality(1420 MatchesStructure.byEquality(
1420 alloc_type=IPADDRESS_TYPE.DHCP, subnet=subnet,1421 alloc_type=IPADDRESS_TYPE.DHCP, subnet=subnet,
1421 ip=unicode(IPNetwork(cidr).ip)))1422 ip=address))

Subscribers

People subscribed via source and target branches