id stringlengths 2 7 | text stringlengths 17 51.2k | title stringclasses 1 value |
|---|---|---|
c169900 |
defer cancel()
obj, err := finder.ObjectReference(ctx, ref)
if err != nil {
return nil, err
}
log.Printf("[DEBUG] vApp container found: %s", obj.Reference().Value)
return obj.(*object.VirtualApp), nil
} | |
c169901 | != nil {
return false
}
return true
} | |
c169902 | := context.WithTimeout(context.Background(), provider.DefaultAPITimeout)
defer cancel()
nva, err := rp.CreateVApp(ctx, name, *resSpec, *vSpec, folder)
if err != nil {
return nil, err
}
return nva, nil
} | |
c169903 | cancel := context.WithTimeout(context.Background(), provider.DefaultAPITimeout)
defer cancel()
return vc.UpdateConfig(ctx, spec)
} | |
c169904 | id = "<new resource>"
}
return fmt.Sprintf("%s (ID = %s)", name, id)
} | |
c169905 | if o, ok := v.(string); ok {
d = append(d, o)
}
}
return d
} | |
c169906 | := range s {
d = append(d, v)
}
return d
} | |
c169907 | d []types.ManagedObjectReference
for _, v := range s {
d = append(d, types.ManagedObjectReference{
Type: t,
Value: v.(string),
})
}
return d
} | |
c169908 |
if err != nil {
return ""
}
return strconv.FormatBool(b)
} | |
c169909 | return
}
if _, err := strconv.ParseBool(v); err != nil {
es = append(es, err)
}
return
}
} | |
c169910 |
Value: BoolPtr(b),
}
return bp
} | |
c169911 | {
return BoolPolicy(v.(bool))
}
return nil
} | |
c169912 | return nil
}
err := d.Set(key, val.Value)
return err
} | |
c169913 | &types.StringPolicy{
Value: s,
}
return sp
} | |
c169914 | {
return StringPolicy(v.(string))
}
return nil
} | |
c169915 | return nil
}
err := d.Set(key, val.Value)
return err
} | |
c169916 | int32:
lp.Value = int64(v)
case uint:
lp.Value = int64(v)
case uint8:
lp.Value = int64(v)
case uint16:
lp.Value = int64(v)
case uint32:
lp.Value = int64(v)
case int64:
lp.Value = v
default:
panic(fmt.Errorf("non-convertible type %T for value", n))
}
return lp
} | |
c169917 | {
v, e := d.GetOkExists(key)
if e {
return LongPolicy(v)
}
return nil
} | |
c169918 | return nil
}
err := d.Set(key, val.Value)
return err
} | |
c169919 |
} else {
fv = reflect.ValueOf(v).Elem().Field(i)
}
ft := t.Field(i).Type
fz := reflect.Zero(ft)
switch ft.Kind() {
case reflect.Map, reflect.Slice:
if fv.Len() > 0 {
return false
}
default:
if fz.Interface() != fv.Interface() {
return false
}
}
}
return true
} | |
c169920 |
return v
}
if reflect.ValueOf(v) == reflect.Zero(reflect.TypeOf(v)) {
// All zero-value pointers are nil
return nil
}
return reflect.ValueOf(v).Elem().Interface()
} | |
c169921 | return s[i].Value < s[j].Value
} | |
c169922 | s[i], s[j] = s[j], s[i]
} | |
c169923 | context.WithTimeout(context.Background(), defaultAPITimeout)
defer cancel()
return hs.ConfigManager().DatastoreSystem(ctx)
} | |
c169924 | err != nil {
return nil, fmt.Errorf("cannot query available disks: %s", err)
}
var disk *types.HostScsiDisk
for _, d := range disks {
if d.CanonicalName == name {
disk = &d
break
}
}
if disk == nil {
return nil, fmt.Errorf("%s does not seem to be a disk available for VMFS", name)
}
return disk, nil
} | |
c169925 |
if _, ok := o.Info.(*types.VmfsDatastoreAllExtentOption); ok {
option = &o
break
}
}
if option == nil {
return nil, fmt.Errorf("device %q is not available as a new whole-disk device for datastore", name)
}
return option.Spec.(*types.VmfsDatastoreCreateSpec), nil
} | |
c169926 |
var option *types.VmfsDatastoreOption
for _, o := range options {
if _, ok := o.Info.(*types.VmfsDatastoreAllExtentOption); ok {
option = &o
break
}
}
if option == nil {
return nil, fmt.Errorf("device %q cannot be used as a new whole-disk device for datastore %q", name, props.Summary.Name)
}
return option.Spec.(*types.VmfsDatastoreExtendSpec), nil
} | |
c169927 | context.WithTimeout(context.Background(), defaultAPITimeout)
defer cancel()
return s.Remove(ctx, ds)
} | |
c169928 | s.Reference(),
Datastore: ds.Reference(),
DevicePath: devicePath,
SuppressExpandCandidates: &suppressExpandCandidates,
}
res, err := methods.QueryVmfsDatastoreExtendOptions(ctx, s.Client(), &req)
if err != nil {
return nil, err
}
return res.Returnval, nil
} | |
c169929 | spec,
}
res, err := methods.ExtendVmfsDatastore(ctx, s.Client(), &req)
if err != nil {
return nil, err
}
return object.NewDatastore(s.Client(), res.Returnval), nil
} | |
c169930 | s["ha_admission_control_resource_percentage_cpu"].Default,
"ha_admission_control_resource_percentage_memory": s["ha_admission_control_resource_percentage_memory"].Default,
"ha_admission_control_slot_policy_explicit_cpu": s["ha_admission_control_slot_policy_explicit_cpu"].Default,
"ha_admission_control_slot_policy_explicit_memory": s["ha_admission_control_slot_policy_explicit_memory"].Default,
"host_cluster_exit_timeout": s["host_cluster_exit_timeout"].Default,
})
} | |
c169931 |
// create the datastore cluster.
f, err := folder.FromPath(client, d.Get("folder").(string), folder.VSphereFolderTypeHost, dc)
if err != nil {
return nil, fmt.Errorf("cannot locate folder: %s", err)
}
// Create the cluster. We use an empty config spec so that we can move the
// necessary hosts into the cluster *before* we send the full configuration,
// ensuring that any host-dependent configuration does not break.
cluster, err := clustercomputeresource.Create(f, d.Get("name").(string), types.ClusterConfigSpecEx{})
if err != nil {
return nil, fmt.Errorf("error creating cluster: %s", err)
}
// Set the ID now before proceeding any further. Any other operation past
// this point is recoverable.
d.SetId(cluster.Reference().Value)
return cluster, nil
} | |
c169932 | this connection, skipping", resourceVSphereComputeClusterIDString(d))
return nil
}
log.Printf("[DEBUG] %s: Applying any pending tags", resourceVSphereComputeClusterIDString(d))
return processTagDiff(tagsClient, d, cluster)
} | |
c169933 | return err
}
} else {
log.Printf("[DEBUG] %s: Tags unsupported on this connection, skipping tag read", resourceVSphereComputeClusterIDString(d))
}
return nil
} | |
c169934 | customattribute.GetDiffProcessorIfAttributesDefined(client, d)
if err != nil {
return err
}
if attrsProcessor == nil {
log.Printf("[DEBUG] %s: Custom attributes unsupported on this connection, skipping", resourceVSphereComputeClusterIDString(d))
return nil
}
log.Printf("[DEBUG] %s: Applying any pending custom attributes", resourceVSphereComputeClusterIDString(d))
return attrsProcessor.ProcessDiff(cluster)
} | |
c169935 |
return err
}
customattribute.ReadFromResource(client, props.Entity(), d)
} else {
log.Printf("[DEBUG] %s: Custom attributes unsupported on this connection, skipping", resourceVSphereComputeClusterIDString(d))
}
return nil
} | |
c169936 | := resourceVSphereComputeClusterClient(meta)
if err != nil {
return nil, err
}
return clustercomputeresource.FromID(client, d.Id())
} | |
c169937 | }
log.Printf("[DEBUG] Looking for cluster %q in datacenter %q", path, dc.InventoryPath)
} else {
log.Printf("[DEBUG] Fetching cluster at path %q", path)
}
return clustercomputeresource.FromPath(client, path, dc)
} | |
c169938 | err != nil {
return err
}
p, err := folder.RootPathParticleHost.SplitDatacenter(cluster.InventoryPath)
if err != nil {
return fmt.Errorf("error parsing datacenter path from cluster: %s", err)
}
dc, err := getDatacenter(client, p)
if err != nil {
return fmt.Errorf("error fetching datacenter for cluster: %s", err)
}
return d.Set("datacenter_id", dc.Reference().Value)
} | |
c169939 | err := folder.RootPathParticleHost.SplitRelativeFolder(cluster.InventoryPath)
if err != nil {
return fmt.Errorf("error parsing cluster path %q: %s", cluster.InventoryPath, err)
}
if err := d.Set("folder", folder.NormalizePath(f)); err != nil {
return fmt.Errorf("error saving folder: %s", err)
}
return nil
} | |
c169940 | so that we have the new inventory path for logging and
// other things
cluster, err = resourceVSphereComputeClusterGetCluster(d, meta)
if err != nil {
return nil, fmt.Errorf("error refreshing cluster after name change: %s", err)
}
log.Printf(
"[DEBUG] %s: Name changed, new path = %q",
resourceVSphereComputeClusterIDString(d),
cluster.InventoryPath,
)
}
return cluster, nil
} | |
c169941 | = clustercomputeresource.MoveToFolder(client, cluster, f); err != nil {
return nil, fmt.Errorf("could not move cluster to folder %q: %s", f, err)
}
changed = true
}
if changed {
// Update the cluster so that we have the new inventory path for logging and
// other things
cluster, err = resourceVSphereComputeClusterGetCluster(d, meta)
if err != nil {
return nil, fmt.Errorf("error refreshing cluster after folder change: %s", err)
}
log.Printf(
"[DEBUG] %s: Folder changed, new path = %q",
resourceVSphereComputeClusterIDString(d),
cluster.InventoryPath,
)
}
return cluster, nil
} | |
c169942 | contents: %s", err)
}
if ne {
return fmt.Errorf(
"cluster %q still has hosts or virtual machines. Please move or remove all items before deleting",
cluster.InventoryPath,
)
}
return nil
} | |
c169943 | deletion", resourceVSphereComputeClusterIDString(d))
if err := clustercomputeresource.Delete(cluster); err != nil {
return err
}
return nil
} | |
c169944 | // Save the root resource pool ID so that it can be passed on to other
// resources without having to resort to the data source.
if err := d.Set("resource_pool_id", props.ResourcePool.Value); err != nil {
return err
}
return flattenClusterConfigSpecEx(d, props.ConfigurationEx.(*types.ClusterConfigInfoEx), version)
} | |
c169945 | obj.InfraUpdateHaConfig = expandClusterInfraUpdateHaConfigInfo(d)
obj.Orchestration = expandClusterOrchestrationInfo(d)
obj.ProactiveDrsConfig = expandClusterProactiveDrsConfigInfo(d)
}
return obj
} | |
c169946 | version.Newer(viapi.VSphereVersion{Product: version.Product, Major: 6, Minor: 5}) {
if err := flattenClusterOrchestrationInfo(d, obj.Orchestration); err != nil {
return err
}
}
if version.Newer(viapi.VSphereVersion{Product: version.Product, Major: 6, Minor: 5}) {
return flattenClusterProactiveDrsConfigInfo(d, obj.ProactiveDrsConfig)
}
return nil
} | |
c169947 |
policy := d.Get("ha_admission_control_policy").(string)
if policy != clusterAdmissionControlTypeDisabled {
obj.AdmissionControlEnabled = structure.BoolPtr(true)
} else {
obj.AdmissionControlEnabled = structure.BoolPtr(false)
}
obj.AdmissionControlPolicy = expandBaseClusterDasAdmissionControlPolicy(d, policy, version)
if version.Newer(viapi.VSphereVersion{Product: version.Product, Major: 6}) {
obj.VmComponentProtecting = d.Get("ha_vm_component_protection").(string)
}
return obj
} | |
c169948 | := flattenClusterDasVMSettings(d, obj.DefaultVmSettings, version); err != nil {
return err
}
if err := flattenResourceVSphereComputeClusterDasAdvancedOptions(d, obj.Option); err != nil {
return err
}
if version.Newer(viapi.VSphereVersion{Product: version.Product, Major: 6}) {
if err := d.Set("ha_vm_component_protection", obj.VmComponentProtecting); err != nil {
return err
}
}
// If AdmissionControlEnabled is false, AdmissionControlPolicy is still
// configured. Set ha_admission_control_policy to disabled before
// flattenBaseClusterDasAdmissionControlPolicy, so AdmissionControlEnabled
// can still be checked.
if *obj.AdmissionControlEnabled == false {
return d.Set("ha_admission_control_policy", clusterAdmissionControlTypeDisabled)
}
return flattenBaseClusterDasAdmissionControlPolicy(d, obj.AdmissionControlPolicy, version)
} | |
c169949 | case clusterAdmissionControlTypeDisabled:
return nil
}
if version.Newer(viapi.VSphereVersion{Product: version.Product, Major: 6, Minor: 5}) {
obj.GetClusterDasAdmissionControlPolicy().ResourceReductionToToleratePercent = int32(d.Get("ha_admission_control_host_failure_tolerance").(int))
}
return obj
} | |
c169950 |
case *types.ClusterFailoverLevelAdmissionControlPolicy:
if err := flattenClusterFailoverLevelAdmissionControlPolicy(d, t); err != nil {
return err
}
policy = clusterAdmissionControlTypeSlotPolicy
case *types.ClusterFailoverHostAdmissionControlPolicy:
if err := flattenClusterFailoverHostAdmissionControlPolicy(d, t, version); err != nil {
return err
}
policy = clusterAdmissionControlTypeFailoverHosts
default:
policy = clusterAdmissionControlTypeDisabled
}
return d.Set("ha_admission_control_policy", policy)
} | |
c169951 | version.Newer(viapi.VSphereVersion{Product: version.Product, Major: 6, Minor: 5}) {
obj.AutoComputePercentages = structure.GetBool(d, "ha_admission_control_resource_percentage_auto_compute")
obj.FailoverLevel = int32(d.Get("ha_admission_control_host_failure_tolerance").(int))
}
return obj
} | |
c169952 | return err
}
}
if version.Newer(viapi.VSphereVersion{Product: version.Product, Major: 6, Minor: 5}) {
return structure.SetBatch(d, map[string]interface{}{
"ha_admission_control_resource_percentage_auto_compute": obj.AutoComputePercentages,
"ha_admission_control_host_failure_tolerance": obj.FailoverLevel,
})
}
return nil
} | |
c169953 | }
if d.Get("ha_admission_control_slot_policy_use_explicit_size").(bool) {
obj.SlotPolicy = &types.ClusterFixedSizeSlotPolicy{
Cpu: int32(d.Get("ha_admission_control_resource_percentage_cpu").(int)),
Memory: int32(d.Get("ha_admission_control_resource_percentage_memory").(int)),
}
}
return obj
} | |
c169954 | structure.SetBatch(d, map[string]interface{}{
"ha_admission_control_resource_percentage_cpu": obj.SlotPolicy.(*types.ClusterFixedSizeSlotPolicy).Cpu,
"ha_admission_control_resource_percentage_memory": obj.SlotPolicy.(*types.ClusterFixedSizeSlotPolicy).Memory,
})
}
return nil
} | |
c169955 |
d.Get("ha_admission_control_failover_host_system_ids").(*schema.Set).List(),
"HostSystem",
),
}
if version.Newer(viapi.VSphereVersion{Product: version.Product, Major: 6, Minor: 5}) {
obj.FailoverLevel = int32(d.Get("ha_admission_control_host_failure_tolerance").(int))
}
return obj
} | |
c169956 | nil {
return err
}
if version.Newer(viapi.VSphereVersion{Product: version.Product, Major: 6, Minor: 5}) {
return d.Set("ha_admission_control_host_failure_tolerance", obj.FailoverLevel)
}
return nil
} | |
c169957 | expandClusterVMComponentProtectionSettings(d)
}
if version.Newer(viapi.VSphereVersion{Product: version.Product, Major: 6, Minor: 5}) {
obj.RestartPriorityTimeout = int32(d.Get("ha_vm_restart_timeout").(int))
}
return obj
} | |
c169958 | version.Product, Major: 6}) {
if err := flattenClusterVMComponentProtectionSettings(d, obj.VmComponentProtectionSettings); err != nil {
return err
}
}
if version.Newer(viapi.VSphereVersion{Product: version.Product, Major: 6, Minor: 5}) {
return d.Set("ha_vm_restart_timeout", obj.RestartPriorityTimeout)
}
return nil
} | |
c169959 | effective. Note
// that this setting is not persisted to state or the vSphere backend and
// is actually a host operation, not a cluster operation. It's here to
// ensure that the settings specified here are otherwise effective. We may
// need to revisit this if we introduce more robust host management
// capabilities in the provider.
obj.EnableAPDTimeoutForHosts = structure.BoolPtr(true)
}
return obj
} | |
c169960 | "ha_datastore_apd_recovery_action": obj.VmReactionOnAPDCleared,
"ha_datastore_apd_response": obj.VmStorageProtectionForAPD,
"ha_datastore_pdl_response": obj.VmStorageProtectionForPDL,
"ha_datastore_apd_response_delay": obj.VmTerminateDelayForAPDSec,
})
} | |
c169961 |
MaxFailureWindow: int32(d.Get("ha_vm_maximum_failure_window").(int)),
MinUpTime: int32(d.Get("ha_vm_minimum_uptime").(int)),
VmMonitoring: d.Get("ha_vm_monitoring").(string),
}
return obj
} | |
c169962 | obj.MaxFailures,
"ha_vm_maximum_failure_window": obj.MaxFailureWindow,
"ha_vm_minimum_uptime": obj.MinUpTime,
"ha_vm_monitoring": obj.VmMonitoring,
})
} | |
c169963 | types.DpmBehavior(d.Get("dpm_automation_level").(string)),
Enabled: structure.GetBool(d, "dpm_enabled"),
HostPowerActionRate: int32(d.Get("dpm_threshold").(int)),
}
return obj
} | |
c169964 | map[string]interface{}{
"dpm_automation_level": obj.DefaultDpmBehavior,
"dpm_enabled": obj.Enabled,
"dpm_threshold": obj.HostPowerActionRate,
})
} | |
c169965 | structure.GetBool(d, "drs_enabled"),
EnableVmBehaviorOverrides: structure.GetBool(d, "drs_enable_vm_overrides"),
VmotionRate: int32(d.Get("drs_migration_threshold").(int)),
Option: expandResourceVSphereComputeClusterDrsAdvancedOptions(d),
}
return obj
} | |
c169966 | "drs_enable_vm_overrides": obj.EnableVmBehaviorOverrides,
"drs_migration_threshold": obj.VmotionRate,
})
if err != nil {
return err
}
return flattenResourceVSphereComputeClusterDrsAdvancedOptions(d, obj.Option)
} | |
c169967 |
m := d.Get("drs_advanced_options").(map[string]interface{})
for k, v := range m {
opts = append(opts, &types.OptionValue{
Key: k,
Value: types.AnyType(v),
})
}
return opts
} | |
c169968 | structure.GetBool(d, "proactive_ha_enabled"),
ModerateRemediation: d.Get("proactive_ha_moderate_remediation").(string),
Providers: structure.SliceInterfacesToStrings(d.Get("proactive_ha_provider_ids").(*schema.Set).List()),
SevereRemediation: d.Get("proactive_ha_severe_remediation").(string),
}
return obj
} | |
c169969 | obj.Enabled,
"proactive_ha_moderate_remediation": obj.ModerateRemediation,
"proactive_ha_provider_ids": obj.Providers,
"proactive_ha_severe_remediation": obj.SevereRemediation,
})
} | |
c169970 | PostReadyDelay: int32(d.Get("ha_vm_restart_additional_delay").(int)),
ReadyCondition: d.Get("ha_vm_dependency_restart_condition").(string),
},
}
return obj
} | |
c169971 | map[string]interface{}{
"ha_vm_restart_additional_delay": obj.DefaultVmReadiness.PostReadyDelay,
"ha_vm_dependency_restart_condition": obj.DefaultVmReadiness.ReadyCondition,
})
} | |
c169972 | {
obj := &types.ClusterProactiveDrsConfigInfo{
Enabled: structure.GetBool(d, "drs_enable_predictive_drs"),
}
return obj
} | |
c169973 | structure.SetBatch(d, map[string]interface{}{
"drs_enable_predictive_drs": obj.Enabled,
})
} | |
c169974 | err := pod.Properties(ctx, pod.Reference(), nil, &props); err != nil {
return nil, err
}
return &props, nil
} | |
c169975 | name))
ctx, cancel := context.WithTimeout(context.Background(), provider.DefaultAPITimeout)
defer cancel()
pod, err := f.CreateStoragePod(ctx, name)
if err != nil {
return nil, err
}
return pod, nil
} | |
c169976 | context.WithTimeout(context.Background(), provider.DefaultAPITimeout)
defer cancel()
task, err := mgr.ConfigureStorageDrsForPod(ctx, pod, spec, true)
if err != nil {
return err
}
return task.Wait(ctx)
} | |
c169977 |
ctx, cancel := context.WithTimeout(context.Background(), provider.DefaultAPITimeout)
defer cancel()
task, err := pod.Rename(ctx, name)
if err != nil {
return err
}
return task.Wait(ctx)
} | |
c169978 | := folder.DatastoreFolderFromObject(client, pod, relative)
if err != nil {
return err
}
return folder.MoveObjectTo(pod.Reference(), f)
} | |
c169979 | nil
}
return props.PodStorageDrsEntry.StorageDrsConfig.PodConfig.Enabled, nil
} | |
c169980 | If the parent resource pool is a vApp, we need to create the VM using the
// CreateChildVM vApp function instead of directly using SDRS recommendations.
if sps.ResourcePool != nil {
vc, err := vappcontainer.FromID(client, sps.ResourcePool.Reference().Value)
switch {
case viapi.IsManagedObjectNotFoundError(err):
// This isn't a vApp container, so continue with normal SDRS work flow.
case err == nil:
return createVAppVMFromSPS(client, placement, spec, sps, vc)
default:
return nil, err
}
}
return applySDRS(client, placement, provider.DefaultAPITimeout)
} | |
c169981 | Folder: types.NewReference(fo.Reference()),
Vm: types.NewReference(src.Reference()),
CloneName: name,
CloneSpec: &spec,
PodSelectionSpec: types.StorageDrsPodSelectionSpec{
StoragePod: types.NewReference(pod.Reference()),
},
Type: string(types.StoragePlacementSpecPlacementTypeClone),
}
return recommendAndApplySDRS(client, sps, time.Minute*time.Duration(timeout))
} | |
c169982 | machine %q through Storage DRS API, on datastore cluster %q",
vm.InventoryPath,
pod.Name(),
)
sps := types.StoragePlacementSpec{
Type: string(types.StoragePlacementSpecPlacementTypeReconfigure),
PodSelectionSpec: types.StorageDrsPodSelectionSpec{
InitialVmConfig: expandVMPodConfigForPlacement(spec.DeviceChange, pod),
},
Vm: types.NewReference(vm.Reference()),
ConfigSpec: &spec,
}
_, err = recommendAndApplySDRS(client, sps, provider.DefaultAPITimeout)
return err
} | |
c169983 | machine %q to datastore cluster %q",
vm.InventoryPath,
pod.Name(),
)
sps := types.StoragePlacementSpec{
Vm: types.NewReference(vm.Reference()),
PodSelectionSpec: types.StorageDrsPodSelectionSpec{
StoragePod: types.NewReference(pod.Reference()),
},
Priority: types.VirtualMachineMovePriorityDefaultPriority,
RelocateSpec: &spec,
Type: string(types.StoragePlacementSpecPlacementTypeRelocate),
}
_, err = recommendAndApplySDRS(client, sps, time.Minute*time.Duration(timeout))
return err
} | |
c169984 | := virtualDiskFromDeviceConfigSpecForPlacement(deviceConfigSpec); ok {
return true
}
}
return false
} | |
c169985 | getting properties for datastore %q: %s", ds.Name(), err)
}
if dprops.Parent == nil {
return false, nil
}
if *dprops.Parent != pod.Reference() {
return false, nil
}
return true, nil
} | |
c169986 | be provided")
}
c := &Config{
User: d.Get("user").(string),
Password: d.Get("password").(string),
InsecureFlag: d.Get("allow_unverified_ssl").(bool),
VSphereServer: server,
Debug: d.Get("client_debug").(bool),
DebugPathRun: d.Get("client_debug_path_run").(string),
DebugPath: d.Get("client_debug_path").(string),
Persist: d.Get("persist_session").(bool),
VimSessionPath: d.Get("vim_session_path").(string),
RestSessionPath: d.Get("rest_session_path").(string),
}
return c, nil
} | |
c169987 | connection.
log.Printf("[DEBUG] Connected endpoint does not support tags (%s)", viapi.ParseVersionFromClient(client.vimClient))
}
// Done, save sessions if we need to and return
if err := c.SaveVimClient(client.vimClient); err != nil {
return nil, fmt.Errorf("error persisting SOAP session to disk: %s", err)
}
if err := c.SaveRestClient(client.tagsClient); err != nil {
return nil, fmt.Errorf("error persisting REST session to disk: %s", err)
}
return client, nil
} | |
c169988 | _ = os.RemoveAll(r)
}
err := os.MkdirAll(r, 0700)
if err != nil {
log.Printf("[ERROR] Client debug setup failed: %v", err)
return err
}
p := debug.FileProvider{
Path: r,
}
debug.SetProvider(&p)
return nil
} | |
c169989 | fmt.Sprintf("%s#insecure=%t", u.String(), c.InsecureFlag)
name := fmt.Sprintf("%040x", sha1.Sum([]byte(key)))
return name, nil
} | |
c169990 | "", err
}
return filepath.Join(c.VimSessionPath, p), nil
} | |
c169991 | "", err
}
return filepath.Join(c.RestSessionPath, p), nil
} | |
c169992 | func() {
if err = f.Close(); err != nil {
log.Printf("[DEBUG] Error closing SOAP client session file %q: %s", p, err)
}
}()
err = json.NewEncoder(f).Encode(client.Client)
if err != nil {
return err
}
return nil
} | |
c169993 | nil {
return err
}
err = ioutil.WriteFile(p, []byte(client.SessionID()), 0600)
if err != nil {
return err
}
return nil
} | |
c169994 | return false, err
}
defer func() {
if err = f.Close(); err != nil {
log.Printf("[DEBUG] Error closing SOAP client session file %q: %s", p, err)
}
}()
dec := json.NewDecoder(f)
err = dec.Decode(client)
if err != nil {
return false, err
}
return true, nil
} | |
c169995 | != nil {
if os.IsNotExist(err) {
log.Printf("[DEBUG] REST client session data not found in %q", p)
return "", nil
}
return "", err
}
return string(id), nil
} | |
c169996 | fault := soap.ToSoapFault(err).VimFault()
// If the PropertyCollector is not found, the saved session for this URL is not valid
if _, ok := fault.(types.ManagedObjectNotFound); ok {
log.Println("[DEBUG] Cached SOAP client session missing property collector, new session necessary")
return nil, nil
}
}
return nil, err
}
// If the session is nil, the client is not authenticated
if u == nil {
log.Println("[DEBUG] Unauthenticated session, new session necessary")
return nil, nil
}
log.Println("[DEBUG] Cached SOAP client session loaded successfully")
return &govmomi.Client{
Client: client,
SessionManager: m,
}, nil
} | |
c169997 | log.Println("[DEBUG] No cached REST session data found or persistence not enabled, new session necessary")
return client, false, nil
}
if !client.Valid(ctx) {
log.Println("[DEBUG] Cached REST client session data not valid, new session necessary")
return client, false, nil
}
log.Println("[DEBUG] Cached REST client session loaded successfully")
return client, true, nil
} | |
c169998 | session from disk: %s", err)
}
if client == nil {
log.Printf("[DEBUG] Creating new SOAP API session on endpoint %s", c.VSphereServer)
client, err = govmomi.NewClient(ctx, u, c.InsecureFlag)
if err != nil {
return nil, fmt.Errorf("error setting up new vSphere SOAP client: %s", err)
}
log.Println("[DEBUG] SOAP API session creation successful")
}
return client, nil
} | |
c169999 | load vSphere REST session from disk: %s", err)
}
if !valid {
log.Printf("[DEBUG] Creating new CIS REST API session on endpoint %s", c.VSphereServer)
if err := client.Login(ctx); err != nil {
return nil, fmt.Errorf("Error connecting to CIS REST endpoint: %s", err)
}
log.Println("[DEBUG] CIS REST API session creation successful")
}
return client, nil
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.