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.dc1.consul:8080/v1/static/lattice-cell-helpers.tgz",
				To:   "/tmp",
				User: "******",
			}),
			dr.blobStore.DownloadAppBitsAction(dropletName),
			dr.blobStore.DeleteAppBitsAction(dropletName),
			models.WrapAction(&models.RunAction{
				Path: "/bin/chmod",
				Dir:  "/tmp/app",
				Args: []string{"-R", "a+X", "."},
				User: "******",
			}),
			models.WrapAction(&models.RunAction{
				Path: "/tmp/builder",
				Dir:  "/",
				Args: builderConfig.Args(),
				User: "******",
			}),
			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)
}
Beispiel #2
0
				models.SecurityGroupRule{
					Protocol:     models.TCPProtocol,
					Destinations: []string{"bermuda", "bahamas"},
					Ports:        []uint16{4242, 5353},
					PortRange:    &models.PortRange{6666, 7777},
					Log:          true,
				},
			}
			createTaskParams = task_runner.NewCreateTaskParams(
				action,
				"task-name",
				"preloaded:my-rootfs",
				"task-domain",
				"log-source",
				map[string]string{
					"MaRTY": "BiSHoP",
					"CoSMo": "CRaMeR",
				},
				securityGroupRules,
				128,
				100,
				0,
			)
		})

		It("creates a task", func() {
			err := taskRunner.CreateTask(createTaskParams)

			Expect(err).NotTo(HaveOccurred())

			Expect(fakeReceptorClient.TasksCallCount()).To(Equal(1))
func (dr *dropletRunner) BuildDroplet(taskName, dropletName, buildpackUrl string, environment map[string]string) error {
	builderConfig := buildpack_app_lifecycle.NewLifecycleBuilderConfig([]string{buildpackUrl}, true, false)

	action := &models.SerialAction{
		Actions: []models.Action{
			&models.DownloadAction{
				From: "http://file_server.service.dc1.consul:8080/v1/static/lattice-cell-helpers.tgz",
				To:   "/tmp",
			},
			&models.RunAction{
				Path: "/tmp/s3downloader",
				Dir:  "/",
				Args: []string{
					dr.config.BlobTarget().AccessKey,
					dr.config.BlobTarget().SecretKey,
					fmt.Sprintf("http://%s:%d/", dr.config.BlobTarget().TargetHost, dr.config.BlobTarget().TargetPort),
					dr.config.BlobTarget().BucketName,
					fmt.Sprintf("%s/bits.tgz", dropletName),
					"/tmp/bits.tgz",
				},
				User: "******",
			},
			&models.RunAction{
				Path: "/bin/mkdir",
				Dir:  "/",
				Args: []string{"/tmp/app"},
				User: "******",
			},
			&models.RunAction{
				Path: "/bin/tar",
				Dir:  "/",
				Args: []string{"-C", "/tmp/app", "-xf", "/tmp/bits.tgz"},
				User: "******",
			},
			&models.RunAction{
				Path: "/tmp/builder",
				Dir:  "/",
				Args: builderConfig.Args(),
				User: "******",
			},
			&models.RunAction{
				Path: "/tmp/s3uploader",
				Dir:  "/",
				Args: []string{
					dr.config.BlobTarget().AccessKey,
					dr.config.BlobTarget().SecretKey,
					fmt.Sprintf("http://%s:%d/", dr.config.BlobTarget().TargetHost, dr.config.BlobTarget().TargetPort),
					dr.config.BlobTarget().BucketName,
					fmt.Sprintf("%s/droplet.tgz", dropletName),
					"/tmp/droplet",
				},
				User: "******",
			},
			&models.RunAction{
				Path: "/tmp/s3uploader",
				Dir:  "/",
				Args: []string{
					dr.config.BlobTarget().AccessKey,
					dr.config.BlobTarget().SecretKey,
					fmt.Sprintf("http://%s:%d/", dr.config.BlobTarget().TargetHost, dr.config.BlobTarget().TargetPort),
					dr.config.BlobTarget().BucketName,
					fmt.Sprintf("%s/result.json", dropletName),
					"/tmp/result.json",
				},
				User: "******",
			},
		},
	}

	environment["CF_STACK"] = DropletStack

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

	return dr.taskRunner.CreateTask(createTaskParams)
}
Beispiel #4
0
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)

	dropletURL := fmt.Sprintf("http://%s:%s@%s:%s%s",
		dr.config.BlobStore().Username,
		dr.config.BlobStore().Password,
		dr.config.BlobStore().Host,
		dr.config.BlobStore().Port,
		path.Join("/blobs", dropletName))

	action := &models.SerialAction{
		Actions: []models.Action{
			&models.DownloadAction{
				From: "http://file_server.service.dc1.consul:8080/v1/static/lattice-cell-helpers.tgz",
				To:   "/tmp",
				User: "******",
			},
			&models.DownloadAction{
				From: dropletURL + "/bits.zip",
				To:   "/tmp/app",
				User: "******",
			},
			&models.RunAction{
				Path: "/tmp/davtool",
				Dir:  "/",
				Args: []string{"delete", dropletURL + "/bits.zip"},
				User: "******",
			},
			&models.RunAction{
				Path: "/bin/chmod",
				Dir:  "/tmp/app",
				Args: []string{"-R", "a+X", "."},
				User: "******",
			},
			&models.RunAction{
				Path: "/tmp/builder",
				Dir:  "/",
				Args: builderConfig.Args(),
				User: "******",
			},
			&models.RunAction{
				Path: "/tmp/davtool",
				Dir:  "/",
				Args: []string{"put", dropletURL + "/droplet.tgz", "/tmp/droplet"},
				User: "******",
			},
			&models.RunAction{
				Path: "/tmp/davtool",
				Dir:  "/",
				Args: []string{"put", dropletURL + "/result.json", "/tmp/result.json"},
				User: "******",
			},
		},
	}

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

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

	return dr.taskRunner.CreateTask(createTaskParams)
}
Beispiel #5
0
				LogSource:      "log-source",
			}
			securityGroupRules = []models.SecurityGroupRule{
				models.SecurityGroupRule{
					Protocol:     models.TCPProtocol,
					Destinations: []string{"bermuda", "bahamas"},
					Ports:        []uint16{4242, 5353},
					PortRange:    &models.PortRange{6666, 7777},
					Log:          true,
				},
			}
			createTaskParams = task_runner.NewCreateTaskParams(
				action,
				"task-name",
				"preloaded:my-rootfs",
				"task-domain",
				"log-source",
				nil,
				securityGroupRules,
			)
		})

		It("creates a task", func() {
			err := taskRunner.CreateTask(createTaskParams)

			Expect(err).NotTo(HaveOccurred())

			Expect(fakeReceptorClient.TasksCallCount()).To(Equal(1))

			Expect(fakeReceptorClient.UpsertDomainCallCount()).To(Equal(1))
			domain, ttl := fakeReceptorClient.UpsertDomainArgsForCall(0)