當前位置: 首頁>>代碼示例>>Golang>>正文


Golang MAASObject.GetSubObject方法代碼示例

本文整理匯總了Golang中launchpad/net/gomaasapi.MAASObject.GetSubObject方法的典型用法代碼示例。如果您正苦於以下問題:Golang MAASObject.GetSubObject方法的具體用法?Golang MAASObject.GetSubObject怎麽用?Golang MAASObject.GetSubObject使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在launchpad/net/gomaasapi.MAASObject的用法示例。


在下文中一共展示了MAASObject.GetSubObject方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: maasGetSingleNode

/*
This is a *low level* function that access a MAAS Server and returns a MAASObject
referring to a single MAAS managed node.
The function takes a pointer to an already active MAASObject as well as a system_id and returns a MAASObject array
and an error code.
*/
func maasGetSingleNode(maas *gomaasapi.MAASObject, system_id string) (gomaasapi.MAASObject, error) {
	log.Printf("[DEBUG] [maasGetSingleNode] Getting a node (%s) from MAAS\n", system_id)
	nodeObject, err := maas.GetSubObject("nodes").GetSubObject(system_id).Get()
	if err != nil {
		log.Printf("[ERROR] [maasGetSingleNode] Unable to get node (%s) from MAAS\n", system_id)
		return gomaasapi.MAASObject{}, err
	}
	return nodeObject, nil
}
開發者ID:negronjl,項目名稱:terraform-provider-maas,代碼行數:15,代碼來源:maas_client.go

示例2: maasReleaseNode

func maasReleaseNode(maas *gomaasapi.MAASObject, system_id string) error {
	log.Printf("[DEBUG] [maasReleaseNode] Releasing node: %s", system_id)

	_, err := maas.GetSubObject("nodes").GetSubObject(system_id).CallPost("release", url.Values{})
	if err != nil {
		log.Printf("[DEBUG] [maasReleaseNode] Unable to release node (%s)", system_id)
		return err
	}
	return nil
}
開發者ID:negronjl,項目名稱:terraform-provider-maas,代碼行數:10,代碼來源:maas_client.go

示例3: maasAllocateNodes

/*
This is a *low level* function that attempts to acquire a MAAS managed node for future deployment.
*/
func maasAllocateNodes(maas *gomaasapi.MAASObject, params url.Values) (gomaasapi.MAASObject, error) {
	log.Printf("[DEBUG] [maasAllocateNodes] Allocating one or more nodes with following params: %+v", params)

	nodeObject, err := maas.GetSubObject("nodes").CallPost("acquire", params)
	if err != nil {
		log.Printf("[ERROR] [maasAllocateNodes] Unable to acquire a node ... bailing")
		return gomaasapi.MAASObject{}, err
	}
	return nodeObject.GetMAASObject()
}
開發者ID:negronjl,項目名稱:terraform-provider-maas,代碼行數:13,代碼來源:maas_client.go

示例4: maasListAllNodes

/*
This is a *low level* function that access a MAAS Server and returns an array of MAASObject
The function takes a pointer to an already active MAASObject and returns a JSONObject array
and an error code.
*/
func maasListAllNodes(maas *gomaasapi.MAASObject) ([]gomaasapi.JSONObject, error) {
	nodeListing := maas.GetSubObject("nodes")
	log.Printf("[DEBUG] [maasListAllNodes] Fetching list of nodes...\n")
	listNodeObjects, err := nodeListing.CallGet("list", url.Values{})
	if err != nil {
		log.Printf("[ERROR] [maasListAllNodes] Unable to get list of nodes ...\n")
		return nil, err
	}

	listNodes, err := listNodeObjects.GetArray()
	if err != nil {
		log.Printf("[ERROR] [maasListAllNodes] Unable to get the node list array ...\n")
		return nil, err
	}
	return listNodes, err
}
開發者ID:negronjl,項目名稱:terraform-provider-maas,代碼行數:21,代碼來源:maas_client.go


注:本文中的launchpad/net/gomaasapi.MAASObject.GetSubObject方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。