Skip to content

Commit

Permalink
Get dhcp domain
Browse files Browse the repository at this point in the history
  • Loading branch information
enxebre authored and michaelgugino committed Apr 23, 2020
1 parent c44c93c commit dda7270
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
21 changes: 21 additions & 0 deletions pkg/actuators/machine/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,27 @@ func (r *Reconciler) update() error {

r.machineScope.setProviderStatus(newestInstance, conditionSuccess())

vpc, err := r.awsClient.DescribeVpcs(&ec2.DescribeVpcsInput{
VpcIds: []*string{newestInstance.VpcId},
})
if err != nil {
return err
}

dhcp, err := r.awsClient.DescribeDHCPOptions(&ec2.DescribeDhcpOptionsInput{
DhcpOptionsIds: []*string{vpc.Vpcs[0].DhcpOptionsId},
})
if err != nil {
return err
}

klog.Infof("DHCP %+v", dhcp.DhcpOptions[0].DhcpConfigurations[0])
for _, i := range dhcp.DhcpOptions[0].DhcpConfigurations {
if *i.Key == "domain-name" {
klog.Infof("Domain value %v", i.Values)
}
}

return r.requeueIfInstancePending(newestInstance)
}

Expand Down
5 changes: 5 additions & 0 deletions pkg/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ type AwsClientBuilderFuncType func(client client.Client, secretName, namespace,
// Client is a wrapper object for actual AWS SDK clients to allow for easier testing.
type Client interface {
DescribeImages(*ec2.DescribeImagesInput) (*ec2.DescribeImagesOutput, error)
DescribeDHCPOptions(input *ec2.DescribeDhcpOptionsInput) (*ec2.DescribeDhcpOptionsOutput, error)
DescribeVpcs(*ec2.DescribeVpcsInput) (*ec2.DescribeVpcsOutput, error)
DescribeSubnets(*ec2.DescribeSubnetsInput) (*ec2.DescribeSubnetsOutput, error)
DescribeAvailabilityZones(*ec2.DescribeAvailabilityZonesInput) (*ec2.DescribeAvailabilityZonesOutput, error)
Expand All @@ -73,6 +74,10 @@ type awsClient struct {
elbv2Client elbv2iface.ELBV2API
}

func (c *awsClient) DescribeDHCPOptions(input *ec2.DescribeDhcpOptionsInput) (*ec2.DescribeDhcpOptionsOutput, error) {
return c.ec2Client.DescribeDhcpOptions(input)
}

func (c *awsClient) DescribeImages(input *ec2.DescribeImagesInput) (*ec2.DescribeImagesOutput, error) {
return c.ec2Client.DescribeImages(input)
}
Expand Down

0 comments on commit dda7270

Please sign in to comment.