Skip to content

Commit

Permalink
Populate network mapping from ovf envelope (#546)
Browse files Browse the repository at this point in the history
On OVF import bind network adapters to the networks specified in the
OVF envelope if they exist on the target.
  • Loading branch information
egorovv authored and dougm committed Jul 15, 2016
1 parent fa6668d commit e3c3cd0
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions govc/importx/ovf.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,22 @@ func (cmd *ovfx) Import(fpath string) (*types.ManagedObjectReference, error) {
PropertyMapping: cmd.Map(cmd.Options.PropertyMapping),
}

if e.Network != nil {
finder, err := cmd.DatastoreFlag.Finder()
if err != nil {
return nil, err
}
for _, n := range e.Network.Networks {
if net, err := finder.Network(context.TODO(), n.Name); err == nil {
cisp.NetworkMapping = append(cisp.NetworkMapping,
types.OvfNetworkMapping{
Name: n.Name,
Network: net.Reference(),
})
}
}
}

m := object.NewOvfManager(cmd.Client)
spec, err := m.CreateImportSpec(context.TODO(), string(o), cmd.ResourcePool, cmd.Datastore, cisp)
if err != nil {
Expand Down

0 comments on commit e3c3cd0

Please sign in to comment.