Skip to content

Commit

Permalink
all: Normalize cloud_provider options for bosh-init
Browse files Browse the repository at this point in the history
Addresses #31 by restructuring the mbus, ntp, and blobstore configuration
properties to be consistent with existing CPIs.
  • Loading branch information
evandbrown committed Jul 14, 2016
1 parent db0d408 commit 79143af
Show file tree
Hide file tree
Showing 11 changed files with 66 additions and 50 deletions.
22 changes: 11 additions & 11 deletions ci/tasks/setup-director.sh
Original file line number Diff line number Diff line change
Expand Up @@ -200,12 +200,12 @@ jobs:
agent:
mbus: nats://nats:nats-password@${google_address_static_director}:4222
ntp: *ntp
blobstore:
options:
endpoint: http://${google_address_static_director}:25250
user: agent
password: agent-password
ntp: *ntp
blobstore:
options:
endpoint: http://${google_address_static_director}:25250
user: agent
password: agent-password
ntp: &ntp
- 169.254.169.254
Expand All @@ -227,11 +227,11 @@ cloud_provider:
google: *google_properties
agent:
mbus: https://mbus:mbus-password@0.0.0.0:6868
blobstore:
provider: local
options:
blobstore_path: /var/vcap/micro_bosh/data/cache
ntp: *ntp
blobstore:
provider: local
options:
blobstore_path: /var/vcap/micro_bosh/data/cache
ntp: *ntp
EOF

pushd ${deployment_dir}
Expand Down
2 changes: 2 additions & 0 deletions src/bosh-google-cpi/action/concrete_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ func NewConcreteFactory(
registryClient,
options.Registry,
options.Agent,
options.Blobstore,
options.Ntp,
googleClient.DefaultRootDiskSizeGb(),
googleClient.DefaultRootDiskType(),
googleClient.DefaultZone(),
Expand Down
11 changes: 10 additions & 1 deletion src/bosh-google-cpi/action/concrete_factory_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,22 @@ import (
type ConcreteFactoryOptions struct {
Agent registry.AgentOptions
Registry registry.ClientOptions

// List of NTP servers
Ntp []string

// Blobstore options
Blobstore registry.BlobstoreOptions
}

func (o ConcreteFactoryOptions) Validate() error {
if err := o.Agent.Validate(); err != nil {
return bosherr.WrapError(err, "Validating Agent configuration")
}

err := o.Blobstore.Validate()
if err != nil {
return bosherr.WrapError(err, "Validating Blobstore configuration")
}
if err := o.Registry.Validate(); err != nil {
return bosherr.WrapError(err, "Validating Registry configuration")
}
Expand Down
8 changes: 4 additions & 4 deletions src/bosh-google-cpi/action/concrete_factory_options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ var _ = Describe("ConcreteFactoryOptions", func() {
validOptions = ConcreteFactoryOptions{
Agent: registry.AgentOptions{
Mbus: "fake-mbus",
Ntp: []string{},
Blobstore: registry.BlobstoreOptions{
Type: "fake-blobstore-type",
},
},
Ntp: []string{},
Blobstore: registry.BlobstoreOptions{
Type: "fake-blobstore-type",
},
Registry: registry.ClientOptions{
Protocol: "http",
Expand Down
2 changes: 2 additions & 0 deletions src/bosh-google-cpi/action/concrete_factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,8 @@ var _ = Describe("ConcreteFactory", func() {
registryClient,
options.Registry,
options.Agent,
options.Blobstore,
options.Ntp,
googleClient.DefaultRootDiskSizeGb(),
googleClient.DefaultRootDiskType(),
googleClient.DefaultZone(),
Expand Down
24 changes: 15 additions & 9 deletions src/bosh-google-cpi/action/create_vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ type CreateVM struct {
registryClient registry.Client
registryOptions registry.ClientOptions
agentOptions registry.AgentOptions
blobstoreOptions registry.BlobstoreOptions
ntp []string
defaultRootDiskSizeGb int
defaultRootDiskType string
defaultZone string
Expand All @@ -37,19 +39,23 @@ func NewCreateVM(
registryClient registry.Client,
registryOptions registry.ClientOptions,
agentOptions registry.AgentOptions,
blobstoreOptions registry.BlobstoreOptions,
ntp []string,
defaultRootDiskSizeGb int,
defaultRootDiskType string,
defaultZone string,
) CreateVM {
return CreateVM{
vmService: vmService,
diskService: diskService,
diskTypeService: diskTypeService,
imageService: imageService,
machineTypeService: machineTypeService,
registryClient: registryClient,
registryOptions: registryOptions,
agentOptions: agentOptions,
vmService: vmService,
diskService: diskService,
diskTypeService: diskTypeService,
imageService: imageService,
machineTypeService: machineTypeService,
registryClient: registryClient,
registryOptions: registryOptions,
agentOptions: agentOptions,
blobstoreOptions: blobstoreOptions,
ntp: ntp,
defaultRootDiskSizeGb: defaultRootDiskSizeGb,
defaultRootDiskType: defaultRootDiskType,
defaultZone: defaultZone,
Expand Down Expand Up @@ -121,7 +127,7 @@ func (cv CreateVM) Run(agentID string, stemcellCID StemcellCID, cloudProps VMClo

// Create VM settings
agentNetworks := networks.AsRegistryNetworks()
agentSettings := registry.NewAgentSettings(agentID, vm, agentNetworks, registry.EnvSettings(env), cv.agentOptions)
agentSettings := registry.NewAgentSettings(agentID, vm, agentNetworks, registry.EnvSettings(env), cv.agentOptions, cv.blobstoreOptions, cv.ntp)
if err = cv.registryClient.Update(vm, agentSettings); err != nil {
return "", bosherr.WrapErrorf(err, "Creating VM")
}
Expand Down
14 changes: 11 additions & 3 deletions src/bosh-google-cpi/action/create_vm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ var _ = Describe("CreateVM", func() {
defaultRootDiskType string
registryOptions registry.ClientOptions
agentOptions registry.AgentOptions
blobstore registry.BlobstoreOptions
ntp []string
expectedVMProps *instance.Properties
expectedInstanceNetworks instance.Networks
expectedAgentSettings registry.AgentSettings
Expand Down Expand Up @@ -68,9 +70,9 @@ var _ = Describe("CreateVM", func() {
}
agentOptions = registry.AgentOptions{
Mbus: "http://fake-mbus",
Blobstore: registry.BlobstoreOptions{
Type: "fake-blobstore-type",
},
}
blobstore = registry.BlobstoreOptions{
Type: "fake-blobstore-type",
}
defaultRootDiskSizeGb = 0
defaultRootDiskType = ""
Expand All @@ -83,6 +85,8 @@ var _ = Describe("CreateVM", func() {
registryClient,
registryOptions,
agentOptions,
blobstore,
ntp,
defaultRootDiskSizeGb,
defaultRootDiskType,
"fake-default-zone",
Expand Down Expand Up @@ -380,6 +384,8 @@ var _ = Describe("CreateVM", func() {
registryClient,
registryOptions,
agentOptions,
blobstore,
ntp,
defaultRootDiskSizeGb,
defaultRootDiskType,
"fake-default-zone",
Expand Down Expand Up @@ -443,6 +449,8 @@ var _ = Describe("CreateVM", func() {
registryClient,
registryOptions,
agentOptions,
blobstore,
ntp,
defaultRootDiskSizeGb,
defaultRootDiskType,
"fake-default-zone",
Expand Down
8 changes: 4 additions & 4 deletions src/bosh-google-cpi/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ var validGoogleConfig = bgcconfig.Config{
var validActionsOptions = bgcaction.ConcreteFactoryOptions{
Agent: registry.AgentOptions{
Mbus: "fake-mbus",
Ntp: []string{},
Blobstore: registry.BlobstoreOptions{
Type: "fake-blobstore-type",
},
},
Ntp: []string{},
Blobstore: registry.BlobstoreOptions{
Type: "fake-blobstore-type",
},
Registry: registry.ClientOptions{
Protocol: "http",
Expand Down
6 changes: 3 additions & 3 deletions src/bosh-google-cpi/integration/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ var (
},
"actions": {
"agent": {
"mbus": "http://127.0.0.1",
"blobstore": {
"mbus": "http://127.0.0.1"
},
"blobstore": {
"type": "local"
}
},
"registry": {
"use_gce_metadata": true
Expand Down
11 changes: 0 additions & 11 deletions src/bosh-google-cpi/registry/agent_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@ import (
type AgentOptions struct {
// Mbus URI
Mbus string

// List of NTP servers
Ntp []string

// Blobstore options
Blobstore BlobstoreOptions
}

// BlobstoreOptions are the blobstore options passed to the BOSH Agent (http://bosh.io/docs/bosh-components.html#agent).
Expand All @@ -31,11 +25,6 @@ func (o AgentOptions) Validate() error {
return bosherr.Error("Must provide a non-empty Mbus")
}

err := o.Blobstore.Validate()
if err != nil {
return bosherr.WrapError(err, "Validating Blobstore configuration")
}

return nil
}

Expand Down
8 changes: 4 additions & 4 deletions src/bosh-google-cpi/registry/agent_settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,21 +110,21 @@ type VMSettings struct {
}

// NewAgentSettings creates new agent settings for a VM.
func NewAgentSettings(agentID string, vmCID string, networksSettings NetworksSettings, env EnvSettings, agentOptions AgentOptions) AgentSettings {
func NewAgentSettings(agentID string, vmCID string, networksSettings NetworksSettings, env EnvSettings, agentOptions AgentOptions, blobstoreOptions BlobstoreOptions, ntp []string) AgentSettings {
agentSettings := AgentSettings{
AgentID: agentID,
Disks: DisksSettings{
System: defaultSystemDisk,
Persistent: map[string]PersistentSettings{},
},
Blobstore: BlobstoreSettings{
Provider: agentOptions.Blobstore.Type,
Options: agentOptions.Blobstore.Options,
Provider: blobstoreOptions.Type,
Options: blobstoreOptions.Options,
},
Env: EnvSettings(env),
Mbus: agentOptions.Mbus,
Networks: networksSettings,
Ntp: agentOptions.Ntp,
Ntp: ntp,
VM: VMSettings{
Name: vmCID,
},
Expand Down

0 comments on commit 79143af

Please sign in to comment.