本文整理汇总了Golang中github.com/vmware/vic/lib/config.VirtualContainerHostConfigSpec.AddComponent方法的典型用法代码示例。如果您正苦于以下问题:Golang VirtualContainerHostConfigSpec.AddComponent方法的具体用法?Golang VirtualContainerHostConfigSpec.AddComponent怎么用?Golang VirtualContainerHostConfigSpec.AddComponent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/vmware/vic/lib/config.VirtualContainerHostConfigSpec
的用法示例。
在下文中一共展示了VirtualContainerHostConfigSpec.AddComponent方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: createAppliance
func (d *Dispatcher) createAppliance(conf *config.VirtualContainerHostConfigSpec, settings *data.InstallerData) error {
defer trace.End(trace.Begin(""))
log.Infof("Creating appliance on target")
spec, err := d.createApplianceSpec(conf, settings)
if err != nil {
log.Errorf("Unable to create appliance spec: %s", err)
return err
}
var info *types.TaskInfo
// create appliance VM
if d.isVC && d.vchVapp != nil {
info, err = tasks.WaitForResult(d.ctx, func(ctx context.Context) (tasks.ResultWaiter, error) {
return d.vchVapp.CreateChildVM_Task(ctx, *spec, d.session.Host)
})
} else {
// if vapp is not created, fall back to create VM under default resource pool
info, err = tasks.WaitForResult(d.ctx, func(ctx context.Context) (tasks.ResultWaiter, error) {
return d.session.Folders(ctx).VmFolder.CreateVM(ctx, *spec, d.vchPool, d.session.Host)
})
}
if err != nil {
log.Errorf("Unable to create appliance VM: %s", err)
return err
}
if info.Error != nil || info.State != types.TaskInfoStateSuccess {
log.Errorf("Create appliance reported: %s", info.Error.LocalizedMessage)
}
// get VM reference and save it
moref := info.Result.(types.ManagedObjectReference)
conf.SetMoref(&moref)
obj, err := d.session.Finder.ObjectReference(d.ctx, moref)
if err != nil {
log.Errorf("Failed to reacquire reference to appliance VM after creation: %s", err)
return err
}
gvm, ok := obj.(*object.VirtualMachine)
if !ok {
return fmt.Errorf("Required reference after appliance creation was not for a VM: %T", obj)
}
vm2 := vm.NewVirtualMachineFromVM(d.ctx, d.session, gvm)
// update the displayname to the actual folder name used
if d.vmPathName, err = vm2.FolderName(d.ctx); err != nil {
log.Errorf("Failed to get canonical name for appliance: %s", err)
return err
}
log.Debugf("vm folder name: %q", d.vmPathName)
log.Debugf("vm inventory path: %q", vm2.InventoryPath)
// create an extension to register the appliance as
if err = d.GenerateExtensionName(conf, vm2); err != nil {
return errors.Errorf("Could not generate extension name during appliance creation due to error: %s", err)
}
settings.Extension = types.Extension{
Description: &types.Description{
Label: "VIC",
Summary: "vSphere Integrated Containers Virtual Container Host",
},
Company: "VMware, Inc.",
Version: "0.0",
Key: conf.ExtensionName,
}
conf.AddComponent("vicadmin", &executor.SessionConfig{
User: "vicadmin",
Group: "vicadmin",
Cmd: executor.Cmd{
Path: "/sbin/vicadmin",
Args: []string{
"/sbin/vicadmin",
"-docker-host=unix:///var/run/docker.sock",
// FIXME: hack during config migration
"-insecure",
"-ds=" + conf.ImageStores[0].Host,
"-cluster=" + settings.ClusterPath,
"-pool=" + settings.ResourcePoolPath,
"-vm-path=" + vm2.InventoryPath,
},
Env: []string{
"PATH=/sbin:/bin",
},
Dir: "/home/vicadmin",
},
Restart: true,
},
)
if conf.HostCertificate != nil {
d.VICAdminProto = "https"
d.DockerPort = fmt.Sprintf("%d", opts.DefaultTLSHTTPPort)
} else {
d.VICAdminProto = "http"
d.DockerPort = fmt.Sprintf("%d", opts.DefaultHTTPPort)
}
//.........这里部分代码省略.........