Exemplo n.º 1
0
    def take_action(self, parsed_args):
        ret = 0
        resources = getattr(parsed_args, self.resource, [])

        for r in resources:
            self.r = r
            try:
                if self.app.client_manager.is_network_endpoint_enabled():
                    self.take_action_network(self.app.client_manager.network,
                                             parsed_args)
                else:
                    self.take_action_compute(self.app.client_manager.compute,
                                             parsed_args)
            except Exception as e:
                msg = _("Failed to delete %(resource)s with name or ID "
                        "'%(name_or_id)s': %(e)s") % {
                            "resource": self.resource,
                            "name_or_id": r,
                            "e": e,
                        }
                LOG.error(msg)
                ret += 1

        if ret:
            total = len(resources)
            msg = _("%(num)s of %(total)s %(resource)ss failed to delete.") % {
                "num": ret,
                "total": total,
                "resource": self.resource,
            }
            raise exceptions.CommandError(msg)
 def take_action(self, parsed_args):
     try:
         if self.app.client_manager.is_network_endpoint_enabled():
             return self.take_action_network(
                 self.app.client_manager.network, parsed_args)
         else:
             return self.take_action_compute(
                 self.app.client_manager.compute, parsed_args)
     except openstack.exceptions.HttpException as exc:
         msg = _("Error while executing command: %s") % exc.message
         raise exceptions.CommandError(msg)
Exemplo n.º 3
0
    def _get_property_converter(self, _property):
        if 'type' not in _property:
            converter = str
        else:
            converter = self._allowed_types_dict.get(_property['type'])

        if not converter:
            raise exceptions.CommandError(
                _("Type {property_type} of property {name} "
                  "is not supported").format(property_type=_property['type'],
                                             name=_property['name']))
        return converter