thefactory/marathon-python

Support custom fields in application definition

Opened this issue · 1 comments

Use case: our mesos+marathon deployment supports a resource called networkBandwidth to specify the amount of bandwidth usable by the container. Our marathon supports to specify networkBandwidth as any other resource but this is not part of the upstream api.

I'd like to know if you would consider a PR adding the ability to add extra fields in the json generated from MarathonApp instances.

Example:

MarathonApp(
  id='incubator/demo',
  cpus=1,
  mem=128,
  ...
  extra_fields: {
    "networkBandwidth": 1000
  }
)

The idea would be to support the injection of a dict with any field not present in the official api.

What do you think?

Thanks to the way the MarathonApp is built (deriving from MarathonObject), we can actually do:

app = MarathonApp(id='/incubator/demo')
app.networkBandwidth = 1000

and the resulting json will contain that field.

Considering it works because the internals uses vars (https://github.com/thefactory/marathon-python/blob/master/marathon/models/base.py#L33), would you recommend to use this technique or would you have a better advice?