def human_id(self): """Human-readable ID which can be used for bash completion.""" if self.HUMAN_ID: name = getattr(self, self.NAME_ATTR, None) if name is not None: return strutils.to_slug(name) return None
def __init__(self, instance=None, disk_name=None, path=None): super(Qcow2, self).__init__("file", "qcow2", is_block_dev=False) self.path = path or os.path.join(libvirt_utils.get_instance_path(instance), disk_name) self.preallocate = strutils.to_slug(CONF.preallocate_images) == "space" self.disk_info_path = os.path.join(os.path.dirname(self.path), "disk.info") self.resolve_driver_format()
def __init__(self, instance=None, disk_name=None, path=None): super(Qcow2, self).__init__("file", "qcow2", is_block_dev=False) self.path = (path or os.path.join( libvirt_utils.get_instance_path(instance), disk_name)) self.preallocate = (strutils.to_slug( CONF.preallocate_images) == 'space') self.disk_info_path = os.path.join(os.path.dirname(self.path), 'disk.info') self.resolve_driver_format()
def __init__(self, instance=None, disk_name=None, path=None): self.disk_name = disk_name path = path or os.path.join(libvirt_utils.get_instance_path(instance), disk_name) super(Flat, self).__init__(path, "file", "raw", is_block_dev=False) self.preallocate = strutils.to_slug(CONF.preallocate_images) == "space" if self.preallocate: self.driver_io = "native" self.disk_info_path = os.path.join(os.path.dirname(path), "disk.info") self.correct_format()
def slugify(value): """Converts a string usable in a url or filename. Normalizes string, converts to lowercase, removes non-alpha characters, and converts spaces to hyphens. From Django's "django/template/defaultfilters.py". Make use strutils.to_slug from openstack common """ return strutils.to_slug(value, incoming=None, errors="strict")
def slugify(value): """Converts a string usable in a url or filename. Normalizes string, converts to lowercase, removes non-alpha characters, and converts spaces to hyphens. From Django's "django/template/defaultfilters.py". Make use of strutils.to_slug from openstack common """ return strutils.to_slug(value, incoming=None, errors="strict")
def __init__(self, instance=None, disk_name=None, path=None): path = (path or os.path.join(libvirt_utils.get_instance_path(instance), disk_name)) super(Qcow2, self).__init__(path, "file", "qcow2", is_block_dev=False) self.preallocate = ( strutils.to_slug(CONF.preallocate_images) == 'space') if self.preallocate: self.driver_io = "native" self.disk_info_path = os.path.join(os.path.dirname(path), 'disk.info') self.resolve_driver_format()
def __init__(self, instance=None, disk_name=None, path=None): self.disk_name = disk_name super(Raw, self).__init__("file", "raw", is_block_dev=False) self.path = (path or os.path.join(libvirt_utils.get_instance_path(instance), disk_name)) self.preallocate = ( strutils.to_slug(CONF.preallocate_images) == 'space') self.disk_info_path = os.path.join(os.path.dirname(self.path), 'disk.info') self.correct_format()
def __init__(self, instance=None, disk_name=None, path=None): self.disk_name = disk_name path = (path or os.path.join(libvirt_utils.get_instance_path(instance), disk_name)) super(Flat, self).__init__(path, "file", "raw", is_block_dev=False) self.preallocate = (strutils.to_slug( CONF.preallocate_images) == 'space') if self.preallocate: self.driver_io = "native" self.disk_info_path = os.path.join(os.path.dirname(path), 'disk.info') self.correct_format()
def human_id(self): """Provides a pretty ID which can be used for bash completion.""" if 'name' in self.__dict__ and self.HUMAN_ID: return strutils.to_slug(self.name) return None
def human_id(self): """Human-readable ID which can be used for bash completion. """ if self.NAME_ATTR in self.__dict__ and self.HUMAN_ID: return strutils.to_slug(getattr(self, self.NAME_ATTR)) return None
pip install oslo.utils ''' from oslo_utils import strutils ''' utils: dictutils encodeutils eventletutils excutils fileutils fixture importutils netutils reflection secretutils specs_matcher strutils timeutils units uuidutils versionutils ''' slug = strutils.to_slug("input value") print("strutils.to_slug", slug)