Getting the swiftClient copy command to work

asked 2017-05-30 06:11:03 -0500

Ian_Stuart gravatar image

Problem

Can't set the destination for a copy

Environment:

  • Python 3, python-swiftclient, python-keystoneclient, and keystoneauth1
  • Connection is good, and I can create objects in the store

Code:

def cp(self, old_path, new_path):
    with SwiftService() as swift:
      try:
        _obj = SwiftCopyObject(old_path, 
                               options={"Destination": '/my_container/' + new_path})
        response = swift.copy( self.container, [_obj],
            { "Destination": 'my_container' + new_path })
        for r in response:
          pprint(r)
      except SwiftError as e:
        logger.error(e.value)

If I call self.cp('untitled.ipynb', 'renamed.ipynb'), I get a dump something like:

{'action': 'copy_object',
 'container': 'my_container',
 'destination': None,
 'fresh_metadata': False,
 'headers': {},
 'object': 'Untitled.ipynb',
 'response_dict': {'headers': {'content-length': '0',
                           'content-type': 'binary/octet-stream',
                           'date': 'Tue, 30 May 2017 10:44:49 GMT',
                           'etag': 'd588d3885f633322f6733b2e0f33df71',
                           'last-modified': 'Tue, 30 May 2017 10:44:49 GMT',
                           'x-copied-from': 'kiz/Untitled.ipynb',
                           'x-copied-from-account': '0edbdcab2cda436a90ab73a26b77c83e',
                           'x-copied-from-last-modified': 'Tue, 30 May '
                                                          '2017 10:44:44 '
                                                          'GMT',
                           'x-object-meta-mtime': '1496141084.000000',
                           'x-trans-id': 'tx0000000000000002af6e0-00592d4d20-3d698d-default'},
               'reason': 'Created',
               'response_dicts': [{'headers': {'content-length': '0',
                                               'content-type': 'binary/octet-stream',
                                               'date': 'Tue, 30 May 2017 '
                                                       '10:44:49 GMT',
                                               'etag': 'd588d3885f633322f6733b2e0f33df71',
                                               'last-modified': 'Tue, 30 '
                                                                'May 2017 '
                                                                '10:44:49 '
                                                                'GMT',
                                               'x-copied-from': 'kiz/Untitled.ipynb',
                                               'x-copied-from-account': '0edbdcab2cda436a90ab73a26b77c83e',
                                               'x-copied-from-last-modified': 'Tue, '
                                                                              '30 '
                                                                              'May '
                                                                              '2017 '
                                                                              '10:44:44 '
                                                                              'GMT',
                                               'x-object-meta-mtime': '1496141084.000000',
                                               'x-trans-id': 'tx0000000000000002af6e0-00592d4d20-3d698d-default'},
                                   'reason': 'Created',
                                   'status': 201}],
               'status': 201},
 'success': True}

Why is "Destination" None?

How do I actually set it?

edit retag flag offensive close merge delete