Class: Marathon::Groups
Overview
This class represents a set of Groups
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#change(id, hash, force = false, dry_run = false) ⇒ Object
Change parameters of a deployed application group.
-
#delete(id, force = false) ⇒ Object
(also: #remove)
Delete the application group with id.
-
#get(id) ⇒ Object
List the group with the specified ID.
-
#initialize(marathon_instance) ⇒ Groups
constructor
A new instance of Groups.
-
#list ⇒ Object
List all groups.
-
#start(hash) ⇒ Object
(also: #create)
Create and start a new application group.
Methods inherited from Base
Methods included from Error
error_class, error_message, from_response
Constructor Details
#initialize(marathon_instance) ⇒ Groups
Returns a new instance of Groups.
171 172 173 |
# File 'lib/marathon/group.rb', line 171 def initialize(marathon_instance) @marathon_instance = marathon_instance end |
Instance Method Details
#change(id, hash, force = false, dry_run = false) ⇒ Object
Change parameters of a deployed application group. Changes to application parameters will result in a restart of this application. A new application added to the group is started. An existing application removed from the group gets stopped. If there are no changes to the application definition, no restart is triggered. During restart marathon keeps track, that the configured amount of minimal running instances are always available. A deployment can run forever. This is the case, when the new application has a problem and does not become healthy. In this case, human interaction is needed with 2 possible choices: Rollback to an existing older version (send an existing version in the body) Update with a newer version of the group which does not have the problems of the old one. If there is an upgrade process already in progress, a new update will be rejected unless the force flag is set. With the force flag given, a running upgrade is terminated and a new one is started. Since the deployment of the group can take a considerable amount of time, this endpoint returns immediatly with a version. The failure or success of the action is signalled via event. There is a group_change_success and group_change_failed event with the given version. id
: Group’s id. hash
: Hash of attributes to change. force
: If the group is affected by a running deployment, then the update operation will fail.
The current deployment can be overridden by setting the `force` query parameter.
dry_run
: Get a preview of the deployment steps Marathon would run for a given group update.
236 237 238 239 240 241 242 243 244 245 246 |
# File 'lib/marathon/group.rb', line 236 def change(id, hash, force = false, dry_run = false) query = {} query[:force] = true if force query[:dryRun] = true if dry_run json = @marathon_instance.connection.put("/v2/groups/#{id}", query, :body => hash) if dry_run json['steps'].map { |e| Marathon::DeploymentStep.new(e) } else Marathon::DeploymentInfo.new(json, @marathon_instance) end end |
#delete(id, force = false) ⇒ Object Also known as: remove
Delete the application group with id. id
: Group’s id. force
: If the group is affected by a running deployment, then the update operation will fail.
The current deployment can be overridden by setting the `force` query parameter.
192 193 194 195 196 197 |
# File 'lib/marathon/group.rb', line 192 def delete(id, force = false) query = {} query[:force] = true if force json = @marathon_instance.connection.delete("/v2/groups/#{id}", query) Marathon::DeploymentInfo.new(json, @marathon_instance) end |
#get(id) ⇒ Object
List the group with the specified ID. id
: Group’s id.
177 178 179 180 |
# File 'lib/marathon/group.rb', line 177 def get(id) json = @marathon_instance.connection.get("/v2/groups/#{id}") Marathon::Group.new(json, @marathon_instance) end |
#list ⇒ Object
List all groups.
183 184 185 186 |
# File 'lib/marathon/group.rb', line 183 def list json = @marathon_instance.connection.get('/v2/groups') Marathon::Group.new(json, @marathon_instance) end |
#start(hash) ⇒ Object Also known as: create
Create and start a new application group. Application groups can contain other application groups. An application group can either hold other groups or applications, but can not be mixed in one. Since the deployment of the group can take a considerable amount of time, this endpoint returns immediatly with a version. The failure or success of the action is signalled via event. There is a group_change_success and group_change_failed event with the given version. hash
: Hash including all attributes
see https://mesosphere.github.io/marathon/docs/rest-api.html#post-/v2/groups for full details
208 209 210 211 |
# File 'lib/marathon/group.rb', line 208 def start(hash) json = @marathon_instance.connection.post('/v2/groups', nil, :body => hash) Marathon::DeploymentInfo.new(json, @marathon_instance) end |