Skip to content

Commit

Permalink
changed for virtual machine to have only a gateway
Browse files Browse the repository at this point in the history
  • Loading branch information
h-otter committed Apr 3, 2019
1 parent 546cae3 commit 780ec9b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
2 changes: 2 additions & 0 deletions n0core/pkg/api/provisioning/virtualmachine/annotations.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ const AnnotationComputeReservedBy = "n0core/provisioning/virtual_machine/virtual
const AnnotationNetworkInterfaceIsGateway = "n0core/provisioning/virtual_machine/is_gateway"

const AnnotationVirtualMachineRequestNodeName = "n0core/provisioning/virtual_machine/request_node_name"

const AnnotationVirtualMachineNICIsGateway = "n0core/provisioning/virtual_machine/is_gateway"
18 changes: 15 additions & 3 deletions n0core/pkg/api/provisioning/virtualmachine/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,15 @@ func (a *VirtualMachineAPI) bootVirtualMachine(ctx context.Context, req *pprovis

netdevs := make([]*NetDev, len(vm.Nics))
{
gatewayIndex := 0
for i, nic := range vm.Nics {
if nic.Annotations != nil {
if _, ok := nic.Annotations[AnnotationVirtualMachineNICIsGateway]; ok {
gatewayIndex = i
}
}
}

for i, nic := range vm.Nics {
network, err := a.networkAPI.GetNetwork(ctx, &ppool.GetNetworkRequest{Name: nic.NetworkName})
if err != nil {
Expand All @@ -604,9 +613,12 @@ func (a *VirtualMachineAPI) bootVirtualMachine(ctx context.Context, req *pprovis
}

netdevs[i].Ipv4AddressCidr = fmt.Sprintf("%s/%d", vm.Nics[i].Ipv4Address, ip.SubnetMaskBits())
netdevs[i].Ipv4Gateway = gateway
netdevs[i].Nameservers = []string{"8.8.8.8"} // TODO: 取るようにする
// TODO: domain searchはnetworkのdomainから取る

if gatewayIndex == i {
netdevs[i].Ipv4Gateway = gateway
netdevs[i].Nameservers = []string{"8.8.8.8"} // TODO: 取るようにする
// TODO: domain searchはnetworkのdomainから取る
}
}
}
}
Expand Down

0 comments on commit 780ec9b

Please sign in to comment.