示例#1
0
 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
示例#2
0
    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()
示例#4
0
    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()
示例#5
0
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")
示例#6
0
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")
示例#7
0
    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()
示例#8
0
    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()
示例#9
0
    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()
示例#10
0
文件: base.py 项目: numvc/LuxoftBot
 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
示例#11
0
 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
示例#12
0
 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
示例#13
0
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)