implement support for heat's get_file function
Enhances Shaker's heat client to support templates which use Heat's get_file function to pass locally available files to the heat engine via the API request Change-Id: I51d3bf3ebcfe09833bbe15f96d36fc8ee5926bf5
This commit is contained in:
parent
a2adff395f
commit
870b20b34f
@ -14,23 +14,33 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
import tempfile
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from heatclient import exc
|
from heatclient import exc
|
||||||
|
from heatclient.common import template_utils
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
from timeout_decorator import timeout
|
from timeout_decorator import TimeoutError, timeout
|
||||||
from timeout_decorator import TimeoutError
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def create_stack(heat_client, stack_name, template, parameters,
|
def create_stack(heat_client, stack_name, template, parameters,
|
||||||
environment=None):
|
environment=None):
|
||||||
|
# process_template_path expects a path to a file object, create
|
||||||
|
# a temporary named file and write the contents of template to it
|
||||||
|
with tempfile.NamedTemporaryFile(mode='w+t') as fd:
|
||||||
|
fd.write(template)
|
||||||
|
fd.seek(0)
|
||||||
|
files, processed_template = template_utils.process_template_path(
|
||||||
|
fd.name)
|
||||||
|
|
||||||
stack_params = {
|
stack_params = {
|
||||||
'stack_name': stack_name,
|
'stack_name': stack_name,
|
||||||
'template': template,
|
'template': processed_template,
|
||||||
'parameters': parameters,
|
'parameters': parameters,
|
||||||
'environment': environment,
|
'environment': environment,
|
||||||
|
'files': files,
|
||||||
}
|
}
|
||||||
|
|
||||||
stack = heat_client.stacks.create(**stack_params)['stack']
|
stack = heat_client.stacks.create(**stack_params)['stack']
|
||||||
|
Loading…
x
Reference in New Issue
Block a user