def get_template_contents( self, template_file=None, template_url=None, template_object=None, files=None): try: return template_utils.get_template_contents( template_file=template_file, template_url=template_url, template_object=template_object, files=files) except Exception as e: raise exceptions.SDKException( "Error in processing template files: %s" % str(e))
def New(self): print(f'Create `{ self.name }` stack') container = self._create_container(self.name, "ansible") self.conf['Orchestration']['container_name'] = container['container'] self.conf['Orchestration']['ansible_tarball'] = container['name'] files, template = template_utils.get_template_contents( self.conf['CIAP']['stack_template']) self.conf['Orchestration']['openstack_rc'] = self.get_openstack_rc() self.openstack.orchestration.create_stack( name=self.name, template=template, files=files, parameters=dict(self.conf['Orchestration']), tags=('CIAP'))
def read_env_and_templates(self, template_file=None, template_url=None, template_object=None, files=None, environment_files=None): """Read templates and environment content and prepares corresponding stack attributes :param string template_file: Path to the template. :param string template_url: URL of template. :param string template_object: URL to retrieve template object. :param dict files: dict of additional file content to include. :param environment_files: Paths to environment files to apply. :returns: Attributes dict to be set on the :class:`~openstack.orchestration.v1.stack.Stack` :rtype: dict """ stack_attrs = dict() envfiles = None tpl_files = None if environment_files: envfiles, env = \ template_utils.process_multiple_environments_and_files( env_paths=environment_files) stack_attrs['environment'] = env if template_file or template_url or template_object: tpl_files, template = template_utils.get_template_contents( template_file=template_file, template_url=template_url, template_object=template_object, files=files) stack_attrs['template'] = template if tpl_files or envfiles: stack_attrs['files'] = dict( list(tpl_files.items()) + list(envfiles.items())) return stack_attrs
def read_env_and_templates(self, template_file=None, template_url=None, template_object=None, files=None, environment_files=None): """Read templates and environment content and prepares corresponding stack attributes :param string template_file: Path to the template. :param string template_url: URL of template. :param string template_object: URL to retrieve template object. :param dict files: dict of additional file content to include. :param environment_files: Paths to environment files to apply. :returns: Attributes dict to be set on the :class:`~openstack.orchestration.v1.stack.Stack` :rtype: dict """ stack_attrs = dict() envfiles = None tpl_files = None if environment_files: envfiles, env = \ template_utils.process_multiple_environments_and_files( env_paths=environment_files) stack_attrs['environment'] = env if template_file or template_url or template_object: tpl_files, template = template_utils.get_template_contents( template_file=template_file, template_url=template_url, template_object=template_object, files=files) stack_attrs['template'] = template if tpl_files or envfiles: stack_attrs['files'] = dict( list(tpl_files.items()) + list(envfiles.items()) ) return stack_attrs