예제 #1
0
def _create_channel(channel, node, default_content_type=None):
    device = channel.get('device')
    if has_control_chars(device):
        raise ClusterConfigParsingError(
            _('Bad device name: %s in %s') % (device, node.name))
    path = parse_location(channel.get('path'))
    if not device:
        raise ClusterConfigParsingError(
            _('Must specify device for file in %s') % node.name)
    access = DEVICE_MAP.get(device, -1)
    mode = channel.get('mode', None)
    meta = channel.get('meta', {})
    content_type = channel.get('content_type',
                               default_content_type if path else 'text/html')
    if access & ACCESS_READABLE and path:
        if not is_swift_path(path):
            raise ClusterConfigParsingError(
                _('Readable device must be a swift object'))
        if not path.account or not path.container:
            raise ClusterConfigParsingError(
                _('Invalid path %s in %s') % (path.url, node.name))
    return ZvmChannel(device,
                      access,
                      path=path,
                      content_type=content_type,
                      meta_data=meta,
                      mode=mode)
예제 #2
0
 def resolve_path_info(self, account_name, replica_count):
     default_path_info = '/%s' % account_name
     for node in self.node_list:
         top_channel = node.channels[0]
         if top_channel and is_swift_path(top_channel.path):
             if top_channel.access & (ACCESS_READABLE | ACCESS_CDR):
                 node.path_info = top_channel.path.path
             elif top_channel.access & ACCESS_WRITABLE and node.replicate > 0:
                 node.path_info = top_channel.path.path
                 node.replicate = replica_count
             else:
                 node.path_info = default_path_info
         if node.replicate == 0:
             node.replicate = 1
예제 #3
0
 def resolve_path_info(self, account_name, replica_count):
     default_path_info = '/%s' % account_name
     for node in self.node_list:
         top_channel = node.channels[0]
         if top_channel and is_swift_path(top_channel.path):
             if top_channel.access & (ACCESS_READABLE | ACCESS_CDR):
                 node.path_info = top_channel.path.path
             elif top_channel.access & ACCESS_WRITABLE and node.replicate > 0:
                 node.path_info = top_channel.path.path
                 node.replicate = replica_count
             else:
                 node.path_info = default_path_info
         if node.replicate == 0:
             node.replicate = 1
예제 #4
0
def _create_channel(channel, node, default_content_type=None):
    device = channel.get('device')
    if has_control_chars(device):
        raise ClusterConfigParsingError(_('Bad device name: %s in %s') % (device, node.name))
    path = parse_location(channel.get('path'))
    if not device:
        raise ClusterConfigParsingError(_('Must specify device for file in %s') % node.name)
    access = DEVICE_MAP.get(device, -1)
    mode = channel.get('mode', None)
    meta = channel.get('meta', {})
    content_type = channel.get('content_type', default_content_type if path else 'text/html')
    if access & ACCESS_READABLE and path:
        if not is_swift_path(path):
            raise ClusterConfigParsingError(_('Readable device must be a swift object'))
        if not path.account or not path.container:
            raise ClusterConfigParsingError(_('Invalid path %s in %s')
                                            % (path.url, node.name))
    return ZvmChannel(device, access, path=path,
                      content_type=content_type, meta_data=meta, mode=mode)