id stringlengths 2 7 | text stringlengths 17 51.2k | title stringclasses 1 value |
|---|---|---|
c170200 | controller key %d for device %d", vd.ControllerKey, vd.Key)
}
return ctlr.(types.BaseVirtualController), nil
} | |
c170201 |
ckey := ctlr.GetVirtualDevice().Key
dsf := findVirtualDeviceInListDeviceSelectFunc(ckey, du)
devices := l.Select(dsf)
if len(devices) != 1 {
return nil, fmt.Errorf("invalid device result - %d results returned (expected 1): controller key %q, disk number: %d", len(devices), ckey, du)
}
device := devices[0]
log.Printf("[DEBUG] FindVirtualDevice: Device found: %s", l.Name(device))
return device, nil
} | |
c170202 | log.Printf("[DEBUG] FindVirtualDevice: Device found: %s", l.Name(dev))
return dev, nil
}
return nil, fmt.Errorf("could not find device with key %d", key)
}
return r.FindVirtualDeviceByAddr(l)
} | |
c170203 | device>"
}
return fmt.Sprintf("%s (key %d at %s)", r.Addr(), r.Get("key").(int), devaddr)
} | |
c170204 | nsd.GetVirtualDevice().Key
for _, vd := range l {
if vd.GetVirtualDevice().ControllerKey == ockey {
vd.GetVirtualDevice().ControllerKey = nckey
cspec, err := object.VirtualDeviceList{vd}.ConfigSpec(types.VirtualDeviceConfigSpecOperationEdit)
if err != nil {
return nil, err
}
if len(cspec) != 1 {
return nil, fmt.Errorf("incorrect number of config spec items returned - expected 1, got %d", len(cspec))
}
// Clear the file operation
cspec[0].GetVirtualDeviceConfigSpec().FileOperation = ""
spec = append(spec, cspec...)
}
}
log.Printf("[DEBUG] swapSCSIDevice: Outgoing device config spec: %s", DeviceChangeString(spec))
return spec, nil
} | |
c170205 | != nil {
return nil, nil, err
}
spec = append(spec, cspec...)
continue
}
if l.Type(ctlr.(types.BaseVirtualDevice)) == ct {
cspec, err := setSCSIBusSharing(&l, ctlr, st)
if err != nil {
return nil, nil, err
}
spec = append(spec, cspec...)
continue
}
cspec, err := swapSCSIDevice(l, ctlr, ct, st)
if err != nil {
return nil, nil, err
}
spec = append(spec, cspec...)
l = applyDeviceChange(l, cspec)
continue
}
log.Printf("[DEBUG] NormalizeSCSIBus: Outgoing device list: %s", DeviceListString(l))
log.Printf("[DEBUG] NormalizeSCSIBus: Outgoing device config spec: %s", DeviceChangeString(spec))
return l, spec, nil
} | |
c170206 | object.VirtualDeviceList{ctlr.(types.BaseVirtualDevice)}.ConfigSpec(types.VirtualDeviceConfigSpecOperationEdit)
if err != nil {
return nil, err
}
*l = applyDeviceChange(*l, cspec)
}
return cspec, nil
} | |
c170207 | cspec, err := object.VirtualDeviceList{nc}.ConfigSpec(types.VirtualDeviceConfigSpecOperationAdd)
*l = applyDeviceChange(*l, cspec)
return cspec, err
} | |
c170208 | count, scsiControllerListString(ctlrs))
if ctlrs[0] == nil {
return subresourceControllerTypeUnknown
}
last := l.Type(ctlrs[0].(types.BaseVirtualDevice))
for _, ctlr := range ctlrs[1:] {
if ctlr == nil || l.Type(ctlr.(types.BaseVirtualDevice)) != last {
return subresourceControllerTypeMixed
}
}
return last
} | |
c170209 | return subresourceControllerSharingUnknown
}
last := ctlrs[0].(types.BaseVirtualSCSIController).GetVirtualSCSIController().SharedBus
for _, ctlr := range ctlrs[1:] {
if ctlr == nil || ctlr.(types.BaseVirtualSCSIController).GetVirtualSCSIController().SharedBus != last {
return subresourceControllerSharingMixed
}
}
return string(last)
} | |
c170210 | device.(type) {
case types.BaseVirtualSCSIController:
return d.GetVirtualSCSIController().BusNumber == int32(bus)
}
return false
})
if len(l) == 0 {
return nil, fmt.Errorf("could not find scsi controller at bus number %d", bus)
}
log.Printf("[DEBUG] pickSCSIController: Found SCSI controller: %s", l.Name(l[0]))
return l[0].(types.BaseVirtualController), nil
} | |
c170211 |
ctlr = l.PickController(&types.VirtualPCIController{})
default:
return nil, fmt.Errorf("invalid controller type %T", ct)
}
if err != nil {
return nil, err
}
if ctlr == nil {
return nil, fmt.Errorf("could not find an available %s controller", ct)
}
// Assert that we are on bus 0 when we aren't looking for a SCSI controller.
// We currently do not support attaching devices to multiple non-SCSI buses.
if ctlr.GetVirtualController().BusNumber != 0 && ct != SubresourceControllerTypeSCSI {
return nil, fmt.Errorf("there are no available slots on the primary %s controller", ct)
}
log.Printf("[DEBUG] ControllerForCreateUpdate: Found controller: %s", l.Name(ctlr.(types.BaseVirtualDevice)))
return ctlr, nil
} | |
c170212 | in implementation anywhere.
for n, dev := range l {
if dev.GetVirtualDevice().Key == spec.Device.GetVirtualDevice().Key {
l[n] = spec.Device
}
}
case types.VirtualDeviceConfigSpecOperationRemove:
for i := 0; i < len(l); i++ {
dev := l[i]
if dev.GetVirtualDevice().Key == spec.Device.GetVirtualDevice().Key {
l = append(l[:i], l[i+1:]...)
i--
}
}
default:
panic("unknown op")
}
}
log.Printf("[DEBUG] applyDeviceChange: Device list after changes: %s", DeviceListString(l))
return l
} | |
c170213 | } else {
names = append(names, l.Name(d))
}
}
return strings.Join(names, ",")
} | |
c170214 | key %d)", string(spec.Operation), spec.Device, spec.Device.GetVirtualDevice().Key))
}
return strings.Join(strs, ",")
} | |
c170215 |
devaddr = "<new device>"
}
strs = append(strs, fmt.Sprintf("(key %d at %s)", m["key"].(int), devaddr))
}
return strings.Join(strs, ",")
} | |
c170216 |
} else {
l = append(l, ctlr.(types.BaseVirtualDevice))
}
}
return DeviceListString(l)
} | |
c170217 |
c := copystructure.Must(copystructure.Copy(op)).(types.BaseVirtualDeviceConfigSpec)
spec = append(spec, c)
}
return spec
} | |
c170218 | d.Get("name").(string),
UserCreated: structure.BoolPtr(true),
},
DependsOnVmGroup: d.Get("dependency_vm_group_name").(string),
VmGroup: d.Get("vm_group_name").(string),
}
return obj, nil
} | |
c170219 | obj.Mandatory,
"name": obj.Name,
"dependency_vm_group_name": obj.DependsOnVmGroup,
"vm_group_name": obj.VmGroup,
})
} | |
c170220 | := strconv.Atoi(parts[1])
if err != nil {
return "", 0, fmt.Errorf("bad key in ID %q: %s", parts[1], err)
}
return parts[0], int32(key), nil
} | |
c170221 | := clustercomputeresource.FromID(client, clusterID)
if err != nil {
return nil, 0, fmt.Errorf("cannot locate cluster: %s", err)
}
return cluster, key, nil
} | |
c170222 | if err != nil {
return nil, fmt.Errorf("cannot locate folder: %s", err)
}
// Create the storage pod (datastore cluster).
pod, err := storagepod.Create(f, d.Get("name").(string))
if err != nil {
return nil, fmt.Errorf("error creating datastore cluster: %s", err)
}
// Set the ID now before proceeding with tags, custom attributes, and DRS.
// This ensures that we can recover from a problem with any of these
// operations.
d.SetId(pod.Reference().Value)
return pod, nil
} | |
c170223 | skipping", resourceVSphereDatastoreClusterIDString(d))
return nil
}
log.Printf("[DEBUG] %s: Applying any pending tags", resourceVSphereDatastoreClusterIDString(d))
return processTagDiff(tagsClient, d, pod)
} | |
c170224 | return err
}
} else {
log.Printf("[DEBUG] %s: Tags unsupported on this connection, skipping tag read", resourceVSphereDatastoreClusterIDString(d))
}
return nil
} | |
c170225 | if err != nil {
return err
}
if attrsProcessor == nil {
log.Printf("[DEBUG] %s: Custom attributes unsupported on this connection, skipping", resourceVSphereDatastoreClusterIDString(d))
return nil
}
log.Printf("[DEBUG] %s: Applying any pending custom attributes", resourceVSphereDatastoreClusterIDString(d))
return attrsProcessor.ProcessDiff(pod)
} | |
c170226 |
return err
}
customattribute.ReadFromResource(client, props.Entity(), d)
} else {
log.Printf("[DEBUG] %s: Custom attributes unsupported on this connection, skipping", resourceVSphereDatastoreClusterIDString(d))
}
return nil
} | |
c170227 | help determine what
// attributes we need to set
version := viapi.ParseVersionFromClient(client)
// Expand the SDRS configuration.
spec := types.StorageDrsConfigSpec{
PodConfigSpec: expandStorageDrsPodConfigSpec(d, version),
}
return storagepod.ApplyDRSConfiguration(client, pod, spec)
} | |
c170228 | {
switch {
case resourceVSphereDatastoreClusterHasSDRSConfigChangeExcluded(k):
continue
case d.HasChange(k):
return true
}
}
return false
} | |
c170229 |
if err := viapi.ValidateVirtualCenter(client); err != nil {
return nil, err
}
return storagepod.FromID(client, d.Id())
} | |
c170230 | {
log.Printf("[DEBUG] Fetching datastore cluster at path %q", path)
}
if err := viapi.ValidateVirtualCenter(client); err != nil {
return nil, err
}
return storagepod.FromPath(client, path, dc)
} | |
c170231 | err := folder.RootPathParticleDatastore.SplitRelativeFolder(pod.InventoryPath)
if err != nil {
return fmt.Errorf("error parsing datastore cluster path %q: %s", pod.InventoryPath, err)
}
if err := d.Set("folder", folder.NormalizePath(f)); err != nil {
return fmt.Errorf("error saving folder: %s", err)
}
return nil
} | |
c170232 | pod so that we have the new inventory path for logging and
// other things
pod, err = resourceVSphereDatastoreClusterGetPod(d, meta)
if err != nil {
return nil, fmt.Errorf("error refreshing datastore cluster after name change: %s", err)
}
log.Printf(
"[DEBUG] %s: Name changed, new path = %q",
resourceVSphereDatastoreClusterIDString(d),
pod.InventoryPath,
)
}
return pod, nil
} | |
c170233 | = storagepod.MoveToFolder(client, pod, f); err != nil {
return nil, fmt.Errorf("could not move datastore cluster to folder %q: %s", f, err)
}
changed = true
}
if changed {
// Update the pod so that we have the new inventory path for logging and
// other things
pod, err = resourceVSphereDatastoreClusterGetPod(d, meta)
if err != nil {
return nil, fmt.Errorf("error refreshing pod after folder change: %s", err)
}
log.Printf(
"[DEBUG] %s: Folder changed, new path = %q",
resourceVSphereDatastoreClusterIDString(d),
pod.InventoryPath,
)
}
return pod, nil
} | |
c170234 | cluster contents: %s", err)
}
if ne {
return fmt.Errorf(
"datastore cluster %q still has datastores. Please move or remove all datastores before deleting",
pod.InventoryPath,
)
}
return nil
} | |
c170235 | cluster deletion", resourceVSphereDatastoreClusterIDString(d))
if err := storagepod.Delete(pod); err != nil {
return err
}
d.SetId("")
return nil
} | |
c170236 |
version := viapi.ParseVersionFromClient(client)
props, err := storagepod.Properties(pod)
if err != nil {
return err
}
return flattenStorageDrsPodConfigInfo(d, props.PodStorageDrsEntry.StorageDrsConfig.PodConfig, version)
} | |
c170237 | int32(d.Get("sdrs_load_balance_interval").(int)),
SpaceLoadBalanceConfig: expandStorageDrsSpaceLoadBalanceConfig(d, version),
Option: expandStorageDrsOptionSpec(d),
}
if version.Newer(viapi.VSphereVersion{Product: version.Product, Major: 6}) {
obj.AutomationOverrides = expandStorageDrsAutomationConfig(d)
}
return obj
} | |
c170238 | }
if err := flattenStorageDrsIoLoadBalanceConfig(d, obj.IoLoadBalanceConfig, version); err != nil {
return err
}
if err := flattenStorageDrsSpaceLoadBalanceConfig(d, obj.SpaceLoadBalanceConfig, version); err != nil {
return err
}
if err := flattenStorageDrsOptionSpec(d, obj.Option); err != nil {
return err
}
if version.Newer(viapi.VSphereVersion{Product: version.Product, Major: 6}) {
if err := flattenStorageDrsAutomationConfig(d, obj.AutomationOverrides); err != nil {
return err
}
}
return nil
} | |
c170239 | SpaceLoadBalanceAutomationMode: d.Get("sdrs_space_balance_automation_level").(string),
VmEvacuationAutomationMode: d.Get("sdrs_vm_evacuation_automation_level").(string),
}
return obj
} | |
c170240 | "sdrs_rule_enforcement_automation_level": obj.RuleEnforcementAutomationMode,
"sdrs_space_balance_automation_level": obj.SpaceLoadBalanceAutomationMode,
"sdrs_vm_evacuation_automation_level": obj.VmEvacuationAutomationMode,
}
for k, v := range attrs {
if err := d.Set(k, v); err != nil {
return fmt.Errorf("error setting attribute %q: %s", k, err)
}
}
return nil
} | |
c170241 |
}
if version.Newer(viapi.VSphereVersion{Product: version.Product, Major: 6}) {
obj.ReservableIopsThreshold = int32(d.Get("sdrs_io_reservable_iops_threshold").(int))
obj.ReservablePercentThreshold = int32(d.Get("sdrs_io_reservable_percent_threshold").(int))
obj.ReservableThresholdMode = d.Get("sdrs_io_reservable_threshold_mode").(string)
}
return obj
} | |
c170242 | attrs["sdrs_io_reservable_iops_threshold"] = obj.ReservableIopsThreshold
} else {
attrs["sdrs_io_reservable_percent_threshold"] = obj.ReservablePercentThreshold
}
}
for k, v := range attrs {
if err := d.Set(k, v); err != nil {
return fmt.Errorf("error setting attribute %q: %s", k, err)
}
}
return nil
} | |
c170243 | }
if version.Newer(viapi.VSphereVersion{Product: version.Product, Major: 6}) {
obj.FreeSpaceThresholdGB = int32(d.Get("sdrs_free_space_threshold").(int))
obj.SpaceThresholdMode = d.Get("sdrs_free_space_threshold_mode").(string)
}
return obj
} | |
c170244 | version.Newer(viapi.VSphereVersion{Product: version.Product, Major: 6})
if freeSpaceSupported && obj.SpaceThresholdMode == string(types.StorageDrsSpaceLoadBalanceConfigSpaceThresholdModeFreeSpace) {
attrs["sdrs_free_space_threshold"] = obj.FreeSpaceThresholdGB
} else {
attrs["sdrs_space_utilization_threshold"] = obj.SpaceUtilizationThreshold
}
for k, v := range attrs {
if err := d.Set(k, v); err != nil {
return fmt.Errorf("error setting attribute %q: %s", k, err)
}
}
return nil
} | |
c170245 | opts = append(opts, types.StorageDrsOptionSpec{
Option: &types.OptionValue{
Key: k,
Value: types.AnyType(v),
},
})
}
return opts
} | |
c170246 | m[opt.GetOptionValue().Key] = opt.GetOptionValue().Value
}
return d.Set("sdrs_advanced_options", m)
} | |
c170247 | vsphere_folder state: completed v%d state: %#v", version, os)
return os, nil
}
if err := migrateFunc(os, meta); err != nil {
return nil, err
}
version++
log.Printf("[DEBUG] Migrating vsphere_folder state: new v%d state: %#v", version, os)
return resourceVSphereFolderMigrateState(version, os, meta)
} | |
c170248 |
// relative path.
fp := folder.RootPathParticleVM.PathFromDatacenter(dc, p)
folder, err := folder.FromAbsolutePath(client, fp)
if err != nil {
return err
}
// We got our folder!
//
// Read will handle everything except for the ID, so just wipe attributes,
// update the ID, and let read take care of the rest.
s.Attributes = make(map[string]string)
s.ID = folder.Reference().Value
return nil
} | |
c170249 | return finder.Datacenter(context.TODO(), dc)
}
return finder.DefaultDatacenter(context.TODO())
}
return nil, fmt.Errorf("unsupported ApiType: %s", t)
} | |
c170250 | err := finder.ObjectReference(ctx, ref)
if err != nil {
return nil, fmt.Errorf("could not find datacenter with id: %s: %s", id, err)
}
return ds.(*object.Datacenter), nil
} | |
c170251 | srtype: subresourceTypeDisk,
data: d,
olddata: old,
rdd: rdd,
},
}
sr.Index = idx
return sr
} | |
c170252 | diskApplyOperationCreateUpdate(ni, nm, ods, c, d, &l, &spec, &updates); err != nil {
return nil, nil, err
}
}
log.Printf("[DEBUG] DiskApplyOperation: Post-apply final resource list: %s", subresourceListString(updates))
// We are now done! Return the updated device list and config spec. Save updates as well.
if err := d.Set(subresourceTypeDisk, updates); err != nil {
return nil, nil, err
}
log.Printf("[DEBUG] DiskApplyOperation: Device list at end of operation: %s", DeviceListString(l))
log.Printf("[DEBUG] DiskApplyOperation: Device config operations from apply: %s", DeviceChangeString(spec))
log.Printf("[DEBUG] DiskApplyOperation: Apply complete, returning updated spec")
return l, spec, nil
} | |
c170253 | error
if name, err = diskLabelOrName(newData); err != nil {
return err
}
if (name == diskDeletedName || name == diskDetachedName) && oldData["uuid"] == newData["uuid"] {
didx = ni
break
}
}
if didx < 0 {
// Deleted entry not found
return nil
}
r := NewDiskSubresource(c, d, oldData, nil, index)
dspec, err := r.Delete(*l)
if err != nil {
return fmt.Errorf("%s: %s", r.Addr(), err)
}
*l = applyDeviceChange(*l, dspec)
*spec = append(*spec, dspec...)
return nil
} | |
c170254 | = newData["datastore_id"]
oldCopy["keep_on_remove"] = newData["keep_on_remove"]
// TODO: Remove these in 2.0, when all attributes should bear a label and
// name is gone, and we won't need to exempt transitions.
oldCopy["label"] = newData["label"]
oldCopy["name"] = newData["name"]
if reflect.DeepEqual(oldCopy, newData) {
*updates = append(*updates, r.Data())
return nil
}
uspec, err := r.Update(*l)
if err != nil {
return fmt.Errorf("%s: %s", r.Addr(), err)
}
*l = applyDeviceChange(*l, uspec)
*spec = append(*spec, uspec...)
*updates = append(*updates, r.Data())
return nil
}
}
// New data was not found - this is a create operation
r := NewDiskSubresource(c, d, newData, nil, index)
cspec, err := r.Create(*l)
if err != nil {
return fmt.Errorf("%s: %s", r.Addr(), err)
}
*l = applyDeviceChange(*l, cspec)
*spec = append(*spec, cspec...)
*updates = append(*updates, r.Data())
return nil
} | |
c170255 | nm["datastore_id"] == "" || nm["datastore_id"] == diskDatastoreComputedName {
break
}
r := NewDiskSubresource(c, d, nm, om, ni)
relocator, err := r.Relocate(l, false)
if err != nil {
return nil, false, fmt.Errorf("%s: %s", r.Addr(), err)
}
if d.Get("datastore_id").(string) == relocator.Datastore.Value {
log.Printf("[DEBUG] %s: Datastore in spec is same as default, dropping in favor of implicit relocation", r.Addr())
break
}
relocators = append(relocators, relocator)
}
}
}
if !relocateOK {
log.Printf("[DEBUG] DiskMigrateRelocateOperation: Disk relocation not necessary")
return nil, false, nil
}
log.Printf("[DEBUG] DiskMigrateRelocateOperation: Disk relocator list: %s", diskRelocateListString(relocators))
log.Printf("[DEBUG] DiskMigrateRelocateOperation: Disk relocator generation complete")
return relocators, true, nil
} | |
c170256 | err error
m["device_address"], err = computeDevAddr(vd, ctlr.(types.BaseVirtualController))
if err != nil {
return nil, fmt.Errorf("error computing device address: %s", err)
}
r := NewDiskSubresource(c, d, m, nil, i)
// A disk locator is only useful if a target datastore is available. If we
// don't have a datastore specified (ie: when Storage DRS is in use), then
// we just need to skip this disk. The disk will be migrated properly
// through the SDRS API.
if dsID := r.Get("datastore_id"); dsID == "" || dsID == diskDatastoreComputedName {
continue
}
// Otherwise, proceed with generating and appending the locator.
relocator, err := r.Relocate(l, true)
if err != nil {
return nil, fmt.Errorf("%s: %s", r.Addr(), err)
}
relocators = append(relocators, relocator)
}
log.Printf("[DEBUG] DiskCloneRelocateOperation: Disk relocator list: %s", diskRelocateListString(relocators))
log.Printf("[DEBUG] DiskCloneRelocateOperation: Disk relocator generation complete")
return relocators, nil
} | |
c170257 | i,
addr,
device.(*types.VirtualDisk).Backing,
)
}
m := make(map[string]interface{})
// Save information so that the next DiskRefreshOperation can pick this
// disk up as if it was newly added and not attempt to try and line up
// UUIDs. We use a negative key for this reason, in addition to assigning
// the device address.
m["key"] = (i + 1) * -1
m["device_address"] = addr
// Assign a computed label. This label *needs* be the label this disk is
// assigned in config, or you risk service interruptions or data corruption.
m["label"] = fmt.Sprintf("disk%d", i)
// Set keep_on_remove to ensure that if labels are assigned incorrectly,
// all that happens is that the disk is removed. The comments above
// regarding the risk of incorrect label assignment are still true, but
// this greatly reduces the risk of data loss.
m["keep_on_remove"] = true
curSet = append(curSet, m)
}
log.Printf("[DEBUG] DiskImportOperation: Discovered disks from import: %s", subresourceListString(curSet))
if err := d.Set(subresourceTypeDisk, curSet); err != nil {
return err
}
log.Printf("[DEBUG] DiskImportOperation: Pre-read import and validation complete")
return nil
} | |
c170258 | after sort: %s", DeviceListString(devices))
var out []map[string]interface{}
for i, device := range devices {
disk := device.(*types.VirtualDisk)
backing, ok := disk.Backing.(*types.VirtualDiskFlatVer2BackingInfo)
if !ok {
return nil, fmt.Errorf("disk number %d has an unsupported backing type (expected flat VMDK version 2, got %T)", i, disk.Backing)
}
m := make(map[string]interface{})
var eager, thin bool
if backing.EagerlyScrub != nil {
eager = *backing.EagerlyScrub
}
if backing.ThinProvisioned != nil {
thin = *backing.ThinProvisioned
}
m["size"] = diskCapacityInGiB(disk)
m["eagerly_scrub"] = eager
m["thin_provisioned"] = thin
out = append(out, m)
}
log.Printf("[DEBUG] ReadDiskAttrsForDataSource: Attributes returned: %+v", out)
return out, nil
} | |
c170259 | fmt.Errorf("incorrect number of config spec items returned - expected 1, got %d", len(dspec))
}
// Clear the file operation if we are attaching.
if r.Get("attach").(bool) {
dspec[0].GetVirtualDeviceConfigSpec().FileOperation = ""
}
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
} | |
c170260 | "" {
r.Set("disk_sharing", b.Sharing)
}
if !attach {
r.Set("thin_provisioned", b.ThinProvisioned)
r.Set("eagerly_scrub", b.EagerlyScrub)
}
r.Set("datastore_id", b.Datastore.Value)
// Disk settings
if !attach {
dp := &object.DatastorePath{}
if ok := dp.FromString(b.FileName); !ok {
return fmt.Errorf("could not parse path from filename: %s", b.FileName)
}
r.Set("path", dp.Path)
r.Set("size", diskCapacityInGiB(disk))
}
if allocation := disk.StorageIOAllocation; allocation != nil {
r.Set("io_limit", allocation.Limit)
r.Set("io_reservation", allocation.Reservation)
if shares := allocation.Shares; shares != nil {
r.Set("io_share_level", string(shares.Level))
r.Set("io_share_count", shares.Shares)
}
}
log.Printf("[DEBUG] %s: Read finished (key and device address may have changed)", r)
return nil
} | |
c170261 | the settings.
if err := r.expandDiskSettings(disk); err != nil {
return nil, err
}
dspec, err := object.VirtualDeviceList{disk}.ConfigSpec(types.VirtualDeviceConfigSpecOperationEdit)
if err != nil {
return nil, err
}
if len(dspec) != 1 {
return nil, fmt.Errorf("incorrect number of config spec items returned - expected 1, got %d", len(dspec))
}
// Clear file operation - VirtualDeviceList currently sets this to replace, which is invalid
dspec[0].GetVirtualDeviceConfigSpec().FileOperation = ""
log.Printf("[DEBUG] %s: Device config operations from update: %s", r, DeviceChangeString(dspec))
log.Printf("[DEBUG] %s: Update complete", r)
return dspec, nil
} | |
c170262 |
}
if r.Get("keep_on_remove").(bool) || r.Get("attach").(bool) {
// Clear file operation so that the disk is kept on remove.
deleteSpec[0].GetVirtualDeviceConfigSpec().FileOperation = ""
}
log.Printf("[DEBUG] %s: Device config operations from update: %s", r, DeviceChangeString(deleteSpec))
log.Printf("[DEBUG] %s: Delete completed", r)
return deleteSpec, nil
} | |
c170263 | value if we don't have custom shares set
osc, _ := r.GetChange("io_share_count")
if r.Get("io_share_level").(string) != string(types.SharesLevelCustom) {
r.Set("io_share_count", osc)
}
// Ensure that the user is not attempting to shrink the disk. If we do more
// we might want to change the name of this method, but we want to check this
// here as CustomizeDiff is meant for vetoing.
osize, nsize := r.GetChange("size")
if osize.(int) > nsize.(int) {
return fmt.Errorf("virtual disk %q: virtual disks cannot be shrunk (old: %d new: %d)", name, osize.(int), nsize.(int))
}
// Ensure that there is no change in either eagerly_scrub or thin_provisioned
// - these values cannot be changed once set.
if _, err = r.GetWithVeto("eagerly_scrub"); err != nil {
return fmt.Errorf("virtual disk %q: %s", name, err)
}
if _, err = r.GetWithVeto("thin_provisioned"); err != nil {
return fmt.Errorf("virtual disk %q: %s", name, err)
}
// Same with attach
if _, err = r.GetWithVeto("attach"); err != nil {
return fmt.Errorf("virtual disk %q: %s", name, err)
}
// Validate storage vMotion if the datastore is changing
if r.HasChange("datastore_id") {
if err = r.validateStorageRelocateDiff(); err != nil {
return err
}
}
log.Printf("[DEBUG] %s: Normalization of existing disk diff complete", r)
return nil
} | |
c170264 | return fmt.Errorf("size for disk %q: required option not set", name)
}
}
// Block certain options from being set depending on the vSphere version.
version := viapi.ParseVersionFromClient(r.client)
if r.Get("disk_sharing").(string) != string(types.VirtualDiskSharingSharingNone) {
if version.Older(viapi.VSphereVersion{Product: version.Product, Major: 6}) {
return fmt.Errorf("multi-writer disk_sharing is only supported on vSphere 6 and higher")
}
}
// Prevent eagerly_scrub and thin_provisioned from both being set to true. A
// thin_provisioned disk cannot be eagerly scrubbed since it would then be
// allocating the entire disk.
if r.Get("eagerly_scrub").(bool) && r.Get("thin_provisioned").(bool) {
return fmt.Errorf("%s: eagerly_scrub and thin_provisioned cannot both be set to true", name)
}
log.Printf("[DEBUG] %s: Diff validation complete", r)
return nil
} | |
c170265 | membership of disk", r)
pod, err := storagepod.FromID(r.client, podID)
if err != nil {
return fmt.Errorf("error fetching datastore cluster ID %q: %s", podID, err)
}
ds, err := datastore.FromID(r.client, dsID.(string))
if err != nil {
return fmt.Errorf("error fetching datastore ID %q: %s", dsID, err)
}
isMember, err := storagepod.IsMember(pod, ds)
if err != nil {
return fmt.Errorf("error checking storage pod membership: %s", err)
}
if !isMember {
log.Printf(
"[DEBUG] %s: Disk's datastore %q not a member of cluster %q, marking datastore ID as computed",
r,
ds.Name(),
pod.Name(),
)
dsID = diskDatastoreComputedName
}
r.Set("datastore_id", dsID)
return nil
} | |
c170266 | we are cloning.
if r.rdd.Id() == "" {
log.Printf("[DEBUG] %s: Adding additional options to relocator for cloning", r)
backing := disk.Backing.(*types.VirtualDiskFlatVer2BackingInfo)
backing.FileName = ds.Path("")
backing.Datastore = &dsref
relocate.DiskBackingInfo = backing
}
// Done!
log.Printf("[DEBUG] %s: Generated disk locator: %s", r, diskRelocateString(relocate))
log.Printf("[DEBUG] %s: Relocate generation complete", r)
return relocate, nil
} | |
c170267 | if p == "" {
p = "<unknown>"
}
return fmt.Sprintf("%s (%s)", r.Subresource.String(), p)
} | |
c170268 | if os.(int) > ns.(int) {
return fmt.Errorf("virtual disks cannot be shrunk")
}
disk.CapacityInBytes = structure.GiBToByte(ns.(int))
disk.CapacityInKB = disk.CapacityInBytes / 1024
}
alloc := &types.StorageIOAllocationInfo{
Limit: structure.Int64Ptr(int64(r.Get("io_limit").(int))),
Reservation: structure.Int32Ptr(int32(r.Get("io_reservation").(int))),
Shares: &types.SharesInfo{
Shares: int32(r.Get("io_share_count").(int)),
Level: types.SharesLevel(r.Get("io_share_level").(string)),
},
}
disk.StorageIOAllocation = alloc
return nil
} | |
c170269 | if r.rdd.Get("datastore_cluster_id").(string) == "" {
if err := r.assignBackingInfo(disk); err != nil {
return nil, err
}
}
// Set a new device key for this device
disk.Key = l.NewKey()
return disk, nil
} | |
c170270 | units[*d.UnitNumber] = true
}
// We now have a valid list of units. If we need to, shift up the desired
// unit number so it's not taking the unit of the controller itself.
if unit >= scsiUnit {
unit++
}
if units[unit] {
return nil, fmt.Errorf("unit number %d on SCSI bus %d is in use", unit, bus)
}
// If we made it this far, we are good to go!
disk.ControllerKey = ctlr.GetVirtualController().Key
disk.UnitNumber = &unit
return ctlr, nil
} | |
c170271 | %d is not a SCSI controller (actual: %T)", ctlr.GetVirtualDevice().Key, ctlr)
}
unit := *disk.UnitNumber
if unit > sc.GetVirtualSCSIController().ScsiCtlrUnitNumber {
unit--
}
unit = unit + 15*sc.GetVirtualSCSIController().BusNumber
return int(unit), ctlr.(types.BaseVirtualController), nil
} | |
c170272 | var out []string
for _, relocate := range relocators {
out = append(out, diskRelocateString(relocate))
}
return strings.Join(out, ",")
} | |
c170273 | locstring = backing.FileName
} else {
locstring = relocate.Datastore.Value
}
return fmt.Sprintf("(%d => %s)", key, locstring)
} | |
c170274 | return true
}
liUnit := li.GetVirtualDevice().UnitNumber
ljUnit := lj.GetVirtualDevice().UnitNumber
if liUnit == nil || ljUnit == nil {
panic(errors.New("virtualDeviceListSorter cannot be used with devices that do not have unit numbers set"))
}
return *liUnit < *ljUnit
} | |
c170275 | l.Sort[i], l.Sort[j] = l.Sort[j], l.Sort[i]
} | |
c170276 |
return mi["unit_number"].(int) < mj["unit_number"].(int)
} | |
c170277 |
s[i], s[j] = s[j], s[i]
} | |
c170278 | return false
}
return path.Base(dp.Path) == path.Base(b)
} | |
c170279 | if err != nil {
return nil, err
}
return device.(*types.VirtualDisk), nil
} | |
c170280 |
log.Printf(
"[DEBUG] diskCapacityInGiB: capacityInBytes missing for for %s, falling back to capacityInKB",
object.VirtualDeviceList{}.Name(disk),
)
return int(structure.ByteToGiB(disk.CapacityInKB * 1024).(int64))
} | |
c170281 | := context.WithTimeout(context.Background(), defaultAPITimeout)
defer cancel()
return hs.ConfigManager().NetworkSystem(ctx)
} | |
c170282 | if err != nil {
return nil, err
}
return hostNetworkSystemFromHostSystem(hs)
} | |
c170283 | // Spec.Mtu is not set for vSwitches created directly
// in ESXi. TODO: Use sw.Mtu instead of sw.Spec.Mtu in
// flattenHostVirtualSwitchSpec.
sw.Spec.Mtu = sw.Mtu
return &sw, nil
}
}
return nil, fmt.Errorf("could not find virtual switch %s", name)
} | |
c170284 | nil, fmt.Errorf("error fetching host network properties: %s", err)
}
for _, pg := range mns.NetworkInfo.Portgroup {
if pg.Spec.Name == name {
return &pg, nil
}
}
return nil, fmt.Errorf("could not find port group %s", name)
} | |
c170285 | nets, err := finder.NetworkList(ctx, "*/"+name)
if err != nil {
return nil, err
}
for _, n := range nets {
net, ok := n.(*object.Network)
if !ok {
// Not a standard port group (possibly DVS, etc), pass
continue
}
props, err := network.Properties(net)
if err != nil {
return nil, err
}
for _, hsRef := range props.Host {
if hsRef.Value == hs.Reference().Value {
// This is our network
return net, nil
}
}
}
return nil, fmt.Errorf("could not find a matching %q on host ID %q", name, hs.Reference().Value)
} | |
c170286 |
licenseKey := key.(string)
if !isKeyPresent(licenseKey, manager) {
return ErrNoSuchKeyFound
}
if d.HasChange("labels") {
labelMap := d.Get("labels").(map[string]interface{})
err := updateLabels(manager, licenseKey, labelMap)
if err != nil {
return err
}
}
}
return resourceVSphereLicenseRead(d, meta)
} | |
c170287 |
if info.LicenseKey == key {
return true
}
}
return false
} | |
c170288 | key,
LabelValue: val,
}
_, err := methods.UpdateLicenseLabel(ctx, m.Client(), &req)
return err
} | |
c170289 |
return errors.New(property.Value.(string))
}
}
return nil
} | |
c170290 | skipping", resourceVSphereComputeClusterIDString(d))
return nil
}
log.Printf("[DEBUG] %s: Applying any pending tags", resourceVSphereVAppContainerIDString(d))
return processTagDiff(tagsClient, d, va)
} | |
c170291 | return err
}
} else {
log.Printf("[DEBUG] %s: Tags unsupported on this connection, skipping tag read", resourceVSphereVAppContainerIDString(d))
}
return nil
} | |
c170292 | structure.GetBool(d, "mandatory"),
Name: d.Get("name").(string),
UserCreated: structure.BoolPtr(true),
},
AffineHostGroupName: d.Get("affinity_host_group_name").(string),
AntiAffineHostGroupName: d.Get("anti_affinity_host_group_name").(string),
VmGroupName: d.Get("vm_group_name").(string),
}
return obj, nil
} | |
c170293 | obj.Name,
"affinity_host_group_name": obj.AffineHostGroupName,
"anti_affinity_host_group_name": obj.AntiAffineHostGroupName,
"vm_group_name": obj.VmGroupName,
})
} | |
c170294 | os)
migrateFunc = migrateVSphereVirtualMachineStateV1
default:
// Migration is complete
log.Printf("[DEBUG] Migrating vsphere_virtual_machine state: completed v%d state: %#v", version, os)
return os, nil
}
if err := migrateFunc(os, meta); err != nil {
return nil, err
}
version++
log.Printf("[DEBUG] Migrating vsphere_virtual_machine state: new v%d state: %#v", version, os)
return resourceVSphereVirtualMachineMigrateState(version, os, meta)
} | |
c170295 | }
disk, ok := device.(*types.VirtualDisk)
if !ok {
// Not the device we are looking for
continue
}
backing, ok := disk.Backing.(*types.VirtualDiskFlatVer2BackingInfo)
if !ok {
// Someone has tampered with the VM to the point where we really should
// not mess with it. We can't account for all cases, but if someone has
// added something like an RDM disk or something else that is not
// VMDK-backed, we don't want to continue. We have never supported this.
return fmt.Errorf("disk device %s is not a VMDK-backed virtual disk and state import cannot continue", l.Name(disk))
}
is.Attributes[fmt.Sprintf("disk.%d.uuid", i)] = backing.Uuid
}
d := resourceVSphereVirtualMachine().Data(&terraform.InstanceState{})
log.Printf("[DEBUG] %s: Migration to V3 complete", resourceVSphereVirtualMachineIDString(d))
return nil
} | |
c170296 | &EnvironmentBrowser{
Common: object.NewCommon(c, ref),
}
} | |
c170297 |
if err != nil {
return nil, err
}
if res.Returnval == nil {
return nil, errors.New("no config options were found for the supplied criteria")
}
return object.VirtualDeviceList(res.Returnval.DefaultDevice), nil
} | |
c170298 |
for _, osd := range res.Returnval.GuestOSDescriptor {
if osd.Id == guest {
family := osd.Family
log.Printf("[DEBUG] OSFamily: family for %q is %q", guest, family)
return family, nil
}
}
return "", fmt.Errorf("could not find guest ID %q", guest)
} | |
c170299 | res, err := methods.QueryConfigOptionDescriptor(ctx, b.Client(), &req)
if err != nil {
return nil, err
}
return res.Returnval, nil
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.