예제 #1
0
 def _stranslate_to_cli_optional_param(param):
     if len(param) < 1 or not isinstance(param, six.string_types):
         raise exceptions.InvalidData(
             'Provided wrong parameter for translation.')
     while not param[0:2] == '--':
         param = '-' + param
     return param.replace('_', '-')
예제 #2
0
 def set_share_type_extra_specs(self,
                                share_type_name_or_id,
                                extra_specs,
                                microversion=None):
     """Set key-value pair for share type."""
     if not (isinstance(extra_specs, dict) and extra_specs):
         raise exceptions.InvalidData(
             message='Provided invalid extra specs - %s' % extra_specs)
     cmd = 'type-key %s set ' % share_type_name_or_id
     for key, value in extra_specs.items():
         cmd += '%(key)s=%(value)s ' % {'key': key, 'value': value}
     return self.manila(cmd, microversion=microversion)
예제 #3
0
 def unset_share_type_extra_specs(self,
                                  share_type_name_or_id,
                                  extra_specs_keys,
                                  microversion=None):
     """Unset key-value pair for share type."""
     if not (isinstance(extra_specs_keys,
                        (list, tuple, set)) and extra_specs_keys):
         raise exceptions.InvalidData(
             message='Provided invalid extra specs - %s' % extra_specs_keys)
     cmd = 'type-key %s unset ' % share_type_name_or_id
     for key in extra_specs_keys:
         cmd += '%s ' % key
     return self.manila(cmd, microversion=microversion)
예제 #4
0
    def unset_share_metadata(self, share, keys, microversion=None):
        """Unsets some share metadata by keys.

        :param share: str -- Name or ID of a share
        :param keys: str/list -- key or list of keys to unset.
        """
        if not (isinstance(keys, list) and keys):
            msg = ('Provided invalid data for unsetting of share metadata - '
                   '%s' % keys)
            raise exceptions.InvalidData(message=msg)
        cmd = 'metadata %s unset ' % share
        for key in keys:
            cmd += '%s ' % key
        return self.manila(cmd, microversion=microversion)
예제 #5
0
    def _set_share_metadata(self,
                            share,
                            data,
                            update_all=False,
                            microversion=None):
        """Sets a share metadata.

        :param share: str -- Name or ID of a share.
        :param data: dict -- key-value pairs to set as metadata.
        :param update_all: bool -- if set True then all keys except provided
            will be deleted.
        """
        if not (isinstance(data, dict) and data):
            msg = ('Provided invalid data for setting of share metadata - '
                   '%s' % data)
            raise exceptions.InvalidData(message=msg)
        if update_all:
            cmd = 'metadata-update-all %s ' % share
        else:
            cmd = 'metadata %s set ' % share
        for k, v in data.items():
            cmd += '%(k)s=%(v)s ' % {'k': k, 'v': v}
        return self.manila(cmd, microversion=microversion)