// See also https://libvirt.org/html/libvirt-libvirt-network.html#virNetworkGetUUID
3620
func (n *Network) GetUUID() ([]byte, error) {
	var cUuid [C.VIR_UUID_BUFLEN](byte)
	cuidPtr := unsafe.Pointer(&cUuid)
	var err C.virError
	result := C.virNetworkGetUUIDWrapper(n.ptr, (*C.uchar)(cuidPtr), &err)
	if result != 0 {
		return []byte{}, makeError(&err)
	}
	return C.GoBytes(cuidPtr, C.VIR_UUID_BUFLEN), nil
}
1363424
func GetHookTaskOfWebhookByUUID(webhookID int64, uuid string) (*HookTask, error) {
	hookTask := &HookTask{
		HookID: webhookID,
		UUID:   uuid,
	}
	has, err := x.Get(hookTask)
	if err != nil {
		return nil, err
	} else if !has {
		return nil, errors.HookTaskNotExist{webhookID, uuid}
	}
	return hookTask, nil
}
624241
func NewUUID() UUID {
	uuid, err := NewUUIDv4()
	if err != nil {
		// Panic due to compatibility reasons.
		panic(err)
	}
	return uuid
}
1028412
func (ts *Server) GetWorkflow(ctx context.Context, uuid string) (*WorkflowInfo, error) {
	// Read the file.
	filePath := pathForWorkflow(uuid)
	contents, version, err := ts.globalCell.Get(ctx, filePath)
	if err != nil {
		return nil, err
	}

	// Unpack the contents.
	w := &workflowpb.Workflow{}
	if err := proto.Unmarshal(contents, w); err != nil {
		return nil, err
	}

	return &WorkflowInfo{
		version:  version,
		Workflow: w,
	}, nil
}
958308
func uuid() string {
	f, _ := os.Open(randomSource)
	defer f.Close()
	b := make([]byte, 16)
	f.Read(b)
	return fmt.Sprintf("%x-%x-%x-%x-%x", b[0:4], b[4:6], b[6:8], b[8:10], b[10:])
}
126732
func (n *Network) GetName() (string, error) {
	var err C.virError
	name := C.virNetworkGetNameWrapper(n.ptr, &err)
	if name == nil {
		return "", makeError(&err)
	}
	return C.GoString(name), nil
}
741080
func UUIDv4() UUID {
	uuid := make([]byte, 16)
	rand.Read(uuid)
	uuid[6] = (uuid[6] & 0x0f) | 0x40 // Version 4
	uuid[8] = (uuid[8] & 0x3f) | 0x80 // Variant is 10
	return uuid
}
1030805
func NewV4() UUID {
	u := UUID{}
	safeRandom(u[:])
	u.SetVersion(4)
	u.SetVariant()

	return u
}
763562
func WriteHostUUID(dataDir string, id string) error {
	err := ioutil.WriteFile(filepath.Join(dataDir, HostUUIDFile), []byte(id), os.ModeExclusive|0400)
	if err != nil {
		return trace.ConvertSystemError(err)
	}
	return nil
}
693294
func (c *Connect) LookupSecretByUUIDString(uuid string) (*Secret, error) {
	cUuid := C.CString(uuid)
	defer C.free(unsafe.Pointer(cUuid))
	var err C.virError
	ptr := C.virSecretLookupByUUIDStringWrapper(c.ptr, cUuid, &err)
	if ptr == nil {
		return nil, makeError(&err)
	}
	return &Secret{ptr: ptr}, nil
}
945753
func (f *NWFilter) GetUUIDString() (string, error) {
	var cUuid [C.VIR_UUID_STRING_BUFLEN](C.char)
	cuidPtr := unsafe.Pointer(&cUuid)
	var err C.virError
	result := C.virNWFilterGetUUIDStringWrapper(f.ptr, (*C.char)(cuidPtr), &err)
	if result != 0 {
		return "", makeError(&err)
	}
	return C.GoString((*C.char)(cuidPtr)), nil
}
1154862
func (n *Network) Free() error {
	var err C.virError
	ret := C.virNetworkFreeWrapper(n.ptr, &err)
	if ret == -1 {
		return makeError(&err)
	}
	return nil
}
1233467
func (dc *Datacenter) GetHostByVMUUID(ctx context.Context, vmUUID string) (*types.ManagedObjectReference, error) {
	virtualMachine, err := dc.GetVMByUUID(ctx, vmUUID)
	if err != nil {
		return nil, err
	}
	var vmMo mo.VirtualMachine
	pc := property.DefaultCollector(virtualMachine.Client())
	err = pc.RetrieveOne(ctx, virtualMachine.Reference(), []string{"summary.runtime.host"}, &vmMo)
	if err != nil {
		klog.Errorf("Failed to retrieve VM runtime host, err: %v", err)
		return nil, err
	}
	host := vmMo.Summary.Runtime.Host
	klog.Infof("%s host is %s", virtualMachine.Reference(), host)
	return host, nil
}
1336265
func (c *WorkItemTypeCache) Get(id uuid.UUID) (WorkItemType, bool) {
	c.mapLock.RLock()
	defer c.mapLock.RUnlock()
	w, ok := c.cache[id]
	return w, ok
}
634165
func (r Hardware_SecurityModule) GetNetworkStatusAttribute() (resp datatypes.Hardware_Attribute, err error) {
	err = r.Session.DoRequest("SoftLayer_Hardware_SecurityModule", "getNetworkStatusAttribute", nil, &r.Options, &resp)
	return
}
1318372
func (s *NetworkService) GetNetscalerLoadBalancerNetworkID(keyword string, lbdeviceid string, opts ...OptionFunc) (string, int, error) {
	p := &ListNetscalerLoadBalancerNetworksParams{}
	p.p = make(map[string]interface{})

	p.p["keyword"] = keyword
	p.p["lbdeviceid"] = lbdeviceid

	for _, fn := range append(s.cs.options, opts...) {
		if err := fn(s.cs, p); err != nil {
			return "", -1, err
		}
	}

	l, err := s.ListNetscalerLoadBalancerNetworks(p)
	if err != nil {
		return "", -1, err
	}

	if l.Count == 0 {
		return "", l.Count, fmt.Errorf("No match found for %s: %+v", keyword, l)
	}

	if l.Count == 1 {
		return l.NetscalerLoadBalancerNetworks[0].Id, l.Count, nil
	}

	if l.Count > 1 {
		for _, v := range l.NetscalerLoadBalancerNetworks {
			if v.Name == keyword {
				return v.Id, l.Count, nil
			}
		}
	}
	return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", keyword, l)
}
435543
func (vm VirtualMachine) NicByNetworkID(networkID UUID) *Nic {
	for _, nic := range vm.Nic {
		if nic.NetworkID.Equal(networkID) {
			n := nic
			n.VirtualMachineID = vm.ID
			return &n
		}
	}
	return nil
}