How to use the heat.common.exception function in heat

To help you get started, we’ve selected a few heat examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github openstack / heat / heat / engine / View on Github external
def required_resource_names(self):
        if self._deps is None:
                required_resources = function.dependencies(self._value)
                self._deps = set(map(lambda rp:, required_resources))
            except (exception.InvalidTemplateAttribute,
                # This output ain't gonna work anyway
                self._deps = set()
        return self._deps
github openstack / heat / heat / engine / clients / os / View on Github external
        client = self.client()
        files = {}

        if files_to_skip is None:
            files_to_skip = []

            headers, objects = client.get_container(files_container)
            bytes_used = int(headers.get('x-container-bytes-used', 0))
            if bytes_used > cfg.CONF.max_json_body_size:
                msg = _("Total size of files to download (%(size)s bytes) "
                        "exceeds maximum allowed (%(limit)s bytes).") % {
                            'size': bytes_used,
                            'limit': cfg.CONF.max_json_body_size}
                raise exception.DownloadLimitExceeded(message=msg)
            for obj in objects:
                file_name = obj['name']
                if file_name not in files_to_skip:
                    contents = client.get_object(files_container, file_name)[1]
                files[file_name] = contents
        except exceptions.ClientException as cex:
            raise exception.NotFound(_('Could not fetch files from '
                                       'container %(container)s, '
                                       'reason: %(reason)s.') %
                                     {'container': files_container,
                                      'reason': str(cex)})
        return files
github openstack / heat / heat / engine / resources / openstack / heat / View on Github external
def _validate_min_adjustment_step(self):
        adjustment_type =
        adjustment_step =
        if (adjustment_type != sc_util.PERCENT_CHANGE_IN_CAPACITY
                and adjustment_step is not None):
            raise exception.ResourcePropertyValueDependency(
github openstack / heat / heat / engine / resources / openstack / nova / View on Github external
def _validate_belonging_subnet_to_net(self, network):
        if network.get(self.NETWORK_PORT) is None:
            net = self._get_network_id(network)
            # check if there are subnet and network both specified that
            # subnet belongs to specified network
            subnet = network.get(self.NETWORK_SUBNET)
            if (subnet is not None and net is not None):
                subnet_net = self.client_plugin(
                if subnet_net != net:
                    msg = _('Specified subnet %(subnet)s does not belongs to '
                            'network %(network)s.') % {
                        'subnet': subnet,
                        'network': net}
                    raise exception.StackValidationFailed(message=msg)
github openstack / heat / heat / engine / resources / View on Github external
def _resolve_attribute(self, name):
            return self.get_output(name)
        except exception.NotFound:
            raise exception.InvalidTemplateAttribute(,
github openstack / heat / heat / common / View on Github external
new_strategies = {}

    if not old:
        return new, new_strategies

    for key, value in new.items():
        # if key not in param_schemata ignore it
        if key in param_schemata and value is not None:
            param_merge_strategy = get_param_merge_strategy(
                strategies_in_file, key)
            if key not in available_strategies:
                new_strategies[key] = param_merge_strategy

            elif param_merge_strategy != available_strategies[key]:
                raise exception.ConflictingMergeStrategyForParam(
                    param=key, env_file=env_file)

            if param_merge_strategy == DEEP_MERGE:
                param_merge(key, value,
            elif param_merge_strategy == MERGE:
                param_merge(key, value, param_schemata[key])
                old[key] = value

    return old, new_strategies
github openstack / heat / heat / engine / View on Github external
if not int(param) == param:
                raise exception.InvalidSchemaError(
                    message=_('step/offset must be integer'))

        step, offset = int(step), int(offset)

        if step == 0:
            raise exception.InvalidSchemaError(message=_('step cannot be 0.'))

        if abs(offset) >= abs(step):
            raise exception.InvalidSchemaError(
                message=_('offset must be smaller (by absolute value) '
                          'than step.'))

        if step * offset < 0:
            raise exception.InvalidSchemaError(
                message=_('step and offset must be both positive or both '
github openstack / heat / heat / engine / View on Github external
return condition_name

        if not (isinstance(condition_name, str) and
                condition_name in self._conditions):
            raise ValueError(_('Invalid condition "%s"') % condition_name)

        if condition_name not in self._resolved:
            self._resolved[condition_name] = _in_progress
            self._resolved[condition_name] = self._resolve(condition_name)

        result = self._resolved[condition_name]

        if result is _in_progress:
            message = _('Circular definition for condition '
                        '"%s"') % condition_name
            raise exception.StackValidationFailed(
                error='Condition validation error',

        return result
github openstack / heat / heat / engine / resources / View on Github external
                image_list = self.nova().images.list()
            except clients.novaclient.exceptions.ClientException as ex:
                raise exception.ServerError(message=str(ex))
            image_names = dict(
                for o in image_list if == image_identifier)
            if len(image_names) == 0:
      "Image %s was not found in glance" %
                raise exception.ImageNotFound(image_name=image_identifier)
            elif len(image_names) > 1:
      "Mulitple images %s were found in glance with name"
                            % image_identifier)
                raise exception.NoUniqueImageFound(image_name=image_identifier)
            image_id = image_names.popitem()[0]
        return image_id