From a0670b69415d5182320ea86276f132cddba7efb2 Mon Sep 17 00:00:00 2001 From: Alexander Tivelkov Date: Mon, 20 Jun 2016 13:33:40 +0300 Subject: [PATCH] Two-phase Instance deployment support Currently the provisioning of VM Instances is done by calls of the 'deploy' method of 'io.murano.resources.Instance' class. This method generates the snippet of Heat template describing the VM and its resources, merges this snippet into the global template of the environment and then pushes this template to Heat API. Thus the provisioning of N instances can currently be done only with N updates of the Heat stack, i.e. with N calls of the Heat API, each followed by a significant wait interval. The proper way to do this would be to generate a single Snippet for all the VMs at once, then execute a single Heat Stack update - and then process its output also for all the VMs at once. To allow application developers to implement such a behavior, the 'deploy' method of Instance class is split into two parts: generation of the heat template snippet and the actual pushing of the snippet into the Heat API. These two phases are implemented as 'beginDeploy' and 'endDeploy' methods of the Instance class. These methods are supposed to be properly called by the application code willing to provision multiple instances at once, while the old 'deploy' method just calls them sequentially and is left for backwards compatibility. Similar approach is implemented for releaseResources routine. Change-Id: I985883816bbe9dcc23b05a4170d22acd4af9222d Targets-blueprint: scalable-application-framework --- .../io.murano/Classes/resources/Instance.yaml | 25 ++++++++++++++++--- ...hase-instance-deploy-81d37e7987abc792.yaml | 6 +++++ 2 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 releasenotes/notes/two-phase-instance-deploy-81d37e7987abc792.yaml diff --git a/meta/io.murano/Classes/resources/Instance.yaml b/meta/io.murano/Classes/resources/Instance.yaml index a6680d3f..6ae243f0 100644 --- a/meta/io.murano/Classes/resources/Instance.yaml +++ b/meta/io.murano/Classes/resources/Instance.yaml @@ -103,7 +103,7 @@ Methods: Body: $.sharedIps: $ips - deploy: + beginDeploy: Body: - $.validateBootSource() - $securityGroupName: coalesce( @@ -162,6 +162,9 @@ Methods: # Any additional template preparation - $.instanceTemplate: $.prepareStackTemplate($.instanceTemplate) - $.environment.stack.updateTemplate($.instanceTemplate) + + endDeploy: + Body: - $.environment.stack.push() - $outputs: $.environment.stack.output() - $.ipAddresses: $outputs.get(format('{0}-assigned-ips', $this.name)).values().flatten().distinct() @@ -173,6 +176,11 @@ Methods: Then: $.setAttr(fipAssigned, true) - $.environment.instanceNotifier.trackCloudInstance($this) + deploy: + Body: + - $this.beginDeploy() + - $this.endDeploy() + detectPrimaryNetwork: Body: - $._primaryNetwork: null @@ -283,7 +291,7 @@ Methods: device_type: $blockDevice.deviceType boot_index: $blockDevice.bootIndex - releaseResources: + beginReleaseResources: Body: - $template: $.environment.stack.current() - If: bool($template.resources) and bool($template.outputs) @@ -301,6 +309,12 @@ Methods: - $template.outputs: $template.outputs.deleteAll($outputsToDelete) - $.environment.stack.setTemplate($template) + + endReleaseResources: + Body: + - $template: $.environment.stack.current() + - If: bool($template.resources) and bool($template.outputs) + Then: - $.environment.stack.push() - $.setAttr(instanceResources, []) - $.setAttr(instanceOutputs, []) @@ -309,6 +323,11 @@ Methods: - $.ipAddresses: [] - $.floatingIpAddress: null + releaseResources: + Body: + - $this.beginReleaseResources() + - $this.endReleaseResources() + validateBootSource: Body: - If: $.image = null and len($.blockDevices) = 0 @@ -347,4 +366,4 @@ Methods: getRef: Body: Return: - get_resource: $.name \ No newline at end of file + get_resource: $.name diff --git a/releasenotes/notes/two-phase-instance-deploy-81d37e7987abc792.yaml b/releasenotes/notes/two-phase-instance-deploy-81d37e7987abc792.yaml new file mode 100644 index 00000000..97591dd7 --- /dev/null +++ b/releasenotes/notes/two-phase-instance-deploy-81d37e7987abc792.yaml @@ -0,0 +1,6 @@ +--- +features: + - > + Instance.deploy() can now be split into two phases: beginDeploy() and + endDeploy(). This allows the application developer to provision multiple + instances at once without the need to push the stack for each instance.