diff --git a/README.md b/README.md index f6e89ff..729b4f5 100755 --- a/README.md +++ b/README.md @@ -42,9 +42,9 @@ If you want to use Nutanix Node Driver, you need add it in order to start using 2. Click *Add Node Driver*. 3. Complete the Add Node Driver form. Then click Create. - - *Download URL*: `https://github.com/nutanix/docker-machine/releases/download/v3.5.0/docker-machine-driver-nutanix` - - *Custom UI URL*: `https://nutanix.github.io/rancher-ui-driver/v3.5.0/component.js` - - *Checksum*: `9555aadd060204ec510bb99e1dc9fed94af9780b2a409680888ee928982542cf` + - *Download URL*: `https://github.com/nutanix/docker-machine/releases/download/v3.6.0/docker-machine-driver-nutanix` + - *Custom UI URL*: `https://nutanix.github.io/rancher-ui-driver/v3.6.0/component.js` + - *Checksum*: `` - *Whitelist Domains*: `nutanix.github.io` diff --git a/machine/driver/driver.go b/machine/driver/driver.go index 5cfc872..04fddb3 100755 --- a/machine/driver/driver.go +++ b/machine/driver/driver.go @@ -192,25 +192,43 @@ func (d *NutanixDriver) Create() error { subnetFilter := "" + // Create subnets filter query and add UUID subnets directly for _, subnet := range d.Subnet { - if len(subnetFilter) != 0 { - subnetFilter += "," + + if isUUID(subnet) { + n := &v3.VMNic{ + SubnetReference: utils.BuildReference(*utils.StringPtr(subnet), "subnet"), + } + + res.NicList = append(res.NicList, n) + log.Infof("UUID subnet added %s", subnet) + } else { + if len(subnetFilter) != 0 { + subnetFilter += "," + } + + t := &url.URL{Path: subnet} + encodedSubnet := t.String() + subnetFilter += fmt.Sprintf("name==%s", encodedSubnet) } - t := &url.URL{Path: subnet} - encodedSubnet := t.String() - subnetFilter += fmt.Sprintf("name==%s", encodedSubnet) } + // Retrieve all subnets responseSubnets, err := conn.V3.ListAllSubnet(subnetFilter, getEmptyClientSideFilter()) if err != nil { log.Errorf("Error getting subnets: [%v]", err) return err } - // Validate filtered Subnets + // Search for non UUID Subnets for _, query := range d.Subnet { + if isUUID(query) { + continue + } + log.Infof("Searching subnet %s", query) + for _, subnet := range responseSubnets.Entities { if *subnet.Spec.Name == query { diff --git a/machine/driver/yaml.go b/machine/driver/utils.go similarity index 88% rename from machine/driver/yaml.go rename to machine/driver/utils.go index 33bbd67..01cc2b7 100644 --- a/machine/driver/yaml.go +++ b/machine/driver/utils.go @@ -1,6 +1,15 @@ package driver -import "gopkg.in/yaml.v3" +import ( + "regexp" + + "gopkg.in/yaml.v3" +) + +func isUUID(uuid string) bool { + uuidPattern := regexp.MustCompile(`^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$`) + return uuidPattern.MatchString(uuid) +} func iterateNode(node *yaml.Node, identifier string) *yaml.Node { returnNode := false