id
stringlengths
2
7
text
stringlengths
17
51.2k
title
stringclasses
1 value
c170100
error { d.Set("port_private_secondary_vlan_id", obj.PvlanId) return nil }
c170101
vte: obj = expandVmwareDistributedVirtualSwitchTrunkVlanSpec(d) case pvid: obj = expandVmwareDistributedVirtualSwitchPvlanSpec(d) case ide: obj = expandVmwareDistributedVirtualSwitchVlanIDSpec(d) } return obj }
c170102
err = flattenVmwareDistributedVirtualSwitchTrunkVlanSpec(d, t) case *types.VmwareDistributedVirtualSwitchPvlanSpec: err = flattenVmwareDistributedVirtualSwitchPvlanSpec(d, t) } return err }
c170103
"check_beacon"), } if structure.AllFieldsEmpty(obj) { return nil } return obj }
c170104
{ if obj == nil { return nil } structure.SetBoolPolicy(d, "check_beacon", obj.CheckBeacon) return nil }
c170105
structure.SliceInterfacesToStrings(d.Get("standby_uplinks").([]interface{})), } if structure.AllFieldsEmpty(obj) { return nil } return obj }
c170106
} if err := d.Set("standby_uplinks", obj.StandbyUplinkPort); err != nil { return err } return nil }
c170107
NotifySwitches: structure.GetBoolPolicy(d, "notify_switches"), RollingOrder: structure.GetBoolPolicyReverse(d, "failback"), FailureCriteria: expandDVSFailureCriteria(d), UplinkPortOrder: expandVMwareUplinkPortOrderPolicy(d), } if structure.AllFieldsEmpty(obj) { return nil } return obj }
c170108
err := flattenDVSFailureCriteria(d, obj.FailureCriteria); err != nil { return err } if err := flattenVMwareUplinkPortOrderPolicy(d, obj.UplinkPortOrder); err != nil { return err } return nil }
c170109
MacChanges: structure.GetBoolPolicy(d, "allow_mac_changes"), ForgedTransmits: structure.GetBoolPolicy(d, "allow_forged_transmits"), } if structure.AllFieldsEmpty(obj) { return nil } return obj }
c170110
"allow_mac_changes", obj.MacChanges) structure.SetBoolPolicy(d, "allow_forged_transmits", obj.ForgedTransmits) return nil }
c170111
structure.GetStringPolicy(d, "lacp_mode"), } if structure.AllFieldsEmpty(obj) { return nil } return obj }
c170112
} structure.SetBoolPolicy(d, "lacp_enabled", obj.Enable) structure.SetStringPolicy(d, "lacp_mode", obj.Mode) return nil }
c170113
structure.GetLongPolicy(d, "ingress_shaping_peak_bandwidth"), BurstSize: structure.GetLongPolicy(d, "ingress_shaping_burst_size"), } if structure.AllFieldsEmpty(obj) { return nil } return obj }
c170114
obj.Enabled) structure.SetLongPolicy(d, "ingress_shaping_average_bandwidth", obj.AverageBandwidth) structure.SetLongPolicy(d, "ingress_shaping_peak_bandwidth", obj.PeakBandwidth) structure.SetLongPolicy(d, "ingress_shaping_burst_size", obj.BurstSize) return nil }
c170115
expandDVSSecurityPolicy(d), IpfixEnabled: structure.GetBoolPolicy(d, "netflow_enabled"), TxUplink: structure.GetBoolPolicy(d, "tx_uplink"), LacpPolicy: expandVMwareUplinkLacpPolicy(d), } if structure.AllFieldsEmpty(obj) { return nil } return obj }
c170116
!= nil { return err } if err := flattenVmwareUplinkPortTeamingPolicy(d, obj.UplinkTeamingPolicy); err != nil { return err } if err := flattenDVSSecurityPolicy(d, obj.SecurityPolicy); err != nil { return err } if err := flattenVMwareUplinkLacpPolicy(d, obj.LacpPolicy); err != nil { return err } return nil }
c170117
Behavior: types.DrsBehavior(d.Get("drs_automation_level").(string)), Enabled: structure.GetBool(d, "drs_enabled"), Key: vm.Reference(), } return obj, nil }
c170118
{ return structure.SetBatch(d, map[string]interface{}{ "drs_automation_level": obj.Behavior, "drs_enabled": obj.Enabled, }) }
c170119
return "", "", fmt.Errorf("bad ID %q", id) } return parts[0], parts[1], nil }
c170120
info.Key == vm.Reference() { log.Printf("[DEBUG] Found DRS config info for VM %q in cluster %q", vm.Name(), cluster.Name()) return &info, nil } } log.Printf("[DEBUG] No DRS config info found for VM %q in cluster %q", vm.Name(), cluster.Name()) return nil, nil }
c170121
return strings.Join([]string{clusterID, strconv.Itoa(int(key))}, ":"), nil }
c170122
schema.TypeString, Description: "The current maintenance mode state of the datastore.", Computed: true, }, "multiple_host_access": { Type: schema.TypeBool, Description: "If true, more than one host in the datacenter has been configured with access to the datastore.", Computed: true, }, "uncommitted_space": { Type: schema.TypeInt, Description: "Total additional storage space, in MB, potentially used by all virtual machines on this datastore.", Computed: true, }, "url": { Type: schema.TypeString, Description: "The unique locator for the datastore.", Computed: true, }, } }
c170123
obj.Url) // Set the name attribute off of the name here - since we do not track this // here we check for errors if err := d.Set("name", obj.Name); err != nil { return err } return nil }
c170124
case cok: return resourceVSphereDatastoreStorageClusterPathNormalized(meta, cvalue.(string)) } return path, nil }
c170125
"StoragePod": return resourceVSphereDatastoreReadFolderOrStorageClusterPathSetAttributes(d, "", props.Parent.Value) } return fmt.Errorf("unknown datastore parent type %q while parsing inventory path", props.Parent.Type) }
c170126
}, // VirtualCdromRemoteAtapiBackingInfo "client_device": { Type: schema.TypeBool, Optional: true, Description: "Indicates whether the device should be mapped to a remote client device", }, } structure.MergeSchema(s, subresourceSchema()) return s }
c170127
srtype: subresourceTypeCdrom, data: d, olddata: old, rdd: rdd, }, } sr.Index = idx return sr }
c170128
if err := r.ValidateDiff(); err != nil { return fmt.Errorf("%s: %s", r.Addr(), err) } } log.Printf("[DEBUG] CdromDiffOperation: Diff validation complete") return nil }
c170129
client_device parameter and ISO file parameters (datastore_id, path) set") case !clientDevice && (dsID == "" || path == ""): return fmt.Errorf("Either client_device or datastore_id and path must be set") } log.Printf("[DEBUG] %s: Config validation complete", r) return nil }
c170130
if err != nil { return nil, err } // Map the CDROM to the correct device r.mapCdrom(device, l) // Done here. Save IDs, push the device to the new device list and return. if err := r.SaveDevIDs(device, ctlr); err != nil { return nil, err } dspec, err := object.VirtualDeviceList{device}.ConfigSpec(types.VirtualDeviceConfigSpecOperationAdd) if err != nil { return nil, err } spec = append(spec, dspec...) log.Printf("[DEBUG] %s: Device config operations from create: %s", r, DeviceChangeString(spec)) log.Printf("[DEBUG] %s: Create finished", r) return spec, nil }
c170131
the device address and key, of course). In // addition to making sure correct diffs get created for these kinds of // devices, this ensures we don't fail on CDROM device types we don't // support right now, such as passthrough devices. We might support these // later. log.Printf("%s: [DEBUG] Unknown CDROM type %T, clearing all attributes", r, backing) r.Set("datastore_id", "") r.Set("path", "") r.Set("client_device", false) } // Save the device key and address data ctlr, err := findControllerForDevice(l, d) if err != nil { return err } if err := r.SaveDevIDs(d, ctlr); err != nil { return err } log.Printf("[DEBUG] %s: Read finished (key and device address may have changed)", r) return nil }
c170132
:= object.VirtualDeviceList{device}.ConfigSpec(types.VirtualDeviceConfigSpecOperationEdit) if err != nil { return nil, err } log.Printf("[DEBUG] %s: Device config operations from update: %s", r, DeviceChangeString(spec)) log.Printf("[DEBUG] %s: Update complete", r) return spec, nil }
c170133
} deleteSpec, err := object.VirtualDeviceList{device}.ConfigSpec(types.VirtualDeviceConfigSpecOperationRemove) if err != nil { return nil, err } log.Printf("[DEBUG] %s: Device config operations from update: %s", r, DeviceChangeString(deleteSpec)) log.Printf("[DEBUG] %s: Delete completed", r) return deleteSpec, nil }
c170134
nil case clientDevice == true: // If set to use the client device, then the CDROM will be mapped to a remote device. device.Backing = &types.VirtualCdromRemoteAtapiBackingInfo{ VirtualDeviceRemoteDeviceBackingInfo: types.VirtualDeviceRemoteDeviceBackingInfo{}, } return nil } panic(fmt.Sprintf("%s: no CDROM types specified", r)) }
c170135
see if ISO transport is supported. tm := d.Get("vapp_transport").([]interface{}) for _, m := range tm { if m.(string) == vAppTransportIso && len(tm) == 1 { return fmt.Errorf("this virtual machine requires a client CDROM device to deliver vApp properties") } } log.Printf("[DEBUG] VAppDiffOperation: ISO transport is not supported on this virtual machine or multiple transport options exist") return nil }
c170136
false, nil } } else { // vApp CDROMs must be backed by an ISO. log.Printf("[DEBUG] IsVAppCdrom: CDROM is not backed by an ISO") return false, nil } log.Printf("[DEBUG] IsVAppCdrom: CDROM has a vApp ISO inserted") // Set the vApp transport methods tm := d.Get("vapp_transport").([]interface{}) for _, t := range tm { if t.(string) == "iso" { log.Printf("[DEBUG] IsVAppCdrom: vApp ISO transport is supported") return true, nil } } log.Printf("[DEBUG] IsVAppCdrom: vApp ISO transport is not required") return false, nil }
c170137
log.Printf("[DEBUG] DatastorePathFromString: success: %t, path: %q", success, p) return dp, success }
c170138
log.Printf("[DEBUG] IsVmdkDatastorePath: %q %s a datastore path", p, structure.LogCond(isVMDK, "is", "is not")) return isVMDK }
c170139
return types.VirtualDiskType(""), err } t := di[0].DiskType log.Printf("[DEBUG] QueryDiskType: Disk %q is of type %q", name, t) return types.VirtualDiskType(t), nil }
c170140
return err } tctx, tcancel := context.WithTimeout(context.Background(), provider.DefaultAPITimeout) defer tcancel() if err := task.Wait(tctx); err != nil { return err } log.Printf("[DEBUG] Virtual disk %q in datacenter %s deleted succesfully", name, dc) return nil }
c170141
soap.ToSoapFault(err), true } return nil, false }
c170142
sf.VimFault(), true } return nil, false }
c170143
return te.Fault(), true } return nil, false }
c170144
ok { if _, ok := f.(types.ManagedObjectNotFound); ok { return true } } return false }
c170145
ok { if _, ok := f.(types.NotFound); ok { return true } } return false }
c170146
case isNotFoundError(err): return true } return false }
c170147
ok { if _, ok := f.(types.ResourceInUse); ok { return true } } return false }
c170148
{ f, ok = taskFault(err) } if ok { switch f.(type) { case types.ConcurrentAccess, *types.ConcurrentAccess: return true } } return false }
c170149
return err } t := object.NewTask(client.Client, res.Returnval) tctx, tcancel := context.WithTimeout(context.Background(), provider.DefaultAPITimeout) defer tcancel() return t.Wait(tctx) }
c170150
return errors.New(ErrVirtualCenterOnly) } return nil }
c170151
%q", s[1], version) } v.Patch, err = strconv.Atoi(s[2]) if err != nil { return v, fmt.Errorf("could not parse patch version %q from version string %q", s[2], version) } v.Build, err = strconv.Atoi(build) if err != nil { return v, fmt.Errorf("could not parse build version string %q", build) } return v, nil }
c170152
info.Version, info.Build) if err != nil { panic(err) } return v }
c170153
{ return parseVersionFromAboutInfo(client.Client.ServiceContent.About) }
c170154
v.Product, v.Major, v.Minor, v.Patch, v.Build) }
c170155
return v.Product == other.Product }
c170156
moving on to the build number if v.newerVersion(other) { return false } if v.Build < other.Build { return true } return false }
c170157
v.ProductEqual(other) && !v.Older(other) && !v.Newer(other) }
c170158
err } obj := &types.ClusterVmGroup{ ClusterGroupInfo: types.ClusterGroupInfo{ Name: name, UserCreated: structure.BoolPtr(true), }, Vm: results.ManagedObjectReferences(), } return obj, nil }
c170159
client, obj.Vm, ) if err != nil { return err } return structure.SetBatch(d, map[string]interface{}{ "virtual_machine_ids": results.UUIDs(), }) }
c170160
return vmInfo, nil } return nil, fmt.Errorf("unique group name %q in cluster %q is not a VM group", name, cluster.Name()) } } log.Printf("[DEBUG] No VM group name %q found in cluster %q", name, cluster.Name()) return nil, nil }
c170161
:= clustercomputeresource.FromID(client, clusterID) if err != nil { return nil, "", fmt.Errorf("cannot locate cluster: %s", err) } return cluster, name, nil }
c170162
skipping", resourceVSphereComputeClusterIDString(d)) return nil } log.Printf("[DEBUG] %s: Applying any pending tags", resourceVSphereResourcePoolIDString(d)) return processTagDiff(tagsClient, d, rp) }
c170163
return err } } else { log.Printf("[DEBUG] %s: Tags unsupported on this connection, skipping tag read", resourceVSphereResourcePoolIDString(d)) } return nil }
c170164
if err != nil { return nil, err } obj := &types.ClusterAffinityRuleSpec{ ClusterRuleInfo: types.ClusterRuleInfo{ Enabled: structure.GetBool(d, "enabled"), Mandatory: structure.GetBool(d, "mandatory"), Name: d.Get("name").(string), UserCreated: structure.BoolPtr(true), }, Vm: results.ManagedObjectReferences(), } return obj, nil }
c170165
return err } return structure.SetBatch(d, map[string]interface{}{ "enabled": obj.Enabled, "mandatory": obj.Mandatory, "name": obj.Name, "virtual_machine_ids": results.UUIDs(), }) }
c170166
return vmAffinityRuleInfo, nil } return nil, fmt.Errorf("rule key %d in cluster %q is not a VM affinity rule", key, cluster.Name()) } } log.Printf("[DEBUG] No VM affinity rule key %d found in cluster %q", key, cluster.Name()) return nil, nil }
c170167
schema.TypeMap, Description: "A list of custom attributes to set on this resource.", Optional: true, } }
c170168
ValidateFunc: validation.IntAtLeast(10), }, "customize": { Type: schema.TypeList, Optional: true, MaxItems: 1, Description: "The customization spec for this clone. This allows the user to configure the virtual machine post-clone.", Elem: &schema.Resource{Schema: VirtualMachineCustomizeSchema()}, }, } }
c170169
{ return fmt.Errorf("could not find resource pool ID %q: %s", poolID, err) } family, err := resourcepool.OSFamily(c, pool, d.Get("guest_id").(string)) if err != nil { return fmt.Errorf("cannot find OS family for guest ID %q: %s", d.Get("guest_id").(string), err) } if err := ValidateCustomizationSpec(d, family); err != nil { return err } } else { log.Printf("[DEBUG] ValidateVirtualMachineClone: resource_pool_id is not available. Skipping OS family check.") } } vconfig := vprops.Config.VAppConfig if vconfig != nil { // We need to set the vApp transport types here so that it is available // later in CustomizeDiff where transport requirements are validated in // ValidateVAppTransport d.SetNew("vapp_transport", vconfig.GetVmConfigInfo().OvfEnvironmentTransport) } log.Printf("[DEBUG] ValidateVirtualMachineClone: Source VM/template %s is a suitable source for cloning", tUUID) return nil }
c170170
children", props.Config.Uuid) } // Current snapshot must match root snapshot (this should be the case anyway) if props.Snapshot.CurrentSnapshot.Value != props.Snapshot.RootSnapshotList[0].Snapshot.Value { return fmt.Errorf("virtual machine or template %s's current snapshot must match root snapshot", props.Config.Uuid) } return nil }
c170171
nc := object.NewCommon(client.Client, net.Reference()) if err := nc.Properties(ctx, nc.Reference(), nil, &props); err != nil { return nil, err } return &props, nil }
c170172
finder.DefaultHostSystem(ctx) case "VirtualCenter": if name != "" { return finder.HostSystem(ctx, name) } return finder.DefaultHostSystem(ctx) } return nil, fmt.Errorf("unsupported ApiType: %s", t) }
c170173
err := host.Properties(ctx, host.Reference(), nil, &props); err != nil { return nil, err } return &props, nil }
c170174
provider.DefaultAPITimeout) defer cancel() return host.ResourcePool(ctx) }
c170175
if err != nil { return "", err } return hs.Name(), nil }
c170176
if err != nil { return id } return name }
c170177
ctx, cancel := context.WithTimeout(context.Background(), time.Second*time.Duration(timeout)) defer cancel() task, err := host.EnterMaintenanceMode(ctx, int32(timeout), evacuate, nil) if err != nil { return err } return task.Wait(ctx) }
c170178
timeout + 300 ctx, cancel := context.WithTimeout(context.Background(), time.Second*time.Duration(ctxTimeout)) defer cancel() task, err := host.ExitMaintenanceMode(ctx, int32(timeout)) if err != nil { return err } return task.Wait(ctx) }
c170179
err := methods.QueryDvsByUuid(context.TODO(), client, req) if err != nil { return nil, err } return dvsFromMOID(client, resp.Returnval.Reference().Value) }
c170180
nil, fmt.Errorf("network at path %q is not a VMware distributed virtual switch (type %s)", name, net.Reference().Type) } return dvsFromMOID(client, net.Reference().Value) }
c170181
if err := dvs.Properties(ctx, dvs.Reference(), nil, &props); err != nil { return nil, err } return &props, nil }
c170182
}, } ctx, cancel := context.WithTimeout(context.Background(), defaultAPITimeout) defer cancel() resp, err := methods.PerformDvsProductSpecOperation_Task(ctx, client, req) if err != nil { return err } task := object.NewTask(client.Client, resp.Returnval) tctx, tcancel := context.WithTimeout(context.Background(), defaultAPITimeout) defer tcancel() if err := task.Wait(tctx); err != nil { return err } return nil }
c170183
defaultAPITimeout) defer cancel() _, err := methods.EnableNetworkResourceManagement(ctx, client, req) if err != nil { return err } return nil }
c170184
return strings.Join([]string{podID, strconv.Itoa(int(key))}, ":"), nil }
c170185
return vmAntiAffinityRuleInfo, nil } return nil, fmt.Errorf("rule key %d in datastore cluster %q is not a VM anti-affinity rule", key, pod.Name()) } } log.Printf("[DEBUG] No VM anti-affinity rule key %d found in datastore cluster %q", key, pod.Name()) return nil, nil }
c170186
return vmAntiAffinityRuleInfo, nil } return nil, fmt.Errorf("rule %q in datastore cluster %q is not a VM anti-affinity rule", name, pod.Name()) } } return nil, fmt.Errorf("no VM anti-affinity rule %q found in datastore cluster %q", name, pod.Name()) }
c170187
:= storagepod.FromID(client, podID) if err != nil { return nil, 0, fmt.Errorf("cannot locate datastore cluster: %s", err) } return pod, key, nil }
c170188
case *types.VirtualPCIController: t = SubresourceControllerTypePCI case *types.ParaVirtualSCSIController, *types.VirtualBusLogicController, *types.VirtualLsiLogicController, *types.VirtualLsiLogicSASController: t = SubresourceControllerTypeSCSI default: return subresourceControllerTypeUnknown, fmt.Errorf("unsupported controller type %T", c) } return t, nil }
c170189
{ return fmt.Sprintf("%s.%d", r.srtype, r.Index) }
c170190
{ o, n := r.GetChange(key) return !reflect.DeepEqual(o, n) }
c170191
means no change, so we use the new value as a placeholder. old := r.data[key] if r.olddata != nil { old = r.olddata[key] } return old, new }
c170192
{ if r.HasChange(key) { r.SetRestart(key) } return r.Get(key) }
c170193
value of %q - (old: %v new: %v)", key, old, new) } return r.Get(key), nil }
c170194
d.Set("reboot_required", true) case *schema.ResourceDiff: d.SetNew("reboot_required", true) default: // This should never happen, but log if it does. log.Printf("[WARN] %s: Could not flag reboot_required: invalid type %T", r, r.rdd) } }
c170195
HashResource(&schema.Resource{Schema: r.schema}) return hf(r.data) }
c170196
parts := []string{ ctype, strconv.Itoa(int(vc.BusNumber)), strconv.Itoa(int(structure.DeRef(vd.UnitNumber).(int32))), } return strings.Join(parts, ":"), nil }
c170197
du, fmt.Errorf("invalid controller type %q found in ID", ct) } if cbe != nil { return ct, cb, du, fmt.Errorf("invalid bus number %q found in ID", cbs) } if due != nil { return ct, cb, du, fmt.Errorf("invalid disk unit number %q found in ID", dus) } return ct, cb, du, nil }
c170198
return false } case SubresourceControllerTypePCI: if _, ok := device.(*types.VirtualPCIController); !ok { return false } } vc := device.(types.BaseVirtualController).GetVirtualController() if vc.BusNumber == int32(cb) { return true } return false } }
c170199
if vd.ControllerKey == ckey && vd.UnitNumber != nil && *vd.UnitNumber == int32(du) { return true } return false } }