本文整理匯總了Golang中github.com/hyperhq/runv/lib/glog.V函數的典型用法代碼示例。如果您正苦於以下問題:Golang V函數的具體用法?Golang V怎麽用?Golang V使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了V函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: AddPod
func (daemon *Daemon) AddPod(pod *Pod, podArgs string) (err error) {
// store the UserPod into the db
if err = daemon.WritePodToDB(pod.id, []byte(podArgs)); err != nil {
glog.V(1).Info("Found an error while saveing the POD file")
return
}
defer func() {
if err != nil {
daemon.DeletePodFromDB(pod.id)
}
}()
daemon.PodList.Put(pod)
defer func() {
if err != nil {
daemon.RemovePod(pod.id)
}
}()
if err = daemon.WritePodAndContainers(pod.id); err != nil {
glog.V(1).Info("Found an error while saveing the Containers info")
return
}
pod.status.Handler.Data = daemon
return nil
}
示例2: loginV2
// loginV2 tries to login to the v2 registry server. The given registry endpoint has been
// pinged or setup with a list of authorization challenges. Each of these challenges are
// tried until one of them succeeds. Currently supported challenge schemes are:
// HTTP Basic Authorization
// Token Authorization with a separate token issuing server
// NOTE: the v2 logic does not attempt to create a user account if one doesn't exist. For
// now, users should create their account through other means like directly from a web page
// served by the v2 registry service provider. Whether this will be supported in the future
// is to be determined.
func loginV2(authConfig *cliconfig.AuthConfig, registryEndpoint *Endpoint) (string, error) {
glog.V(1).Infof("attempting v2 login to registry endpoint %s", registryEndpoint)
var (
err error
allErrors []error
)
for _, challenge := range registryEndpoint.AuthChallenges {
glog.V(1).Infof("trying %q auth challenge with params %s", challenge.Scheme, challenge.Parameters)
switch strings.ToLower(challenge.Scheme) {
case "basic":
err = tryV2BasicAuthLogin(authConfig, challenge.Parameters, registryEndpoint)
case "bearer":
err = tryV2TokenAuthLogin(authConfig, challenge.Parameters, registryEndpoint)
default:
// Unsupported challenge types are explicitly skipped.
err = fmt.Errorf("unsupported auth scheme: %q", challenge.Scheme)
}
if err == nil {
return "Login Succeeded", nil
}
glog.V(1).Infof("error trying auth challenge %q: %s", challenge.Scheme, err)
allErrors = append(allErrors, err)
}
return "", fmt.Errorf("no successful auth challenge for %s - errors: %s", registryEndpoint, allErrors)
}
示例3: GetPodByContainerIdOrName
func (daemon *Daemon) GetPodByContainerIdOrName(name string) (pod *Pod, idx int, err error) {
daemon.PodList.RLock()
glog.V(2).Infof("lock read of PodList")
defer glog.V(2).Infof("unlock read of PodList")
defer daemon.PodList.RUnlock()
err = nil
wslash := name
if name[0] != '/' {
wslash = "/" + name
}
var c *hypervisor.Container
pod = daemon.PodList.Find(func(p *Pod) bool {
for idx, c = range p.status.Containers {
if c.Name == wslash || c.Id == name {
return true
}
}
return false
})
if pod == nil {
err = fmt.Errorf("cannot found container %s", name)
return
}
return
}
示例4: AssociateAllVms
// This function will only be invoked during daemon start
func (daemon *Daemon) AssociateAllVms() error {
for _, mypod := range daemon.PodList {
if mypod.Vm == "" {
continue
}
podData, err := daemon.GetPodByName(mypod.Id)
if err != nil {
continue
}
userPod, err := pod.ProcessPodBytes(podData)
if err != nil {
continue
}
glog.V(1).Infof("Associate the POD(%s) with VM(%s)", mypod.Id, mypod.Vm)
vmData, err := daemon.GetVmData(mypod.Vm)
if err != nil {
continue
}
glog.V(1).Infof("The data for vm(%s) is %v", mypod.Vm, vmData)
vm := daemon.NewVm(mypod.Vm, userPod.Resource.Vcpu, userPod.Resource.Memory, false, types.VM_KEEP_NONE)
err = vm.AssociateVm(mypod, vmData)
if err != nil {
continue
}
daemon.AddVm(vm)
}
return nil
}
示例5: verifyTrustedKeys
// verifyTrustedKeys checks the keys provided against the trust store,
// ensuring that the provided keys are trusted for the namespace. The keys
// provided from this method must come from the signatures provided as part of
// the manifest JWS package, obtained from unpackSignedManifest or libtrust.
func (s *TagStore) verifyTrustedKeys(namespace string, keys []libtrust.PublicKey) (verified bool, err error) {
if namespace[0] != '/' {
namespace = "/" + namespace
}
for _, key := range keys {
b, err := key.MarshalJSON()
if err != nil {
return false, fmt.Errorf("error marshalling public key: %s", err)
}
// Check key has read/write permission (0x03)
v, err := s.trustService.CheckKey(namespace, b, 0x03)
if err != nil {
vErr, ok := err.(trust.NotVerifiedError)
if !ok {
return false, fmt.Errorf("error running key check: %s", err)
}
glog.V(1).Infof("Key check result: %v", vErr)
}
verified = v
}
if verified {
glog.V(1).Infof("Key check result: verified")
}
return
}
示例6: validateEndpoint
func validateEndpoint(endpoint *Endpoint) error {
glog.V(1).Infof("pinging registry endpoint %s", endpoint)
// Try HTTPS ping to registry
endpoint.URL.Scheme = "https"
if _, err := endpoint.Ping(); err != nil {
if endpoint.IsSecure {
// If registry is secure and HTTPS failed, show user the error and tell them about `--insecure-registry`
// in case that's what they need. DO NOT accept unknown CA certificates, and DO NOT fallback to HTTP.
return fmt.Errorf("invalid registry endpoint %s: %v. If this private registry supports only HTTP or HTTPS with an unknown CA certificate, please add `--insecure-registry %s` to the daemon's arguments. In the case of HTTPS, if you have access to the registry's CA certificate, no need for the flag; simply place the CA certificate at /etc/docker/certs.d/%s/ca.crt", endpoint, err, endpoint.URL.Host, endpoint.URL.Host)
}
// If registry is insecure and HTTPS failed, fallback to HTTP.
glog.V(1).Infof("Error from registry %q marked as insecure: %v. Insecurely falling back to HTTP", endpoint, err)
endpoint.URL.Scheme = "http"
var err2 error
if _, err2 = endpoint.Ping(); err2 == nil {
return nil
}
return fmt.Errorf("invalid registry endpoint %q. HTTPS attempt: %v. HTTP attempt: %v", endpoint, err, err2)
}
return nil
}
示例7: CmdPodRm
func (daemon *Daemon) CmdPodRm(job *engine.Job) (err error) {
var (
podId = job.Args[0]
code = 0
cause = ""
)
daemon.PodsMutex.Lock()
glog.V(2).Infof("lock PodList")
defer glog.V(2).Infof("unlock PodList")
defer daemon.PodsMutex.Unlock()
code, cause, err = daemon.CleanPod(podId)
if err != nil {
return err
}
// Prepare the vm status to client
v := &engine.Env{}
v.Set("ID", podId)
v.SetInt("Code", code)
v.Set("Cause", cause)
if _, err = v.WriteTo(job.Stdout); err != nil {
return err
}
return nil
}
示例8: CmdPodStop
func (daemon *Daemon) CmdPodStop(job *engine.Job) error {
if len(job.Args) == 0 {
return fmt.Errorf("Can not execute 'stop' command without any pod name!")
}
podId := job.Args[0]
stopVm := job.Args[1]
daemon.PodsMutex.Lock()
glog.V(2).Infof("lock PodList")
defer glog.V(2).Infof("unlock PodList")
defer daemon.PodsMutex.Unlock()
code, cause, err := daemon.StopPod(podId, stopVm)
if err != nil {
return err
}
// Prepare the VM status to client
v := &engine.Env{}
v.Set("ID", podId)
v.SetInt("Code", code)
v.Set("Cause", cause)
if _, err := v.WriteTo(job.Stdout); err != nil {
return err
}
return nil
}
示例9: SendCmdPull
func (cli Docker) SendCmdPull(image string, imagePullConfig *graph.ImagePullConfig) ([]byte, int, error) {
// We need to create a container via an image object. If the image
// is not stored locally, so we need to pull the image from the Docker HUB.
// Get a Repository name and tag name from the argument, but be careful
// with the Repository name with a port number. For example:
// localdomain:5000/samba/hipache:latest
repository, tag := parsers.ParseRepositoryTag(image)
if err := registry.ValidateRepositoryName(repository); err != nil {
return nil, -1, err
}
if tag == "" {
tag = "latest"
}
if len(tag) > 0 {
if err := tags.ValidateTagName(tag); err != nil {
return nil, -1, err
}
}
glog.V(3).Infof("The Repository is %s, and the tag is %s\n", repository, tag)
glog.V(3).Info("pull the image from the repository!\n")
err := cli.daemon.Repositories().Pull(repository, tag, imagePullConfig)
if err != nil {
return nil, -1, err
}
return nil, 200, nil
}
示例10: CmdPodCreate
func (daemon *Daemon) CmdPodCreate(job *engine.Job) error {
// we can only support 1024 Pods
if daemon.GetRunningPodNum() >= 1024 {
return fmt.Errorf("Pod full, the maximum Pod is 1024!")
}
podArgs := job.Args[0]
autoRemove := false
if job.Args[1] == "yes" || job.Args[1] == "true" {
autoRemove = true
}
podId := fmt.Sprintf("pod-%s", pod.RandStr(10, "alpha"))
daemon.PodList.Lock()
glog.V(2).Infof("lock PodList")
defer glog.V(2).Infof("unlock PodList")
defer daemon.PodList.Unlock()
err := daemon.CreatePod(podId, podArgs, autoRemove)
if err != nil {
return err
}
// Prepare the VM status to client
v := &engine.Env{}
v.Set("ID", podId)
v.SetInt("Code", 0)
v.Set("Cause", "")
if _, err := v.WriteTo(job.Stdout); err != nil {
return err
}
return nil
}
示例11: watchDog
func watchDog(qc *QemuContext, hub chan hypervisor.VmEvent) {
wdt := qc.wdt
for {
msg, ok := <-wdt
if ok {
switch msg {
case "quit":
glog.V(1).Info("quit watch dog.")
return
case "kill":
success := false
if qc.process != nil {
glog.V(0).Infof("kill Qemu... %d", qc.process.Pid)
if err := qc.process.Kill(); err == nil {
success = true
}
} else {
glog.Warning("no process to be killed")
}
hub <- &hypervisor.VmKilledEvent{Success: success}
return
}
} else {
glog.V(1).Info("chan closed, quit watch dog.")
break
}
}
}
示例12: waitConsoleOutput
func waitConsoleOutput(ctx *VmContext) {
conn, err := UnixSocketConnect(ctx.ConsoleSockName)
if err != nil {
glog.Error("failed to connected to ", ctx.ConsoleSockName, " ", err.Error())
return
}
glog.V(1).Info("connected to ", ctx.ConsoleSockName)
tc, err := telnet.NewConn(conn)
if err != nil {
glog.Error("fail to init telnet connection to ", ctx.ConsoleSockName, ": ", err.Error())
return
}
glog.V(1).Infof("connected %s as telnet mode.", ctx.ConsoleSockName)
cout := make(chan string, 128)
go TtyLiner(tc, cout)
for {
line, ok := <-cout
if ok {
glog.V(1).Info("[console] ", line)
} else {
glog.Info("console output end")
break
}
}
}
示例13: ApplyDiff
func (d *Driver) ApplyDiff(id, parent string, diff archive.ArchiveReader) (size int64, err error) {
// Mount the root filesystem so we can apply the diff/layer.
layerFs, err := d.Get(id, "")
if err != nil {
return 0, err
}
defer d.Put(id)
start := time.Now().UTC()
glog.V(1).Info("Start untar layer")
if size, err = chrootarchive.ApplyLayer(layerFs, diff); err != nil {
return 0, err
}
glog.V(1).Infof("Untar time: %vs", time.Now().UTC().Sub(start).Seconds())
root := path.Join(utils.HYPER_ROOT, "vbox")
idDisk := fmt.Sprintf("%s/images/%s.vdi", root, id)
if _, err = os.Stat(idDisk); err != nil {
return 0, err
}
if err = d.VmMountLayer(id); err != nil {
return 0, err
}
// XXX should remove the image/container's directory
return size, err
}
示例14: AssociateVm
// This function will only be invoked during daemon start
func (vm *Vm) AssociateVm(mypod *Pod, data []byte) error {
glog.V(1).Infof("Associate the POD(%s) with VM(%s)", mypod.Id, mypod.Vm)
var (
PodEvent = make(chan VmEvent, 128)
Status = make(chan *types.VmResponse, 128)
subStatus = make(chan *types.VmResponse, 128)
)
go VmAssociate(mypod.Vm, PodEvent, Status, mypod.Wg, data)
go vm.handlePodEvent(mypod)
ass := <-Status
if ass.Code != types.E_OK {
glog.Errorf("cannot associate with vm: %s, error status %d (%s)", mypod.Vm, ass.Code, ass.Cause)
return errors.New("load vm status failed")
}
if err := vm.SetVmChan(PodEvent, Status, subStatus); err != nil {
glog.V(1).Infof("SetVmChan error: %s", err.Error())
return err
}
mypod.Status = types.S_POD_RUNNING
mypod.SetContainerStatus(types.S_POD_RUNNING)
vm.Status = types.S_VM_ASSOCIATED
vm.Pod = mypod
return nil
}
示例15: Kill
func (vm *Vm) Kill() (int, string, error) {
PodEvent, Status, subStatus, err := vm.GetVmChan()
if err != nil {
return -1, "", err
}
var Response *types.VmResponse
shutdownPodEvent := &ShutdownCommand{Wait: false}
PodEvent.(chan VmEvent) <- shutdownPodEvent
// wait for the VM response
for {
stop := 0
select {
case Response = <-Status.(chan *types.VmResponse):
glog.V(1).Infof("Got response: %d: %s", Response.Code, Response.Cause)
if Response.Code == types.E_VM_SHUTDOWN {
stop = 1
}
case Response = <-subStatus.(chan *types.VmResponse):
glog.V(1).Infof("Got response: %d: %s", Response.Code, Response.Cause)
if Response.Code == types.E_VM_SHUTDOWN {
stop = 1
}
}
if stop == 1 {
break
}
}
close(Status.(chan *types.VmResponse))
close(subStatus.(chan *types.VmResponse))
return Response.Code, Response.Cause, nil
}