Skip to content

Commit

Permalink
better config renewal
Browse files Browse the repository at this point in the history
  • Loading branch information
joamag committed Dec 20, 2016
1 parent f33f123 commit 78d690d
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions src/rancher/service.py
Expand Up @@ -65,28 +65,19 @@ def upgrade_service(
batch_size = 1,
interval = 2000,
full_upgrade = True,
image_uuid = None
launch_config = None
):
if image_uuid == None: image_uuid = self._service_image_uuid(id)
url = self.base_url + "services/%s?action=upgrade" % id
service = self.get_service(id)
data = service["data"]
fields = data["fields"]
launch_config = fields["launchConfig"]
if launch_config == None: launch_config = self._service_launch_config(id)
contents = self.post(
url,
data_j = dict(
inServiceStrategy = dict(
launchConfig = launch_config,
batchSize = batch_size,
intervalMillis = interval,
fullUpgrade = full_upgrade,
launchConfig = dict(imageUuid = image_uuid),
launchConfig = launch_config,
secondaryLaunchConfigs = []
),
toServiceStrategy = dict(
batchSize = batch_size,
intervalMillis = interval
)
)
)
Expand Down Expand Up @@ -119,9 +110,14 @@ def restart_service(self, id, batch_size = 1, interval = 2000):
data = contents["data"]
return data

def _service_image_uuid(self, id):
def _service_launch_config(self, id):
service = self.get_service(id)
fields = service.get("fields", {})
data = service.get("data", {})
fields = data.get("fields", {})
launch_config = fields.get("launchConfig", {})
return launch_config

def _service_image_uuid(self, id):
launch_config = self._service_launch_config(id)
image_uuid = launch_config.get("imageUuid", None)
return image_uuid

0 comments on commit 78d690d

Please sign in to comment.