当前位置: 首页>>代码示例>>Golang>>正文


Golang uuid.UUID类代码示例

本文整理汇总了Golang中github.com/skyrings/skyring-common/tools/uuid.UUID的典型用法代码示例。如果您正苦于以下问题:Golang UUID类的具体用法?Golang UUID怎么用?Golang UUID使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了UUID类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: GetMonitors

func (c CephApi) GetMonitors(mon string, clusterId uuid.UUID, ctxt string) ([]string, error) {
	getMonsRoute := CEPH_API_ROUTES["GetMons"]
	getMonsRoute.Pattern = strings.Replace(getMonsRoute.Pattern, "{cluster-fsid}", clusterId.String(), 1)

	resp, err := route_request(getMonsRoute, mon, bytes.NewBuffer([]byte{}))
	defer closeRespBody(resp)
	if err != nil {
		return []string{}, err
	}
	respBody, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		return []string{}, err
	}
	var monsDet backend.CephMons
	if err := json.Unmarshal(respBody, &monsDet); err != nil {
		return []string{}, err
	}
	if len(monsDet.Mons) > 0 {
		var list []string
		for _, mon := range monsDet.Mons {
			list = append(list, mon.Name)
		}
		return list, nil
	} else {
		return []string{}, errors.New("Couldn't retrieve the mons")
	}
}
开发者ID:skyrings,项目名称:bigfin,代码行数:27,代码来源:api.go

示例2: FetchClusterDetailsFromProvider

func (a *App) FetchClusterDetailsFromProvider(ctxt string, clusterId uuid.UUID) (retVal map[string]map[string]interface{}, err error) {
	retVal = make(map[string]map[string]interface{})
	var result models.RpcResponse
	vars := make(map[string]string)
	vars["cluster-id"] = clusterId.String()
	provider := a.GetProviderFromClusterId(ctxt, clusterId)
	if provider == nil {
		logger.Get().Error("%s-Faield to get provider for cluster: %v", ctxt, clusterId)
		return nil, fmt.Errorf("Faield to get provider for cluster: %v", clusterId)
	}
	err = provider.Client.Call(fmt.Sprintf("%s.%s", provider.Name, "GetClusterSummary"), models.RpcRequest{RpcRequestVars: vars, RpcRequestData: []byte{}, RpcRequestContext: ctxt}, &result)
	if result.Status.StatusCode == http.StatusOK || result.Status.StatusCode == http.StatusPartialContent {
		providerResult := make(map[string]interface{})
		unmarshalError := json.Unmarshal(result.Data.Result, &providerResult)
		if unmarshalError != nil {
			logger.Get().Error("%s - Error unmarshalling the monitoring data from provider %v.Error %v", ctxt, provider.Name, unmarshalError.Error())
			return nil, fmt.Errorf("%s - Error unmarshalling the monitoring data from provider %v.Error %v", ctxt, provider.Name, unmarshalError.Error())
		}
		retVal[provider.Name] = providerResult
	}
	if err != nil {
		return retVal, fmt.Errorf("%s - Call to provider %v failed.Err: %v\n", ctxt, provider.Name, err)
	}
	if result.Status.StatusMessage != "" && (result.Status.StatusCode == http.StatusPartialContent || result.Status.StatusCode == http.StatusInternalServerError || result.Status.StatusCode == http.StatusBadRequest) {
		return retVal, fmt.Errorf("%s - Call to provider %v failed.Err: %v\n", ctxt, provider.Name, result.Status.StatusMessage)
	}
	return retVal, nil
}
开发者ID:skyrings,项目名称:skyring,代码行数:28,代码来源:request-router.go

示例3: GetMonStatus

func (c CephApi) GetMonStatus(mon string, clusterId uuid.UUID, node string, ctxt string) (backend.MonNodeStatus, error) {
	getMonStatusRoute := CEPH_API_ROUTES["GetMonStatus"]
	getMonStatusRoute.Pattern = strings.Replace(
		getMonStatusRoute.Pattern,
		"{cluster-fsid}",
		clusterId.String(),
		1)
	getMonStatusRoute.Pattern = strings.Replace(
		getMonStatusRoute.Pattern,
		"{mon-name}",
		strings.Split(node, ".")[0],
		1)
	resp, err := route_request(getMonStatusRoute, mon, bytes.NewBuffer([]byte{}))
	defer closeRespBody(resp)
	if err != nil {
		return backend.MonNodeStatus{}, err
	}
	respBody, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		return backend.MonNodeStatus{}, err
	}
	var monStatus backend.MonNodeStatus
	if err := json.Unmarshal(respBody, &monStatus); err != nil {
		return backend.MonNodeStatus{}, err
	}
	return monStatus, nil
}
开发者ID:skyrings,项目名称:bigfin,代码行数:27,代码来源:api.go

示例4: ExecCmd

func (c CephApi) ExecCmd(mon string, clusterId uuid.UUID, cmd string, ctxt string) (bool, string, error) {
	// Replace cluster id in route pattern
	execCmdRoute := CEPH_API_ROUTES["ExecCmd"]
	execCmdRoute.Pattern = strings.Replace(execCmdRoute.Pattern, "{cluster-fsid}", clusterId.String(), 1)
	command := map[string][]string{"command": strings.Split(cmd, " ")}
	buf, err := json.Marshal(command)
	if err != nil {
		return false, "", errors.New(fmt.Sprintf("Error forming request body. error: %v", err))
	}
	body := bytes.NewBuffer(buf)
	resp, err := route_request(execCmdRoute, mon, body)
	defer closeRespBody(resp)
	if err != nil || resp.StatusCode != http.StatusOK {
		return false, "", errors.New(fmt.Sprintf("Failed to execute command: %s. error: %v", cmd, err))
	} else {
		respBody, err := ioutil.ReadAll(resp.Body)
		if err != nil {
			return false, "", err
		}
		var cmdExecResp models.CephCommandResponse
		if err := json.Unmarshal(respBody, &cmdExecResp); err != nil {
			return false, "", err
		}
		if cmdExecResp.Status != 0 {
			return false, "", fmt.Errorf(cmdExecResp.Error)
		} else {
			return true, cmdExecResp.Out, nil
		}
	}
}
开发者ID:skyrings,项目名称:bigfin,代码行数:30,代码来源:api.go

示例5: CreateCrushNode

func (c CephApi) CreateCrushNode(mon string, clusterId uuid.UUID, node backend.CrushNodeRequest, ctxt string) (int, error) {
	// Replace cluster id in route pattern
	var cNodeId int
	route := CEPH_API_ROUTES["CreateCrushNode"]
	route.Pattern = strings.Replace(route.Pattern, "{cluster-fsid}", clusterId.String(), 1)

	buf, err := json.Marshal(node)
	if err != nil {
		return cNodeId, errors.New(fmt.Sprintf("Error forming request body. error: %v", err))
	}
	body := bytes.NewBuffer(buf)
	resp, err := route_request(route, mon, body)
	defer closeRespBody(resp)
	if err != nil || (resp.StatusCode != http.StatusOK && resp.StatusCode != http.StatusAccepted) {
		return cNodeId, errors.New(fmt.Sprintf("Failed to create crush node for cluster: %s. error: %v", clusterId.String(), err))
	}
	ok, err := syncRequestStatus(mon, resp)
	if !ok {
		return cNodeId, err
	}
	cNodes, err := c.GetCrushNodes(mon, clusterId, ctxt)
	if err != nil {
		return cNodeId, err
	}
	for _, cNode := range cNodes {
		if cNode.Name == node.Name {
			return cNode.Id, nil
		}
	}

	return cNodeId, errors.New("Failed to retrieve the Crush Node Id")
}
开发者ID:skyrings,项目名称:bigfin,代码行数:32,代码来源:api.go

示例6: GetClusterNetworks

func (c CephApi) GetClusterNetworks(mon string, clusterId uuid.UUID, ctxt string) (skyringmodels.ClusterNetworks, error) {
	getGetClusterNetworksRoute := CEPH_API_ROUTES["GetClusterNetworks"]
	getGetClusterNetworksRoute.Pattern = strings.Replace(
		getGetClusterNetworksRoute.Pattern,
		"{cluster-fsid}",
		clusterId.String(),
		1)
	resp, err := route_request(getGetClusterNetworksRoute, mon, bytes.NewBuffer([]byte{}))
	defer closeRespBody(resp)
	if err != nil {
		return skyringmodels.ClusterNetworks{}, err
	}
	respBody, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		return skyringmodels.ClusterNetworks{}, err
	}
	var configs map[string]string = make(map[string]string)
	if err := json.Unmarshal(respBody, &configs); err != nil {
		return skyringmodels.ClusterNetworks{}, err
	}
	var clusterNetworks skyringmodels.ClusterNetworks
	clusterNetworks.Public = configs["public_network"]
	if configs["cluster_network"] == "" {
		clusterNetworks.Cluster = clusterNetworks.Public
	} else {
		clusterNetworks.Cluster = configs["cluster_network"]
	}
	return clusterNetworks, nil
}
开发者ID:skyrings,项目名称:bigfin,代码行数:29,代码来源:api.go

示例7: WriteAsyncResponse

func WriteAsyncResponse(taskId uuid.UUID, msg string, result []byte) models.RpcResponse {
	var response models.RpcResponse
	response.Status.StatusCode = http.StatusAccepted
	response.Status.StatusMessage = msg
	response.Data.RequestId = taskId.String()
	response.Data.Result = result
	return response
}
开发者ID:skyrings,项目名称:bigfin,代码行数:8,代码来源:utils.go

示例8: GetPGCount

func (c CephApi) GetPGCount(mon string, clusterId uuid.UUID, ctxt string) (map[string]uint64, error) {
	pgStatsRoute := CEPH_API_ROUTES["GetPGCount"]
	pgStatsRoute.Pattern = strings.Replace(pgStatsRoute.Pattern, "{cluster-fsid}", clusterId.String(), 1)
	resp, err := route_request(pgStatsRoute, mon, bytes.NewBuffer([]byte{}))
	defer closeRespBody(resp)
	var pgSummary map[string]interface{}
	if err != nil {
		return nil, err
	}
	respBody, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		return nil, err
	}
	if err := json.Unmarshal(respBody, &pgSummary); err != nil {
		return nil, err
	}
	pgMap, pgMapOk := pgSummary["pg"].(map[string]interface{})
	if !pgMapOk {
		return nil, fmt.Errorf("%s - Failed to fetch number of pgs for the cluster %v", ctxt, clusterId)
	}

	pgCount := make(map[string]uint64)

	var errPgCountError error
	var warnPgCountError error
	var okPgCountError error

	/*
		Error Pg Count
	*/

	pgCount[skyring_monitoring.CRITICAL], errPgCountError = GetPgStatusBasedCount(monitoring.CRITICAL, clusterId, pgMap)
	if errPgCountError != nil {
		return nil, fmt.Errorf("%s - Err: %v", ctxt, errPgCountError)
	}

	/*
		Warning Pg Count
	*/

	pgCount[skyringmodels.STATUS_WARN], warnPgCountError = GetPgStatusBasedCount(monitoring.WARN, clusterId, pgMap)
	if warnPgCountError != nil {
		return nil, fmt.Errorf("%s - Err: %v", ctxt, warnPgCountError)
	}

	/*
		Clean Pg Count
	*/

	pgCount[skyringmodels.STATUS_OK], okPgCountError = GetPgStatusBasedCount(monitoring.OK, clusterId, pgMap)
	if okPgCountError != nil {
		return nil, fmt.Errorf("%s - Err: %v", ctxt, okPgCountError)
	}

	return pgCount, nil
}
开发者ID:skyrings,项目名称:bigfin,代码行数:56,代码来源:api.go

示例9: CreateCluster

func (s Salt) CreateCluster(clusterName string, fsid uuid.UUID, mons []backend.Mon, ctxt string) (bool, error) {
	mutex.Lock()
	defer mutex.Unlock()
	pyobj, err := pyFuncs["CreateCluster"].Call(clusterName, fsid.String(), mons, ctxt)
	if err == nil {
		return gopy.Bool(pyobj), nil
	}

	return false, err
}
开发者ID:skyrings,项目名称:bigfin,代码行数:10,代码来源:salt.go

示例10: initFormatXL

// initFormatXL - save XL format configuration on all disks.
func initFormatXL(storageDisks []StorageAPI) (err error) {
	var (
		jbod             = make([]string, len(storageDisks))
		formats          = make([]*formatConfigV1, len(storageDisks))
		saveFormatErrCnt = 0
	)
	for index, disk := range storageDisks {
		if err = disk.MakeVol(minioMetaBucket); err != nil {
			if err != errVolumeExists {
				saveFormatErrCnt++
				// Check for write quorum.
				if saveFormatErrCnt <= len(storageDisks)-(len(storageDisks)/2+3) {
					continue
				}
				return errXLWriteQuorum
			}
		}
		var u *uuid.UUID
		u, err = uuid.New()
		if err != nil {
			saveFormatErrCnt++
			// Check for write quorum.
			if saveFormatErrCnt <= len(storageDisks)-(len(storageDisks)/2+3) {
				continue
			}
			return err
		}
		formats[index] = &formatConfigV1{
			Version: "1",
			Format:  "xl",
			XL: &xlFormat{
				Version: "1",
				Disk:    u.String(),
			},
		}
		jbod[index] = formats[index].XL.Disk
	}
	for index, disk := range storageDisks {
		formats[index].XL.JBOD = jbod
		formatBytes, err := json.Marshal(formats[index])
		if err != nil {
			return err
		}
		if err = disk.AppendFile(minioMetaBucket, formatConfigFile, formatBytes); err != nil {
			return err
		}
	}
	return nil
}
开发者ID:yrashk,项目名称:minio,代码行数:50,代码来源:format-config-v1.go

示例11: GetCrushNodes

func (c CephApi) GetCrushNodes(mon string, clusterId uuid.UUID, ctxt string) ([]backend.CrushNode, error) {
	route := CEPH_API_ROUTES["GetCrushNodes"]
	route.Pattern = strings.Replace(route.Pattern, "{cluster-fsid}", clusterId.String(), 1)
	resp, err := route_request(route, mon, bytes.NewBuffer([]byte{}))
	defer closeRespBody(resp)
	if err != nil {
		return []backend.CrushNode{}, err
	}
	respBody, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		return []backend.CrushNode{}, err
	}
	var nodes []backend.CrushNode
	if err := json.Unmarshal(respBody, &nodes); err != nil {
		return []backend.CrushNode{}, err
	}
	return nodes, nil
}
开发者ID:skyrings,项目名称:bigfin,代码行数:18,代码来源:api.go

示例12: GetOSDs

func (c CephApi) GetOSDs(mon string, clusterId uuid.UUID, ctxt string) ([]backend.CephOSD, error) {
	// Replace cluster id in route pattern
	getOsdsRoute := CEPH_API_ROUTES["GetOSDs"]
	getOsdsRoute.Pattern = strings.Replace(getOsdsRoute.Pattern, "{cluster-fsid}", clusterId.String(), 1)
	resp, err := route_request(getOsdsRoute, mon, bytes.NewBuffer([]byte{}))
	defer closeRespBody(resp)
	if err != nil {
		return []backend.CephOSD{}, err
	}
	respBody, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		return []backend.CephOSD{}, err
	}
	var osds []backend.CephOSD
	if err := json.Unmarshal(respBody, &osds); err != nil {
		return []backend.CephOSD{}, err
	}
	return osds, nil
}
开发者ID:skyrings,项目名称:bigfin,代码行数:19,代码来源:api.go

示例13: GetClusterStatus

func (c CephApi) GetClusterStatus(mon string, clusterId uuid.UUID, clusterName string, ctxt string) (status string, err error) {
	// Replace cluster id in route pattern
	getPoolsRoute := CEPH_API_ROUTES["GetClusterStatus"]
	getPoolsRoute.Pattern = strings.Replace(getPoolsRoute.Pattern, "{cluster-fsid}", clusterId.String(), 1)
	resp, err := route_request(getPoolsRoute, mon, bytes.NewBuffer([]byte{}))
	defer closeRespBody(resp)
	if err != nil {
		return "", err
	}
	respBody, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		return "", err
	}
	var clusterHealth backend.CephClusterHealth
	if err := json.Unmarshal(respBody, &clusterHealth); err != nil {
		return "", err
	}
	return clusterHealth.OverallStatus, nil
}
开发者ID:skyrings,项目名称:bigfin,代码行数:19,代码来源:api.go

示例14: lockNode

func lockNode(ctxt string, nodeId uuid.UUID, hostname string, operation string) (*lock.AppLock, error) {
	//lock the node
	locks := make(map[uuid.UUID]string)
	if nodeId.IsZero() {
		//Generate temporary UUID from hostname for the node
		//for locking as the UUID is not available at this point
		id, err := uuid.Parse(util.Md5FromString(hostname))
		if err != nil {
			return nil, fmt.Errorf("Unable to create the UUID for locking for host: %s. error: %v", hostname, err)
		}
		nodeId = *id
	}
	locks[nodeId] = fmt.Sprintf("%s : %s", operation, hostname)
	appLock := lock.NewAppLock(locks)
	if err := GetApp().GetLockManager().AcquireLock(ctxt, *appLock); err != nil {
		return nil, err
	}
	return appLock, nil
}
开发者ID:skyrings,项目名称:skyring,代码行数:19,代码来源:util.go

示例15: UpdateOSD

func (c CephApi) UpdateOSD(mon string, clusterId uuid.UUID, osdId string, params map[string]interface{}, ctxt string) (bool, error) {
	// Replace cluster id in route pattern
	updateOsdRoute := CEPH_API_ROUTES["UpdateOSD"]
	updateOsdRoute.Pattern = strings.Replace(updateOsdRoute.Pattern, "{cluster-fsid}", clusterId.String(), 1)
	updateOsdRoute.Pattern = strings.Replace(updateOsdRoute.Pattern, "{osd-id}", osdId, 1)

	buf, err := json.Marshal(params)
	if err != nil {
		return false, errors.New(fmt.Sprintf("Error forming request body: %v", err))
	}
	body := bytes.NewBuffer(buf)
	resp, err := route_request(updateOsdRoute, mon, body)
	defer closeRespBody(resp)
	if err != nil || (resp.StatusCode != http.StatusOK && resp.StatusCode != http.StatusAccepted) {
		return false, errors.New(fmt.Sprintf("Failed to update osd-id: %s for cluster: %v.error: %v", osdId, clusterId, err))
	} else {
		ok, err := syncRequestStatus(mon, resp)
		return ok, err
	}
}
开发者ID:skyrings,项目名称:bigfin,代码行数:20,代码来源:api.go


注:本文中的github.com/skyrings/skyring-common/tools/uuid.UUID类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。