diff --git a/jobs/scalingengine/spec b/jobs/scalingengine/spec index 81d30a1f6d..f92c0bd40f 100644 --- a/jobs/scalingengine/spec +++ b/jobs/scalingengine/spec @@ -169,6 +169,17 @@ properties: autoscaler.scalingengine.server_key: description: "PEM-encoded server key" + autoscaler.cf_server.port: + description: "the listening port of cf xfcc endpoint" + default: 8080 + + autoscaler.cf_server.xfcc.valid_org_guid: + description: approve org guid for xfcc endpoint + default: '' + + autoscaler.cf_server.xfcc.valid_space_guid: + description: approve space guid for xfcc endpoint + default: '' autoscaler.scalingengine.health.port: description: "the listening port of health endpoint" diff --git a/jobs/scalingengine/templates/scalingengine.yml.erb b/jobs/scalingengine/templates/scalingengine.yml.erb index 562b65596e..8a61a9d8e7 100644 --- a/jobs/scalingengine/templates/scalingengine.yml.erb +++ b/jobs/scalingengine/templates/scalingengine.yml.erb @@ -51,6 +51,11 @@ cf: idle_connection_timeout_ms: <%= p("autoscaler.cf.idle_connection_timeout_ms") %> max_idle_conns_per_host_ms: <%= p("autoscaler.cf.max_idle_conns_per_host_ms") %> +cf_server: + port: <%= p("autoscaler.cf_server.port") %> + xfcc: + valid_org_guid: <%= p("autoscaler.cf_server.xfcc.valid_org_guid") %> + valid_space_guid: <%= p("autoscaler.cf_server.xfcc.valid_space_guid") %> server: port: <%= p("autoscaler.scalingengine.server.port") %> diff --git a/spec/jobs/scalingengine/scalingengine_spec.rb b/spec/jobs/scalingengine/scalingengine_spec.rb index 39d4c13891..e15d6e3532 100644 --- a/spec/jobs/scalingengine/scalingengine_spec.rb +++ b/spec/jobs/scalingengine/scalingengine_spec.rb @@ -39,6 +39,23 @@ end end + context "cf server" do + it "includes default port for cf server" do + expect(rendered_template["cf_server"]["port"]).to eq(8080) + end + + it "defaults xfcc valid org and space " do + properties["autoscaler"]["cf_server"] = {} + properties["autoscaler"]["cf_server"]["xfcc"] = { + "valid_org_guid" => "some-valid-org-guid", + "valid_space_guid" => "some-valid-space-guid" + } + + expect(rendered_template["cf_server"]["xfcc"]["valid_org_guid"]).to eq(properties["autoscaler"]["cf_server"]["xfcc"]["valid_org_guid"]) + expect(rendered_template["cf_server"]["xfcc"]["valid_space_guid"]).to eq(properties["autoscaler"]["cf_server"]["xfcc"]["valid_space_guid"]) + end + end + context "uses tls" do context "policy_db" do it "includes the ca, cert and key in url when configured" do diff --git a/src/autoscaler/helpers/http_server.go b/src/autoscaler/helpers/http_server.go index 20651246ca..a8efbdb65f 100644 --- a/src/autoscaler/helpers/http_server.go +++ b/src/autoscaler/helpers/http_server.go @@ -14,6 +14,7 @@ import ( type ServerConfig struct { Port int `yaml:"port"` TLS models.TLSCerts `yaml:"tls"` + XFCC models.XFCCAuth `yaml:"xfcc"` } func NewHTTPServer(logger lager.Logger, conf ServerConfig, handler http.Handler) (ifrit.Runner, error) { diff --git a/src/autoscaler/models/api.go b/src/autoscaler/models/api.go index 8f8664e15b..66dd342e3f 100644 --- a/src/autoscaler/models/api.go +++ b/src/autoscaler/models/api.go @@ -9,6 +9,11 @@ const ( X509Certificate = "x509" ) +type XFCCAuth struct { + ValidOrgGuid string `yaml:"valid_org_guid"` + ValidSpaceGuid string `yaml:"valid_space_guid"` +} + type BrokerContext struct { OrgGUID string `json:"organization_guid"` SpaceGUID string `json:"space_guid"` diff --git a/src/autoscaler/scalingengine/config/config.go b/src/autoscaler/scalingengine/config/config.go index 15ee855b6e..8cc41d7984 100644 --- a/src/autoscaler/scalingengine/config/config.go +++ b/src/autoscaler/scalingengine/config/config.go @@ -31,6 +31,10 @@ var defaultHealthConfig = helpers.HealthConfig{ }, } +var defaultCfServerConfig = helpers.ServerConfig{ + Port: 8082, +} + var defaultLoggingConfig = helpers.LoggingConfig{ Level: "info", } @@ -49,6 +53,7 @@ type Config struct { CF cf.Config `yaml:"cf"` Logging helpers.LoggingConfig `yaml:"logging"` Server helpers.ServerConfig `yaml:"server"` + CfServer helpers.ServerConfig `yaml:"cf_server"` Health helpers.HealthConfig `yaml:"health"` DB DBConfig `yaml:"db"` DefaultCoolDownSecs int `yaml:"defaultCoolDownSecs"` @@ -61,6 +66,7 @@ func LoadConfig(reader io.Reader) (*Config, error) { CF: defaultCFConfig, Logging: defaultLoggingConfig, Server: defaultServerConfig, + CfServer: defaultCfServerConfig, Health: defaultHealthConfig, HttpClientTimeout: DefaultHttpClientTimeout, } diff --git a/src/autoscaler/scalingengine/config/config_test.go b/src/autoscaler/scalingengine/config/config_test.go index 50aaa06eae..74e6527fa0 100644 --- a/src/autoscaler/scalingengine/config/config_test.go +++ b/src/autoscaler/scalingengine/config/config_test.go @@ -55,6 +55,10 @@ var _ = Describe("Config", func() { Expect(conf.Server.TLS.CertFile).To(Equal("/var/vcap/jobs/autoscaler/config/certs/server.crt")) Expect(conf.Server.TLS.CACertFile).To(Equal("/var/vcap/jobs/autoscaler/config/certs/ca.crt")) + Expect(conf.CfServer.Port).To(Equal(2222)) + Expect(conf.CfServer.XFCC.ValidOrgGuid).To(Equal("valid_org_guid")) + Expect(conf.CfServer.XFCC.ValidSpaceGuid).To(Equal("valid_space_guid")) + Expect(conf.Health.ServerConfig.Port).To(Equal(9999)) Expect(conf.Logging.Level).To(Equal("debug")) diff --git a/src/autoscaler/scalingengine/config/testdata/valid.yml b/src/autoscaler/scalingengine/config/testdata/valid.yml index 487d50b22c..099a49fb94 100644 --- a/src/autoscaler/scalingengine/config/testdata/valid.yml +++ b/src/autoscaler/scalingengine/config/testdata/valid.yml @@ -9,6 +9,13 @@ server: key_file: /var/vcap/jobs/autoscaler/config/certs/server.key cert_file: /var/vcap/jobs/autoscaler/config/certs/server.crt ca_file: /var/vcap/jobs/autoscaler/config/certs/ca.crt + +cf_server: + port: 2222 + xfcc: + valid_org_guid: valid_org_guid + valid_space_guid: valid_space_guid + health: server_config: port: 9999