Skip to content

Commit

Permalink
Merge pull request #597 from mcgG/fix-ipv6
Browse files Browse the repository at this point in the history
[RAC-6563] fix ipv6 prefix format
  • Loading branch information
lanchongyizu authored Jul 5, 2018
2 parents 0a91374 + ee6ddc4 commit c3cc88f
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 35 deletions.
10 changes: 1 addition & 9 deletions lib/jobs/install-os.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,7 @@ function installOsJobFactory(
if (dev.ipv6) {
assert.isIP(dev.ipv6.ipAddr, 6);
assert.isIP(dev.ipv6.gateway, 6);
assert.string(dev.ipv6.netmask);
_.forEach(dev.ipv6.netmask.split('.'), function(item) {
item = +item ? +item : parseInt(item, 16);
/* jshint ignore:start */
if(item !== 0 && (item - 1 | item) !== 65535) {
throw new Error('Invalid ipv6 netmask.');
}
/* jshint ignore:end */
});
assert.number(dev.ipv6.prefixlen);
}
});
}
Expand Down
12 changes: 7 additions & 5 deletions lib/task-data/schemas/types-installos.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,6 @@
"type": "string",
"format": "ipv6"
},
"netmask": {
"description": "The ipv6 netmask",
"type": "string"
},
"gateway": {
"description": "The ipv6 gateway",
"type": "string",
Expand All @@ -145,9 +141,15 @@
"$ref": "#/definitions/VlanId"
},
"uniqueItems": true
},
"prefixlen": {
"description": "The ipv6 prefixlen/netmask",
"type": "integer",
"minimum": 0,
"maximum": 128
}
},
"required": ["ipAddr", "netmask", "gateway"],
"required": ["ipAddr", "prefixlen", "gateway"],
"additionalProperties": false
},
"NetworkConfig": {
Expand Down
17 changes: 1 addition & 16 deletions spec/lib/jobs/install-os-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -607,29 +607,14 @@ describe('Install OS Job', function () {
ipv6:{
ipAddr: "10ec0::6ab4:0:5efe:157.60.14.21",
gateway: "fe80::5efe:131.107.25.1",
netmask: "ffff.ffff.ffff.ffff.0.0.1.0"
prefixlen: 64
}
}
];
expect(function() { job._validateOptions(); })
.to.throw(Error.AssertionError, 'Violated isIP constraint');
});

it('should throw netmask AssertionError', function () {
job.options.networkDevices = [
{
device: "eth0",
ipv6:{
ipAddr: "fec0::6ab4:0:5efe:157.60.14.21",
gateway: "fe80::5efe:131.107.25.1",
netmask: "ffff.ffff.ffff.ffff.0.0.1.0"
}
}
];
expect(function() { job._validateOptions(); })
.to.throw(Error, 'Invalid ipv6 netmask.');
});

it('should allow configuration without gateway', function () {
job.options.networkDevices = [
{
Expand Down
4 changes: 2 additions & 2 deletions spec/lib/task-data/schemas/install-esxi-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe(require('path').basename(__filename), function() {
"ipv6": {
"ipAddr": "fec0::6ab4:0:5efe:157.60.14.21",
"gateway": "fe80::5efe:131.107.25.1",
"netmask": "ffff.ffff.ffff.ffff.0.0.0.0",
"prefixlen": 64,
"vlanIds": [
101,
106
Expand All @@ -72,7 +72,7 @@ describe(require('path').basename(__filename), function() {
"ipv6": {
"ipAddr": "fec0::6ab4:0:5efe:157.60.14.21",
"gateway": "fe80::5efe:131.107.25.1",
"netmask": "ffff.ffff.ffff.ffff.0.0.0.0"
"prefixlen": 64
}
},
],
Expand Down
6 changes: 3 additions & 3 deletions spec/lib/task-data/schemas/install-os-schema-ut-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ var canonical = {
"ipv6": {
"ipAddr": "fec0::6ab4:0:5efe:157.60.14.21",
"gateway": "fe80::5efe:131.107.25.1",
"netmask": "ffff.ffff.ffff.ffff.0.0.0.0",
"prefixlen": 64,
"vlanIds": [
101,
106
Expand All @@ -54,7 +54,7 @@ var canonical = {
"ipv6": {
"ipAddr": "fec0::6ab4:0:5efe:157.60.14.21",
"gateway": "fe80::5efe:131.107.25.1",
"netmask": "ffff.ffff.ffff.ffff.0.0.0.0"
"prefixlen": 64
}
},
],
Expand Down Expand Up @@ -116,7 +116,7 @@ var negativeUnsetParam = [
"rootPassword",
"networkDevices[0].device",
"networkDevices[1].ipv4.ipAddr",
"networkDevices[2].ipv6.netmask",
"networkDevices[2].ipv6.prefixlen",
"progressMilestones.m1.value"
];

Expand Down

0 comments on commit c3cc88f

Please sign in to comment.