本文整理汇总了Golang中github.com/vmware/vic/pkg/vsphere/session.Session.IsVSAN方法的典型用法代码示例。如果您正苦于以下问题:Golang Session.IsVSAN方法的具体用法?Golang Session.IsVSAN怎么用?Golang Session.IsVSAN使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/vmware/vic/pkg/vsphere/session.Session
的用法示例。
在下文中一共展示了Session.IsVSAN方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: NewVirtualMachineConfigSpec
// NewVirtualMachineConfigSpec returns a VirtualMachineConfigSpec
func NewVirtualMachineConfigSpec(ctx context.Context, session *session.Session, config *VirtualMachineConfigSpecConfig) (*VirtualMachineConfigSpec, error) {
defer trace.End(trace.Begin(config.ID))
log.Debugf("Adding metadata to the configspec: %+v", config.Metadata)
// TEMPORARY
// set VM name to prettyname-ID, to make it readable a little bit
// if prettyname-ID is longer than max vm name length, truncate pretty name, instead of UUID, to make it unique
nameMaxLen := maxVMNameLength - len(config.ID)
prettyName := config.Name
if len(prettyName) > nameMaxLen-1 {
prettyName = prettyName[:nameMaxLen-1]
}
fullName := fmt.Sprintf("%s-%s", prettyName, config.ID)
config.VMFullName = fullName
VMPathName := config.VMPathName
if !session.IsVSAN(ctx) {
// VMFS requires the full path to vmx or everything but the datastore is ignored
VMPathName = fmt.Sprintf("%s/%s/%s.vmx", config.VMPathName, config.VMFullName, config.ID)
}
s := &types.VirtualMachineConfigSpec{
Name: fullName,
Uuid: config.BiosUUID,
Files: &types.VirtualMachineFileInfo{
VmPathName: VMPathName,
},
NumCPUs: config.NumCPUs,
CpuHotAddEnabled: &config.VMForkEnabled, // this disables vNUMA when true
MemoryMB: config.MemoryMB,
MemoryHotAddEnabled: &config.VMForkEnabled,
ExtraConfig: []types.BaseOptionValue{
// lets us see the UUID for the containerfs disk (hidden from daemon)
&types.OptionValue{Key: "disk.EnableUUID", Value: "true"},
// needed to avoid the questions that occur when attaching multiple disks with the same uuid (bugzilla 1362918)
&types.OptionValue{Key: "answer.msg.disk.duplicateUUID", Value: "Yes"},
// needed to avoid the question that occur when opening a file backed serial port
&types.OptionValue{Key: "answer.msg.serial.file.open", Value: "Append"},
&types.OptionValue{Key: "sched.mem.lpage.maxSharedPages", Value: "256"},
// seems to be needed to avoid children hanging shortly after fork
&types.OptionValue{Key: "vmotion.checkpointSVGAPrimarySize", Value: "4194304"},
// trying this out - if it works then we need to determine if we can rely on serial0 being the correct index.
&types.OptionValue{Key: "serial0.hardwareFlowControl", Value: "TRUE"},
// https://enatai-jira.eng.vmware.com/browse/BON-257
// Hotadd memory above 3 GB not working
&types.OptionValue{Key: "memory.noHotAddOver4GB", Value: "FALSE"},
&types.OptionValue{Key: "memory.maxGrow", Value: "512"},
// http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=2030189
&types.OptionValue{Key: "tools.remindInstall", Value: "FALSE"},
&types.OptionValue{Key: "tools.upgrade.policy", Value: "manual"},
},
}
// encode the config as optionvalues
cfg := map[string]string{}
extraconfig.Encode(extraconfig.MapSink(cfg), config.Metadata)
metaCfg := vmomi.OptionValueFromMap(cfg)
// merge it with the sec
s.ExtraConfig = append(s.ExtraConfig, metaCfg...)
vmcs := &VirtualMachineConfigSpec{
Session: session,
VirtualMachineConfigSpec: s,
config: config,
}
log.Debugf("Virtual machine config spec created: %+v", vmcs)
return vmcs, nil
}
示例2: NewVirtualMachineConfigSpec
// NewVirtualMachineConfigSpec returns a VirtualMachineConfigSpec
func NewVirtualMachineConfigSpec(ctx context.Context, session *session.Session, config *VirtualMachineConfigSpecConfig) (*VirtualMachineConfigSpec, error) {
defer trace.End(trace.Begin(config.ID))
VMPathName := config.VMPathName
if !session.IsVSAN(ctx) {
// VMFS requires the full path to vmx or everything but the datastore is ignored
VMPathName = fmt.Sprintf("%s/%s/%[2]s.vmx", config.VMPathName, config.ID)
}
log.Debugf("Adding metadata to the configspec: %+v", config.Metadata)
// TEMPORARY
s := &types.VirtualMachineConfigSpec{
Name: config.ID,
Files: &types.VirtualMachineFileInfo{
VmPathName: VMPathName,
},
NumCPUs: config.NumCPUs,
CpuHotAddEnabled: &config.VMForkEnabled, // this disables vNUMA when true
MemoryMB: config.MemoryMB,
MemoryHotAddEnabled: &config.VMForkEnabled,
// needed to cause the disk uuid to propogate into linux for presentation via /dev/disk/by-id/
ExtraConfig: []types.BaseOptionValue{
// lets us see the UUID for the containerfs disk (hidden from daemon)
&types.OptionValue{Key: "disk.EnableUUID", Value: "true"},
// needed to avoid the questions that occur when attaching multiple disks with the same uuid (bugzilla 1362918)
&types.OptionValue{Key: "answer.msg.disk.duplicateUUID", Value: "Yes"},
&types.OptionValue{Key: "answer.msg.serial.file.open", Value: "Replace"},
&types.OptionValue{Key: "sched.mem.lpage.maxSharedPages", Value: "256"},
// seems to be needed to avoid children hanging shortly after fork
&types.OptionValue{Key: "vmotion.checkpointSVGAPrimarySize", Value: "4194304"},
// trying this out - if it works then we need to determine if we can rely on serial0 being the correct index.
&types.OptionValue{Key: "serial0.hardwareFlowControl", Value: "TRUE"},
// https://enatai-jira.eng.vmware.com/browse/BON-257
&types.OptionValue{Key: "memory.noHotAddOver4GB", Value: "FALSE"},
&types.OptionValue{Key: "memory.maxGrow", Value: "512"},
// http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=2030189
&types.OptionValue{Key: "tools.remindInstall", Value: "FALSE"},
&types.OptionValue{Key: "tools.upgrade.policy", Value: "manual"},
},
}
// encode the config as optionvalues
cfg := map[string]string{}
extraconfig.Encode(extraconfig.MapSink(cfg), config.Metadata)
metaCfg := extraconfig.OptionValueFromMap(cfg)
// merge it with the sec
s.ExtraConfig = append(s.ExtraConfig, metaCfg...)
return &VirtualMachineConfigSpec{
Session: session,
VirtualMachineConfigSpec: s,
config: config,
}, nil
}