本文整理汇总了Golang中github.com/marcosnils/cmt/cmd.Cmd类的典型用法代码示例。如果您正苦于以下问题:Golang Cmd类的具体用法?Golang Cmd怎么用?Golang Cmd使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Cmd类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: getIPTables
func getIPTables(host cmd.Cmd) (string, error) {
rules, _, err := host.Run("sudo", "iptables-save")
if err != nil {
return "", err
}
return rules, nil
}
开发者ID:vanloswang,项目名称:cmt,代码行数:7,代码来源:migrate.go
示例2: isRunning
func isRunning(containerId string, dstCmd cmd.Cmd) bool {
_, _, err := dstCmd.Run("stat", fmt.Sprintf("/var/run/opencontainer/containers/%s", containerId))
if err != nil {
return true
}
return false
}
开发者ID:waterytowers,项目名称:global-hack-day-3,代码行数:8,代码来源:migrate.go
示例3: getVersion
func getVersion(command cmd.Cmd, name string) (string, error) {
version, _, err := command.Run("sudo", name, "--version")
if _, ok := err.(*ssh.ExitError); ok {
return "", fmt.Errorf("Error %s does not exist", name)
} else if _, ok := err.(*exec.ExitError); ok {
return "", fmt.Errorf("Error %s does not exist", name)
} else if err != nil {
return "", fmt.Errorf("Connection error: %s ", err)
}
return version, nil
}
开发者ID:geisbruch,项目名称:cmt,代码行数:11,代码来源:validate.go
示例4: checkKernelCap
func checkKernelCap(c cmd.Cmd) error {
_, _, err := c.Run("sudo", "criu", "check", "--ms")
if _, ok := err.(*ssh.ExitError); ok {
return fmt.Errorf("Error criu checks do not pass")
} else if _, ok := err.(*exec.ExitError); ok {
return fmt.Errorf("Error criu checks do not pass")
} else if err != nil {
return fmt.Errorf("Connection error: %s ", err)
}
return err
}
开发者ID:geisbruch,项目名称:cmt,代码行数:11,代码来源:validate.go
示例5: applyIPTablesRules
func applyIPTablesRules(host cmd.Cmd, rules []string) error {
for _, rule := range rules {
args := []string{"iptables"}
args = append(args, strings.Fields(rule)...)
_, _, err := host.Run("sudo", args...)
if err != nil {
return err
}
}
return nil
}
开发者ID:vanloswang,项目名称:cmt,代码行数:11,代码来源:migrate.go
示例6: checkCPUCompat
func checkCPUCompat(srcCmd, dstCmd cmd.Cmd) error {
// Dump
_, _, err := srcCmd.Run("sudo", "criu", "cpuinfo", "dump")
if _, ok := err.(*ssh.ExitError); ok {
return fmt.Errorf("Error dumping CPU info")
} else if _, ok := err.(*exec.ExitError); ok {
return fmt.Errorf("Error dumping CPU info")
} else if err != nil {
return fmt.Errorf("Connection error: %s ", err)
}
// Copy
err = cmd.Scp(srcCmd.URL("./cpuinfo.img"), dstCmd.URL("."))
if _, ok := err.(*ssh.ExitError); ok {
return fmt.Errorf("Error copying dump image")
} else if _, ok := err.(*exec.ExitError); ok {
return fmt.Errorf("Error copying dump image")
} else if err != nil {
return fmt.Errorf("Connection error: %s ", err)
}
// Check
_, _, err = srcCmd.Run("sudo", "criu", "cpuinfo", "check")
if _, ok := err.(*ssh.ExitError); ok {
return fmt.Errorf("Error checking CPU info")
} else if _, ok := err.(*exec.ExitError); ok {
return fmt.Errorf("Error checking CPU info")
} else if err != nil {
return fmt.Errorf("Connection error: %s ", err)
}
return nil
}
开发者ID:geisbruch,项目名称:cmt,代码行数:33,代码来源:validate.go
示例7: unpackTar
func unpackTar(cmd cmd.Cmd, tarFile, workDir string) {
log.Println("Preparing image at destination host")
_, _, err := cmd.Run("sudo", "tar", "-C", workDir, "-xvzf", tarFile)
if err != nil {
log.Fatal("Error uncompressing image in destination:", err)
}
}
开发者ID:waterytowers,项目名称:global-hack-day-3,代码行数:7,代码来源:migrate.go
示例8: checkpoint
func checkpoint(cmd cmd.Cmd, containerId, imagesPath string, predump bool) {
log.Printf("Performing the checkpoint predump = %t\n", predump)
args := []string{"runc", "--id", containerId, "checkpoint", "--track-mem", "--image-path", imagesPath}
if predump {
args = append(args, "--pre-dump")
}
_, _, err := cmd.Run("sudo", args...)
if err != nil {
log.Fatal("Error performing checkpoint:", err)
}
}
开发者ID:waterytowers,项目名称:global-hack-day-3,代码行数:11,代码来源:migrate.go
示例9: prepareDir
func prepareDir(cmd cmd.Cmd, path string) {
_, _, err := cmd.Run("mkdir", "-p", path)
if err != nil {
log.Fatal("Error preparing pre-dump dir:", err)
}
}
开发者ID:waterytowers,项目名称:global-hack-day-3,代码行数:6,代码来源:migrate.go
示例10: prepareTar
func prepareTar(cmd cmd.Cmd, tarFile, workDir string) {
_, _, err := cmd.Run("sudo", "tar", "-czf", tarFile, "-C", fmt.Sprintf("%s/", workDir), ".")
if err != nil {
log.Fatal("Error compressing image in source:", err)
}
}
开发者ID:waterytowers,项目名称:global-hack-day-3,代码行数:6,代码来源:migrate.go
示例11:
cli.StringFlag{
Name: "hook-failed-restore",
Usage: "Command to run right after a failed process restoration",
},
},
Action: func(c *cli.Context) {
srcUrl := validate.ParseURL(c.String("src"))
dstUrl := validate.ParseURL(c.String("dst"))
log.Println("Performing validations")
src, dst := validate.Validate(srcUrl, dstUrl, c.Bool("force"))
log.Println("Preparing everything to do a checkpoint")
containerId := getContainerId(srcUrl.Path)
var imagesPath string
var restoreCmd cmd.Cmd
var migrateStart time.Time
var downtime time.Duration
if c.Bool("pre-dump") {
// Process pre-dump
predumpPath := fmt.Sprintf("%s/images/0", srcUrl.Path)
prepareDir(src, predumpPath)
checkpoint(src, containerId, predumpPath, true)
srcTarFile := fmt.Sprintf("%s/predump.tar.gz", srcUrl.Path)
prepareTar(src, srcTarFile, predumpPath)
prepareDir(dst, fmt.Sprintf("%s/images/0", dstUrl.Path))
开发者ID:waterytowers,项目名称:global-hack-day-3,代码行数:30,代码来源:migrate.go
注:本文中的github.com/marcosnils/cmt/cmd.Cmd类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论