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


Golang framework.RunCmd函數代碼示例

本文整理匯總了Golang中k8s/io/kubernetes/test/e2e/framework.RunCmd函數的典型用法代碼示例。如果您正苦於以下問題:Golang RunCmd函數的具體用法?Golang RunCmd怎麽用?Golang RunCmd使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


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

示例1: removeMasterReplica

func removeMasterReplica(zone string) error {
	framework.Logf(fmt.Sprintf("Removing an existing master replica, zone: %s", zone))
	v, _, err := framework.RunCmd(path.Join(framework.TestContext.RepoRoot, "hack/e2e-internal/e2e-remove-master.sh"), zone, "true")
	framework.Logf("%s", v)
	if err != nil {
		return err
	}
	return nil
}
開發者ID:jonboulle,項目名稱:kubernetes,代碼行數:9,代碼來源:ha_master.go

示例2: addMasterReplica

func addMasterReplica(zone string) error {
	framework.Logf(fmt.Sprintf("Adding a new master replica, zone: %s", zone))
	v, _, err := framework.RunCmd(path.Join(framework.TestContext.RepoRoot, "hack/e2e-internal/e2e-add-master.sh"), zone)
	framework.Logf("%s", v)
	if err != nil {
		return err
	}
	return nil
}
開發者ID:jonboulle,項目名稱:kubernetes,代碼行數:9,代碼來源:ha_master.go

示例3: removeWorkerNodes

func removeWorkerNodes(zone string) error {
	framework.Logf(fmt.Sprintf("Removing worker nodes, zone: %s", zone))
	v, _, err := framework.RunCmd(path.Join(framework.TestContext.RepoRoot, "hack/e2e-internal/e2e-shrink-cluster.sh"), zone, "true", "true", "true")
	framework.Logf("%s", v)
	if err != nil {
		return err
	}
	return nil
}
開發者ID:kubernetes,項目名稱:kubernetes,代碼行數:9,代碼來源:ha_master.go

示例4: realVersion

// realVersion turns a version constant s into a version string deployable on
// GKE.  See hack/get-build.sh for more information.
func realVersion(s string) (string, error) {
	framework.Logf(fmt.Sprintf("Getting real version for %q", s))
	v, _, err := framework.RunCmd(path.Join(framework.TestContext.RepoRoot, "hack/get-build.sh"), "-v", s)
	if err != nil {
		return v, err
	}
	framework.Logf("Version for %q is %q", s, v)
	return strings.TrimPrefix(strings.TrimSpace(v), "v"), nil
}
開發者ID:alex-mohr,項目名稱:kubernetes,代碼行數:11,代碼來源:cluster_upgrade.go

示例5: restartNodes

func restartNodes(f *framework.Framework, nodeNames []string) error {
	// List old boot IDs.
	oldBootIDs := make(map[string]string)
	for _, name := range nodeNames {
		node, err := f.Client.Nodes().Get(name)
		if err != nil {
			return fmt.Errorf("error getting node info before reboot: %s", err)
		}
		oldBootIDs[name] = node.Status.NodeInfo.BootID
	}
	// Reboot the nodes.
	args := []string{
		"compute",
		fmt.Sprintf("--project=%s", framework.TestContext.CloudConfig.ProjectID),
		"instances",
		"reset",
	}
	args = append(args, nodeNames...)
	args = append(args, fmt.Sprintf("--zone=%s", framework.TestContext.CloudConfig.Zone))
	stdout, stderr, err := framework.RunCmd("gcloud", args...)
	if err != nil {
		return fmt.Errorf("error restarting nodes: %s\nstdout: %s\nstderr: %s", err, stdout, stderr)
	}
	// Wait for their boot IDs to change.
	for _, name := range nodeNames {
		if err := wait.Poll(30*time.Second, 5*time.Minute, func() (bool, error) {
			node, err := f.Client.Nodes().Get(name)
			if err != nil {
				return false, fmt.Errorf("error getting node info after reboot: %s", err)
			}
			return node.Status.NodeInfo.BootID != oldBootIDs[name], nil
		}); err != nil {
			return fmt.Errorf("error waiting for node %s boot ID to change: %s", name, err)
		}
	}
	return nil
}
開發者ID:Random-Liu,項目名稱:kubernetes,代碼行數:37,代碼來源:restart.go


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