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


Golang models.WrapAction函數代碼示例

本文整理匯總了Golang中github.com/cloudfoundry-incubator/bbs/models.WrapAction函數的典型用法代碼示例。如果您正苦於以下問題:Golang WrapAction函數的具體用法?Golang WrapAction怎麽用?Golang WrapAction使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


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

示例1: BuildDroplet

func (dr *dropletRunner) BuildDroplet(taskName, dropletName, buildpackUrl string, environment map[string]string, memoryMB, cpuWeight, diskMB int) error {
	builderConfig := buildpack_app_lifecycle.NewLifecycleBuilderConfig([]string{buildpackUrl}, true, false)

	action := models.WrapAction(&models.SerialAction{
		Actions: []*models.Action{
			models.WrapAction(&models.DownloadAction{
				From: "http://file-server.service.cf.internal:8080/v1/static/cell-helpers/cell-helpers.tgz",
				To:   "/tmp",
				User: "vcap",
			}),
			models.WrapAction(&models.DownloadAction{
				From: "http://file-server.service.cf.internal:8080/v1/static/buildpack_app_lifecycle/buildpack_app_lifecycle.tgz",
				To:   "/tmp",
				User: "vcap",
			}),
			dr.blobStore.DownloadAppBitsAction(dropletName),
			dr.blobStore.DeleteAppBitsAction(dropletName),
			models.WrapAction(&models.RunAction{
				Path: "/bin/chmod",
				Dir:  "/tmp/app",
				Args: []string{"-R", "a+X", "."},
				User: "vcap",
			}),
			models.WrapAction(&models.RunAction{
				Path: "/tmp/builder",
				Dir:  "/",
				Args: builderConfig.Args(),
				User: "vcap",
			}),
			dr.blobStore.UploadDropletAction(dropletName),
			dr.blobStore.UploadDropletMetadataAction(dropletName),
		},
	})

	environment["CF_STACK"] = DropletStack
	environment["MEMORY_LIMIT"] = fmt.Sprintf("%dM", memoryMB)

	proxyConf, err := dr.proxyConfReader.ProxyConf()
	if err != nil {
		return err
	}
	environment["http_proxy"] = proxyConf.HTTPProxy
	environment["https_proxy"] = proxyConf.HTTPSProxy
	environment["no_proxy"] = proxyConf.NoProxy

	createTaskParams := task_runner.NewCreateTaskParams(
		action,
		taskName,
		DropletRootFS,
		"lattice",
		"BUILD",
		environment,
		[]*models.SecurityGroupRule{},
		memoryMB,
		cpuWeight,
		diskMB,
	)

	return dr.taskRunner.CreateTask(createTaskParams)
}
開發者ID:SrinivasChilveri,項目名稱:ltc,代碼行數:60,代碼來源:droplet_runner.go

示例2: DownloadAppBitsAction

func (b *BlobStore) DownloadAppBitsAction(dropletName string) *models.Action {
	return models.WrapAction(&models.SerialAction{
		Actions: []*models.Action{
			models.WrapAction(&models.RunAction{
				Path: "/tmp/s3tool",
				Dir:  "/",
				Args: []string{
					"get",
					b.blobTarget.AccessKey,
					b.blobTarget.SecretKey,
					b.Bucket,
					b.blobTarget.Region,
					"/" + dropletName + "/bits.zip",
					"/tmp/bits.zip",
				},
				User: "vcap",
			}),
			models.WrapAction(&models.RunAction{
				Path: "/bin/mkdir",
				Args: []string{"/tmp/app"},
				User: "vcap",
			}),
			models.WrapAction(&models.RunAction{
				Path: "/usr/bin/unzip",
				Dir:  "/tmp/app",
				Args: []string{"-q", "/tmp/bits.zip"},
				User: "vcap",
			}),
		},
	})
}
開發者ID:davidwadden,項目名稱:ltc,代碼行數:31,代碼來源:blob_store.go

示例3: NewValidDesiredLRP

func NewValidDesiredLRP(guid string) *models.DesiredLRP {
	myRouterJSON := json.RawMessage(`{"foo":"bar"}`)
	modTag := models.NewModificationTag("epoch", 0)
	desiredLRP := &models.DesiredLRP{
		ProcessGuid:          guid,
		Domain:               "some-domain",
		RootFs:               "some:rootfs",
		Instances:            1,
		EnvironmentVariables: []*models.EnvironmentVariable{{Name: "FOO", Value: "bar"}},
		CachedDependencies: []*models.CachedDependency{
			{Name: "app bits", From: "blobstore.com/bits/app-bits", To: "/usr/local/app", CacheKey: "cache-key", LogSource: "log-source"},
			{Name: "app bits with checksum", From: "blobstore.com/bits/app-bits-checksum", To: "/usr/local/app-checksum", CacheKey: "cache-key", LogSource: "log-source", ChecksumAlgorithm: "md5", ChecksumValue: "checksum-value"},
		},
		Setup:          models.WrapAction(&models.RunAction{Path: "ls", User: "name"}),
		Action:         models.WrapAction(&models.RunAction{Path: "ls", User: "name"}),
		StartTimeoutMs: 15000,
		Monitor: models.WrapAction(models.EmitProgressFor(
			models.Timeout(models.Try(models.Parallel(models.Serial(&models.RunAction{Path: "ls", User: "name"}))),
				10*time.Second,
			),
			"start-message",
			"success-message",
			"failure-message",
		)),
		DiskMb:      512,
		MemoryMb:    1024,
		CpuWeight:   42,
		Routes:      &models.Routes{"my-router": &myRouterJSON},
		LogSource:   "some-log-source",
		LogGuid:     "some-log-guid",
		MetricsGuid: "some-metrics-guid",
		Annotation:  "some-annotation",
		Network: &models.Network{
			Properties: map[string]string{
				"some-key":       "some-value",
				"some-other-key": "some-other-value",
			},
		},
		EgressRules: []*models.SecurityGroupRule{{
			Protocol:     models.TCPProtocol,
			Destinations: []string{"1.1.1.1/32", "2.2.2.2/32"},
			PortRange:    &models.PortRange{Start: 10, End: 16000},
		}},
		ModificationTag:               &modTag,
		LegacyDownloadUser:            "legacy-dan",
		TrustedSystemCertificatesPath: "/etc/somepath",
		VolumeMounts: []*models.VolumeMount{
			{
				Driver:        "my-driver",
				VolumeId:      "my-volume",
				ContainerPath: "/mnt/mypath",
				Mode:          models.BindMountMode_RO,
			},
		},
	}
	err := desiredLRP.Validate()
	Expect(err).NotTo(HaveOccurred())

	return desiredLRP
}
開發者ID:timani,項目名稱:bbs,代碼行數:60,代碼來源:constructors.go

示例4: DownloadDropletAction

func (b *BlobStore) DownloadDropletAction(dropletName string) *models.Action {
	return models.WrapAction(&models.SerialAction{
		Actions: []*models.Action{
			models.WrapAction(&models.RunAction{
				Path: "/tmp/s3tool",
				Dir:  "/",
				Args: []string{
					"get",
					b.blobTarget.AccessKey,
					b.blobTarget.SecretKey,
					b.Bucket,
					b.blobTarget.Region,
					"/" + dropletName + "/droplet.tgz",
					"/tmp/droplet.tgz",
				},
				User: "vcap",
			}),
			models.WrapAction(&models.RunAction{
				Path: "/bin/tar",
				Args: []string{"zxf", "/tmp/droplet.tgz"},
				Dir:  "/home/vcap",
				User: "vcap",
			}),
		},
	})
}
開發者ID:davidwadden,項目名稱:ltc,代碼行數:26,代碼來源:blob_store.go

示例5: LaunchDroplet

func (dr *dropletRunner) LaunchDroplet(appName, dropletName string, startCommand string, startArgs []string, appEnvironmentParams app_runner.AppEnvironmentParams) error {
	executionMetadata, err := dr.getExecutionMetadata(path.Join(dropletName, "result.json"))
	if err != nil {
		return err
	}

	dropletAnnotation := annotation{}
	dropletAnnotation.DropletSource.DropletName = dropletName

	annotationBytes, err := json.Marshal(dropletAnnotation)
	if err != nil {
		return err
	}

	if appEnvironmentParams.EnvironmentVariables == nil {
		appEnvironmentParams.EnvironmentVariables = map[string]string{}
	}

	appEnvironmentParams.EnvironmentVariables["PWD"] = "/home/vcap"
	appEnvironmentParams.EnvironmentVariables["TMPDIR"] = "/home/vcap/tmp"
	appEnvironmentParams.WorkingDir = "/home/vcap"

	proxyConf, err := dr.proxyConfReader.ProxyConf()
	if err != nil {
		return err
	}
	appEnvironmentParams.EnvironmentVariables["http_proxy"] = proxyConf.HTTPProxy
	appEnvironmentParams.EnvironmentVariables["https_proxy"] = proxyConf.HTTPSProxy
	appEnvironmentParams.EnvironmentVariables["no_proxy"] = proxyConf.NoProxy

	appParams := app_runner.CreateAppParams{
		AppEnvironmentParams: appEnvironmentParams,

		Name:         appName,
		RootFS:       DropletRootFS,
		StartCommand: "/tmp/launcher",
		AppArgs: []string{
			"/home/vcap/app",
			strings.Join(append([]string{startCommand}, startArgs...), " "),
			executionMetadata,
		},

		Annotation: string(annotationBytes),

		Setup: models.WrapAction(&models.SerialAction{
			LogSource: appName,
			Actions: []*models.Action{
				models.WrapAction(&models.DownloadAction{
					From: "http://file-server.service.cf.internal:8080/v1/static/cell-helpers/cell-helpers.tgz",
					To:   "/tmp",
					User: "vcap",
				}),
				dr.blobStore.DownloadDropletAction(dropletName),
			},
		}),
	}

	return dr.appRunner.CreateApp(appParams)
}
開發者ID:SrinivasChilveri,項目名稱:ltc,代碼行數:59,代碼來源:droplet_runner.go

示例6: createTestTask

func createTestTask(taskGuid string) *models.Task {
	task := model_helpers.NewValidTask(taskGuid)
	task.Domain = "test-domain"
	task.TaskDefinition.RootFs = "some:rootfs"
	task.TaskDefinition.Action = models.WrapAction(&models.RunAction{User: "me", Path: "/bin/true"})
	return task
}
開發者ID:davidwadden,項目名稱:lattice-release,代碼行數:7,代碼來源:tasks_test.go

示例7: DeleteAppBitsAction

func (b *BlobStore) DeleteAppBitsAction(dropletName string) *models.Action {
	return models.WrapAction(&models.RunAction{
		Path: "/tmp/davtool",
		Dir:  "/",
		Args: []string{"delete", b.URL.String() + "/blobs/" + dropletName + "/bits.zip"},
		User: "vcap",
	})
}
開發者ID:davidwadden,項目名稱:ltc,代碼行數:8,代碼來源:blob_store.go

示例8: UploadDropletMetadataAction

func (b *BlobStore) UploadDropletMetadataAction(dropletName string) *models.Action {
	return models.WrapAction(&models.RunAction{
		Path: "/tmp/davtool",
		Dir:  "/",
		Args: []string{"put", b.URL.String() + "/blobs/" + dropletName + "/result.json", "/tmp/result.json"},
		User: "vcap",
	})
}
開發者ID:davidwadden,項目名稱:ltc,代碼行數:8,代碼來源:blob_store.go

示例9: UploadDropletAction

func (b *BlobStore) UploadDropletAction(dropletName string) *models.Action {
	return models.WrapAction(&models.RunAction{
		Path:      "/tmp/davtool",
		Dir:       "/",
		Args:      []string{"put", b.URL.String() + "/blobs/" + dropletName + "-droplet.tgz", "/tmp/droplet"},
		User:      "vcap",
		LogSource: "DROPLET",
	})
}
開發者ID:cloudfoundry-incubator,項目名稱:ltc,代碼行數:9,代碼來源:blob_store.go

示例10: taskCreateRequest

func taskCreateRequest(taskGuid, rootFS string, action models.ActionInterface, memoryMB, diskMB int) receptor.TaskCreateRequest {
	return receptor.TaskCreateRequest{
		TaskGuid: taskGuid,
		Domain:   defaultDomain,
		RootFS:   rootFS,
		MemoryMB: memoryMB,
		DiskMB:   diskMB,
		Action:   models.WrapAction(action),
	}
}
開發者ID:Gerg,項目名稱:inigo,代碼行數:10,代碼來源:receptor_requests.go

示例11: NewValidDesiredLRP

func NewValidDesiredLRP(guid string) *models.DesiredLRP {
	myRouterJSON := json.RawMessage(`{"foo":"bar"}`)
	modTag := models.NewModificationTag("epoch", 0)
	desiredLRP := &models.DesiredLRP{
		ProcessGuid:          guid,
		Domain:               "some-domain",
		RootFs:               "some:rootfs",
		Instances:            1,
		EnvironmentVariables: []*models.EnvironmentVariable{{Name: "FOO", Value: "bar"}},
		Setup:                models.WrapAction(&models.RunAction{Path: "ls", User: "name"}),
		Action:               models.WrapAction(&models.RunAction{Path: "ls", User: "name"}),
		StartTimeout:         15,
		Monitor: models.WrapAction(models.EmitProgressFor(
			models.Timeout(models.Try(models.Parallel(models.Serial(&models.RunAction{Path: "ls", User: "name"}))),
				10*time.Second,
			),
			"start-message",
			"success-message",
			"failure-message",
		)),
		DiskMb:      512,
		MemoryMb:    1024,
		CpuWeight:   42,
		Routes:      &models.Routes{"my-router": &myRouterJSON},
		LogSource:   "some-log-source",
		LogGuid:     "some-log-guid",
		MetricsGuid: "some-metrics-guid",
		Annotation:  "some-annotation",
		EgressRules: []*models.SecurityGroupRule{{
			Protocol:     models.TCPProtocol,
			Destinations: []string{"1.1.1.1/32", "2.2.2.2/32"},
			PortRange:    &models.PortRange{Start: 10, End: 16000},
		}},
		ModificationTag: &modTag,
	}
	err := desiredLRP.Validate()
	Expect(err).NotTo(HaveOccurred())

	return desiredLRP
}
開發者ID:emc-xchallenge,項目名稱:bbs,代碼行數:40,代碼來源:constructors.go

示例12: NewValidTaskDefinition

func NewValidTaskDefinition() *models.TaskDefinition {
	return &models.TaskDefinition{
		RootFs: "docker:///docker.com/docker",
		EnvironmentVariables: []*models.EnvironmentVariable{
			{
				Name:  "FOO",
				Value: "BAR",
			},
		},
		Action: models.WrapAction(&models.RunAction{
			User:           "user",
			Path:           "echo",
			Args:           []string{"hello world"},
			ResourceLimits: &models.ResourceLimits{},
		}),
		MemoryMb:    256,
		DiskMb:      1024,
		CpuWeight:   42,
		Privileged:  true,
		LogGuid:     "123",
		LogSource:   "APP",
		MetricsGuid: "456",
		ResultFile:  "some-file.txt",
		EgressRules: []*models.SecurityGroupRule{
			{
				Protocol:     "tcp",
				Destinations: []string{"0.0.0.0/0"},
				PortRange: &models.PortRange{
					Start: 1,
					End:   1024,
				},
				Log: true,
			},
			{
				Protocol:     "udp",
				Destinations: []string{"8.8.0.0/16"},
				Ports:        []uint32{53},
			},
		},

		Annotation: `[{"anything": "you want!"}]... dude`,
	}
}
開發者ID:emc-xchallenge,項目名稱:bbs,代碼行數:43,代碼來源:constructors.go

示例13: newLRPContainer

func newLRPContainer(lrpKey models.ActualLRPKey, instanceKey models.ActualLRPInstanceKey, netInfo models.ActualLRPNetInfo) executor.Container {
	ports := []executor.PortMapping{}
	for _, portMap := range netInfo.Ports {
		ports = append(ports, executor.PortMapping{
			ContainerPort: uint16(portMap.ContainerPort),
			HostPort:      uint16(portMap.HostPort),
		})
	}

	return executor.Container{
		Guid: rep.LRPContainerGuid(lrpKey.ProcessGuid, instanceKey.InstanceGuid),
		RunInfo: executor.RunInfo{
			Action: models.WrapAction(&models.RunAction{Path: "true"}),
			Ports:  ports,
		},
		ExternalIP: netInfo.Address,
		Tags: executor.Tags{
			rep.ProcessGuidTag:  lrpKey.ProcessGuid,
			rep.InstanceGuidTag: instanceKey.InstanceGuid,
			rep.ProcessIndexTag: strconv.Itoa(int(lrpKey.Index)),
			rep.DomainTag:       lrpKey.Domain,
		},
	}
}
開發者ID:jianhuiz,項目名稱:rep,代碼行數:24,代碼來源:ordinary_lrp_processor_test.go

示例14:

			Expect(err).To(MatchError(ContainSubstring("connection refused")))
		})
	})

	Context("Droplet Actions", func() {
		var dropletURL string

		BeforeEach(func() {
			dropletURL = fmt.Sprintf("http://%s:%[email protected]%s:%s/blobs/droplet-name", blobTargetInfo.Username, blobTargetInfo.Password, blobTargetInfo.Host, blobTargetInfo.Port)
		})

		Describe("#DownloadAppBitsAction", func() {
			It("constructs the correct Action to download app bits", func() {
				Expect(blobStore.DownloadAppBitsAction("droplet-name")).To(Equal(models.WrapAction(&models.DownloadAction{
					From: dropletURL + "/bits.zip",
					To:   "/tmp/app",
					User: "vcap",
				})))
			})
		})

		Describe("#DeleteAppBitsAction", func() {
			It("constructs the correct Action to delete app bits", func() {
				Expect(blobStore.DeleteAppBitsAction("droplet-name")).To(Equal(models.WrapAction(&models.RunAction{
					Path: "/tmp/davtool",
					Dir:  "/",
					Args: []string{"delete", dropletURL + "/bits.zip"},
					User: "vcap",
				})))
			})
		})
開發者ID:SrinivasChilveri,項目名稱:ltc,代碼行數:31,代碼來源:blob_store_test.go

示例15:

				&models.CachedDependency{
					From:     "http://file-server.com/v1/static/the/docker/lifecycle/path.tgz",
					To:       "/tmp/lifecycle",
					CacheKey: "docker-lifecycle",
				},
			}

			Expect(taskDefinition.LegacyDownloadUser).To(Equal("vcap"))
			Expect(taskDefinition.CachedDependencies).To(BeEquivalentTo(expectedCacheDependencies))

			expectedAction := models.WrapAction(&models.RunAction{
				User: "root",
				Path: "/tmp/lifecycle/launcher",
				Args: append(
					[]string{"app"},
					"docker run fast",
					"{}",
				),
				Env:            taskRequest.EnvironmentVariables,
				ResourceLimits: &models.ResourceLimits{},
				LogSource:      "TASK",
			})

			Expect(taskDefinition.Action).To(BeEquivalentTo(expectedAction))
		})

		Context("when the docker path is not specified", func() {
			BeforeEach(func() {
				taskRequest.DockerPath = ""
			})

			It("returns an error", func() {
開發者ID:cf-routing,項目名稱:nsync,代碼行數:32,代碼來源:docker_recipe_builder_test.go


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