Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
sla, meter-status: Added sla and meter status to model description #5
Conversation
| +type SLA interface { | ||
| + // Level returns the level of the sla. | ||
| + Level() string | ||
| + // Level returns the credentials of the sla. |
howbazaar
requested changes
Mar 20, 2017
Normally you would need to bump the version number of the wire format for the model, but since it has already been bumped from 1 to 2 for the 2.2 release, I think we can skip this for now. However, you do need to add the parsing code, and tests.
| @@ -424,3 +424,19 @@ type StorageConstraint interface { | ||
| // Count is the required number of storage instances. | ||
| Count() uint64 | ||
| } | ||
| + | ||
| +// SLA represents the sla for the model. |
howbazaar
Mar 20, 2017
Owner
We have been moving interfaces out of the generic file and into the files that implement them. Please move the SLA interface into sla.go
| @@ -89,6 +89,12 @@ type Model interface { | ||
| AddRemoteApplication(RemoteApplicationArgs) RemoteApplication | ||
| Validate() error | ||
| + | ||
| + SetSLA(level string, credentials []byte) |
howbazaar
Mar 20, 2017
Owner
All of the other set methods also return the new thing set. So SetSLA should return the SLA, and SetMeterStatus should return the MeterStatus
mattyw
referenced this pull request
in juju/juju
Mar 22, 2017
Merged
state: Model migration for sla and meter status #7128
| @@ -1225,6 +1284,8 @@ func importModelV1(source map[string]interface{}) (*model, error) { | ||
| func importModelV2(source map[string]interface{}) (*model, error) { | ||
| fields, defaults := modelV1Fields() | ||
| fields["remote-applications"] = schema.StringMap(schema.Any()) | ||
| + fields["sla"] = schema.StringMap(schema.Any()) |
howbazaar
Mar 22, 2017
Owner
Since we are tying the sla and meter-status formats to the model version, this schema should be fully explicit, not Any.
fields["sla"] = schema.FieldMap(
schema.Fields{
"level": schema.String(),
"credentials":schema.String(),
}, nil) // no defaultsAnd similarly for the meter-status.
Since you have not versioned the individual SLA and MeterStatus formats, keep the serialization close to the model code, not in a separate file.
Then your constructor funcs can assume a valid map.
func importSLA(source map[string]interface{}) sla {
return sla{
Level_: source["level"].(string),
Credentials_: source["credentials"].(string),
}
}| + c.Assert(model.MeterStatus().Info(), gc.Equals, "info message") | ||
| +} | ||
| + | ||
| +func (*ModelSerializationSuite) TestSLASerializes(c *gc.C) { |
howbazaar
Mar 22, 2017
Owner
You don't need this test or the following one if you have the tests above using yaml.Marshal and Deserialize.
mattyw commentedMar 20, 2017
This pr adds SLAs and MeterStatus to the model description. This supports the ability to perform model migrations on models with an SLA and meter status