本文整理匯總了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)
}
//.........這裏部分代碼省略.........