Skip to content

Commit

Permalink
Merge pull request #132 from cybozu-go/bmc-info
Browse files Browse the repository at this point in the history
Add BMC NIC configuration information to Machine
  • Loading branch information
zoetrope authored Jan 28, 2019
2 parents 5b9df5c + e573e1a commit 6986d8e
Show file tree
Hide file tree
Showing 67 changed files with 4,811 additions and 177 deletions.
23 changes: 12 additions & 11 deletions dhcpd/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,18 @@ func (i mockInterface) Name() string {
func testNewHandler(maskbits, gwoffset, leasemin uint) DHCPHandler {
m := mock.NewModel()
m.IPAM.PutConfig(context.Background(), &sabakan.IPAMConfig{
MaxNodesInRack: 28,
NodeIPv4Pool: "10.69.0.0/20",
NodeIPv4Offset: "",
NodeRangeSize: 6,
NodeRangeMask: maskbits,
NodeIndexOffset: 3,
NodeIPPerNode: 3,
BMCIPv4Pool: "10.72.16.0/20",
BMCIPv4Offset: "0.0.1.0",
BMCRangeSize: 5,
BMCRangeMask: 20,
MaxNodesInRack: 28,
NodeIPv4Pool: "10.69.0.0/20",
NodeIPv4Offset: "",
NodeRangeSize: 6,
NodeRangeMask: maskbits,
NodeIndexOffset: 3,
NodeIPPerNode: 3,
BMCIPv4Pool: "10.72.16.0/20",
BMCIPv4Offset: "0.0.1.0",
BMCRangeSize: 5,
BMCRangeMask: 20,
BMCGatewayOffset: 1,
})
m.DHCP.PutConfig(context.Background(), &sabakan.DHCPConfig{
GatewayOffset: gwoffset,
Expand Down
7 changes: 4 additions & 3 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ $ curl -s -XPUT 'localhost:10080/api/v1/config/ipam' -d '
"bmc-ipv4-pool": "10.72.16.0/20",
"bmc-ipv4-offset": "0.0.1.0",
"bmc-ipv4-range-size": 5,
"bmc-ipv4-range-mask": 20
"bmc-ipv4-range-mask": 20,
"bmc-ipv4-gateway-offset": 1
}'
```

Expand Down Expand Up @@ -122,7 +123,8 @@ $ curl -s -XGET 'localhost:10080/api/v1/config/ipam'
"bmc-ipv4-pool": "10.72.16.0/20",
"bmc-ipv4-offset": "0.0.1.0",
"bmc-ipv4-range-size": 5,
"bmc-ipv4-range-mask": 20
"bmc-ipv4-range-mask": 20,
"bmc-ipv4-gateway-offset": 1
}
```

Expand Down Expand Up @@ -1027,4 +1029,3 @@ get sabakan health status
$ curl -s -XGET localhost:10080/health
{"health":"healthy"}
```

3 changes: 2 additions & 1 deletion docs/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ Prepare `ipam.json` as follows:
"bmc-ipv4-pool": "10.72.16.0/20",
"bmc-ipv4-offset": "0.0.1.0",
"bmc-ipv4-range-size": 5,
"bmc-ipv4-range-mask": 20
"bmc-ipv4-range-mask": 20,
"bmc-ipv4-gateway-offset": 1
}
```

Expand Down
18 changes: 8 additions & 10 deletions docs/ignition.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ Sabakan also keeps metadata of each ignition other than `id` for external progra
How it works
------------

### Serving ignitions from CoreOS
### Serving ignition configuration via HTTP

1. iPXE received DHCP IP address with iPXE script which kernel parameter includes the newest ignition URL.
2. HTTP BOOT retrieves kernel and initrd.
3. The initrd download ignition file from sabakan.
4. CoreOS apply downloaded ignition to its system.
3. The initrd downloads ignition config from sabakan.
4. Ignition running in CoreOS Container Linux applies downloaded config to its system.

### Ignition configuration

Expand All @@ -52,17 +52,17 @@ but not URL encoded:
"path": "/etc/hostname",
"mode": 420,
"contents": {
"source": "{{ .Serial }}"
"source": "{{ .Spec.Serial }}"
}
}
]
}
}
```

The template variables are defined in [type MachineSpec][].
The context of the template is the instance of the struct.
For example, the template can refers serial number of the machine by `.Serial`.
The template context `.` is the booting [`Machine`](machine.md#machine-struct).

For example, the template can refers serial number of the machine by `.Spec.Serial`.
And the `MyURL` and `Metadata` function can be used in the template.
`MyURL` function will return the URL of this sabakan server itself.
`Metadata` function will return the metadata of the key passed as an argument.
Expand Down Expand Up @@ -120,7 +120,7 @@ The path must be *absolute path* and user need to put the source file in the `fi

```conf
# files/etc/hostname
{{ .Serial }}
{{ .Spec.Serial }}
```

```conf
Expand Down Expand Up @@ -171,5 +171,3 @@ From the above files, user can register an ignition by `sabactl` command:
# sabactl ignitions set -f <FILE> <ROLE> <ID>
$ sabactl ignitions set -f worker.yml worker 1.1.0-3
```

[type MachineSpec]: https://godoc.org/github.com/cybozu-go/sabakan#MachineSpec
54 changes: 28 additions & 26 deletions docs/ipam.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,20 @@ IPAMConfig
`IPAMConfig` is a set of configurations to assign IP addresses automatically.
It is given as JSON object with the following fields:

Field | Type | Description
---------------------- | ------ | -----------
`max-nodes-in-rack` | int | The maximum number of nodes in a rack, excluding "boot" node.
`node-ipv4-pool` | string | CIDR IPv4 network for node IP pool.
`node-ipv4-offset` | string | Node IPs will be started by adding this to `node-ipv4-pool`. Default is "", equivalent to `0.0.0.0`.
`node-ipv4-range-size` | int | Size of the address range to divide the pool (bit counts).
`node-ipv4-range-mask` | int | The subnet mask for a divided range.
`node-ip-per-node` | int | The number of IP addresses for each node.
`node-index-offset` | int | Offset for assigning IP address to a node in a divided range.
`bmc-ipv4-pool` | string | CIDR IPv4 network for BMC IP pool.
`bmc-ipv4-offset` | string | BMC IPs will be started by adding this to `bmc-ipv4-pool`. Default is "", equivalent to `0.0.0.0`.
`bmc-ipv4-range-size` | int | Size of the address range to divide the pool (bit counts).
`bmc-ipv4-range-mask` | int | The subnet mask for a divided range.
Field | Type | Description
------------------------- | ------ | -----------
`max-nodes-in-rack` | int | The maximum number of nodes in a rack, excluding "boot" node.
`node-ipv4-pool` | string | CIDR IPv4 network for node IP pool.
`node-ipv4-offset` | string | Node IPs will be started by adding this to `node-ipv4-pool`. Default is "", equivalent to `0.0.0.0`.
`node-ipv4-range-size` | int | Size of the address range to divide the pool (bit counts).
`node-ipv4-range-mask` | int | The subnet mask for a divided range.
`node-ip-per-node` | int | The number of IP addresses for each node.
`node-index-offset` | int | Offset for assigning IP address to a node in a divided range.
`bmc-ipv4-pool` | string | CIDR IPv4 network for BMC IP pool.
`bmc-ipv4-offset` | string | BMC IPs will be started by adding this to `bmc-ipv4-pool`. Default is "", equivalent to `0.0.0.0`.
`bmc-ipv4-range-size` | int | Size of the address range to divide the pool (bit counts).
`bmc-ipv4-range-mask` | int | The subnet mask for a divided range.
`bmc-ipv4-gateway-offset` | int | The default gateway address offset.

Setting the index of a node
---------------------------
Expand Down Expand Up @@ -90,19 +91,20 @@ Examples

Suppose that IPAM configurations are as follows:

Field | Value
---------------------- | -----:
`max-nodes-in-rack` | 28
`node-ipv4-pool` | 10.69.0.0/16
`node-ipv4-offset` | 0.0.0.0
`node-ipv4-range-size` | 6
`node-ipv4-range-mask` | 26
`node-ip-per-node` | 3
`node-index-offset` | 3
`bmc-ipv4-pool` | 10.72.16.0/20
`bmc-ipv4-offset` | 0.0.1.0
`bmc-ipv4-range-size` | 5
`bmc-ipv4-range-mask` | 20
Field | Value
------------------------- | -----:
`max-nodes-in-rack` | 28
`node-ipv4-pool` | 10.69.0.0/16
`node-ipv4-offset` | 0.0.0.0
`node-ipv4-range-size` | 6
`node-ipv4-range-mask` | 26
`node-ip-per-node` | 3
`node-index-offset` | 3
`bmc-ipv4-pool` | 10.72.16.0/20
`bmc-ipv4-offset` | 0.0.1.0
`bmc-ipv4-range-size` | 5
`bmc-ipv4-range-mask` | 20
`bmc-ipv4-gateway-offset` | 1

For a node whose rack number is `0` and index in rack is `4`,
its static addresses for node OS are:
Expand Down
15 changes: 14 additions & 1 deletion docs/machine.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ Values for auto fields are filled by sabakan at registration.
Machine struct
--------------

`Machine` has `MachineSpec` and its status as described in [lifecycle management](lifecycle.md).
`Machine` has `MachineSpec` and its `status` as described in [lifecycle management](lifecycle.md)
as well as additional `info`.

A JSON representation of `Machine` looks like:

Expand Down Expand Up @@ -63,9 +64,21 @@ A JSON representation of `Machine` looks like:
"state": "healthy",
"timestamp": "2018-06-19T03:43:25.46669721Z",
"duration": 362.1
},

"info": {
"bmc": {
"ipv4": {
"address": "10.72.17.37",
"netmask": "255.255.255.0",
"gateway": "10.71.17.1"
}
}
}
}
```

`status.duration` is the duration between the current time and `status.timestamp`.
The unit of `status.duration` is seconds.

`info.bmc` contains BMC NIC configuration information.
69 changes: 36 additions & 33 deletions e2e/sabactl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,17 +111,18 @@ func testSabactlDHCP(t *testing.T) {

func testSabactlIPAM(t *testing.T) {
var conf = sabakan.IPAMConfig{
MaxNodesInRack: 28,
NodeIPv4Pool: "10.69.0.0/20",
NodeIPv4Offset: "",
NodeRangeSize: 6,
NodeRangeMask: 26,
NodeIndexOffset: 3,
NodeIPPerNode: 3,
BMCIPv4Pool: "10.72.16.0/20",
BMCIPv4Offset: "0.0.1.0",
BMCRangeSize: 5,
BMCRangeMask: 20,
MaxNodesInRack: 28,
NodeIPv4Pool: "10.69.0.0/20",
NodeIPv4Offset: "",
NodeRangeSize: 6,
NodeRangeMask: 26,
NodeIndexOffset: 3,
NodeIPPerNode: 3,
BMCIPv4Pool: "10.72.16.0/20",
BMCIPv4Offset: "0.0.1.0",
BMCRangeSize: 5,
BMCRangeMask: 20,
BMCGatewayOffset: 1,
}
stdout, stderr, err := runSabactlWithFile(t, &conf, "ipam", "set")
code := exitCode(err)
Expand Down Expand Up @@ -151,17 +152,18 @@ func testSabactlIPAM(t *testing.T) {
}

var badConf = sabakan.IPAMConfig{
MaxNodesInRack: 0,
NodeIPv4Pool: "10.69.0.0/20",
NodeIPv4Offset: "",
NodeRangeSize: 6,
NodeRangeMask: 26,
NodeIndexOffset: 3,
NodeIPPerNode: 3,
BMCIPv4Pool: "10.72.16.0/20",
BMCIPv4Offset: "0.0.1.0",
BMCRangeSize: 5,
BMCRangeMask: 20,
MaxNodesInRack: 0,
NodeIPv4Pool: "10.69.0.0/20",
NodeIPv4Offset: "",
NodeRangeSize: 6,
NodeRangeMask: 26,
NodeIndexOffset: 3,
NodeIPPerNode: 3,
BMCIPv4Pool: "10.72.16.0/20",
BMCIPv4Offset: "0.0.1.0",
BMCRangeSize: 5,
BMCRangeMask: 20,
BMCGatewayOffset: 1,
}
stdout, stderr, err = runSabactlWithFile(t, &badConf, "ipam", "set")
code = exitCode(err)
Expand All @@ -174,17 +176,18 @@ func testSabactlIPAM(t *testing.T) {

func testSabactlMachines(t *testing.T) {
var conf = sabakan.IPAMConfig{
MaxNodesInRack: 28,
NodeIPv4Pool: "10.69.0.0/20",
NodeIPv4Offset: "",
NodeRangeSize: 6,
NodeRangeMask: 26,
NodeIndexOffset: 3,
NodeIPPerNode: 3,
BMCIPv4Pool: "10.72.16.0/20",
BMCIPv4Offset: "0.0.1.0",
BMCRangeSize: 5,
BMCRangeMask: 20,
MaxNodesInRack: 28,
NodeIPv4Pool: "10.69.0.0/20",
NodeIPv4Offset: "",
NodeRangeSize: 6,
NodeRangeMask: 26,
NodeIndexOffset: 3,
NodeIPPerNode: 3,
BMCIPv4Pool: "10.72.16.0/20",
BMCIPv4Offset: "0.0.1.0",
BMCRangeSize: 5,
BMCRangeMask: 20,
BMCGatewayOffset: 1,
}
stdout, stderr, err := runSabactlWithFile(t, &conf, "ipam", "set")
code := exitCode(err)
Expand Down
Loading

0 comments on commit 6986d8e

Please sign in to comment.