예제 #1
0
파일: test_glance.py 프로젝트: syotani/nova
    def test_serialize(self):
        metadata = {
            "name": "image1",
            "is_public": True,
            "foo": "bar",
            "properties": {
                "prop1": "propvalue1",
                "mappings": [{"virtual": "aaa", "device": "bbb"}, {"virtual": "xxx", "device": "yyy"}],
                "block_device_mapping": [
                    {"virtual_device": "fake", "device_name": "/dev/fake"},
                    {"virtual_device": "ephemeral0", "device_name": "/dev/fake0"},
                ],
            },
        }

        converted_expected = {
            "name": "image1",
            "is_public": True,
            "foo": "bar",
            "properties": {
                "prop1": "propvalue1",
                "mappings": '[{"device": "bbb", "virtual": "aaa"}, ' '{"device": "yyy", "virtual": "xxx"}]',
                "block_device_mapping": '[{"virtual_device": "fake", "device_name": "/dev/fake"}, '
                '{"virtual_device": "ephemeral0", '
                '"device_name": "/dev/fake0"}]',
            },
        }
        converted = glance._convert_to_string(metadata)
        self.assertEqual(converted, converted_expected)
        self.assertEqual(glance._convert_from_string(converted), metadata)
예제 #2
0
    def test_serialize(self):
        metadata = {'name': 'image1',
                    'is_public': True,
                    'foo': 'bar',
                    'properties': {
                        'prop1': 'propvalue1',
                        'mappings': [
                            {'virtual': 'aaa',
                             'device': 'bbb'},
                            {'virtual': 'xxx',
                             'device': 'yyy'}],
                        'block_device_mapping': [
                            {'virtual_device': 'fake',
                             'device_name': '/dev/fake'},
                            {'virtual_device': 'ephemeral0',
                             'device_name': '/dev/fake0'}]}}

        converted_expected = {
            'name': 'image1',
            'is_public': True,
            'foo': 'bar',
            'properties': {
                'prop1': 'propvalue1',
                'mappings':
                '[{"device": "bbb", "virtual": "aaa"}, '
                '{"device": "yyy", "virtual": "xxx"}]',
                'block_device_mapping':
                '[{"virtual_device": "fake", "device_name": "/dev/fake"}, '
                '{"virtual_device": "ephemeral0", '
                '"device_name": "/dev/fake0"}]'}}
        converted = glance._convert_to_string(metadata)
        self.assertEqual(converted, converted_expected)
        self.assertEqual(glance._convert_from_string(converted), metadata)
예제 #3
0
    def test_serialize(self):
        metadata = {'name': 'image1',
                    'is_public': True,
                    'foo': 'bar',
                    'properties': {
                        'prop1': 'propvalue1',
                        'mappings': [
                            {'virtual': 'aaa',
                             'device': 'bbb'},
                            {'virtual': 'xxx',
                             'device': 'yyy'}],
                        'block_device_mapping': [
                            {'virtual_device': 'fake',
                             'device_name': '/dev/fake'},
                            {'virtual_device': 'ephemeral0',
                             'device_name': '/dev/fake0'}]}}

        converted_expected = {
            'name': 'image1',
            'is_public': True,
            'foo': 'bar',
            'properties': {
                'prop1': 'propvalue1',
                'mappings':
                '[{"device": "bbb", "virtual": "aaa"}, '
                '{"device": "yyy", "virtual": "xxx"}]',
                'block_device_mapping':
                '[{"virtual_device": "fake", "device_name": "/dev/fake"}, '
                '{"virtual_device": "ephemeral0", '
                '"device_name": "/dev/fake0"}]'}}
        converted = glance._convert_to_string(metadata)
        self.assertEqual(converted, converted_expected)
        self.assertEqual(glance._convert_from_string(converted), metadata)
예제 #4
0
 def test_serialize(self):
     metadata = {
         'name': 'image1',
         'is_public': True,
         'foo': 'bar',
         'properties': {
             'prop1':
             'propvalue1',
             'mappings': [{
                 'virtual': 'aaa',
                 'device': 'bbb'
             }, {
                 'virtual': 'xxx',
                 'device': 'yyy'
             }],
             'block_device_mapping': [{
                 'virtual_device': 'fake',
                 'device_name': '/dev/fake'
             }, {
                 'virtual_device': 'ephemeral0',
                 'device_name': '/dev/fake0'
             }]
         }
     }
     # NOTE(tdurakov): Assertion of serialized objects won't work
     # during using of random PYTHONHASHSEED. Assertion of
     # serialized/deserialized object and initial one is enough
     converted = glance._convert_to_string(metadata)
     self.assertEqual(glance._convert_from_string(converted), metadata)
예제 #5
0
파일: test_glance.py 프로젝트: tomzo/nova
 def test_serialize(self):
     metadata = {
         "name": "image1",
         "is_public": True,
         "foo": "bar",
         "properties": {
             "prop1": "propvalue1",
             "mappings": [{"virtual": "aaa", "device": "bbb"}, {"virtual": "xxx", "device": "yyy"}],
             "block_device_mapping": [
                 {"virtual_device": "fake", "device_name": "/dev/fake"},
                 {"virtual_device": "ephemeral0", "device_name": "/dev/fake0"},
             ],
         },
     }
     # NOTE(tdurakov): Assertion of serialized objects won't work
     # during using of random PYTHONHASHSEED. Assertion of
     # serialized/deserialized object and initial one is enough
     converted = glance._convert_to_string(metadata)
     self.assertEqual(glance._convert_from_string(converted), metadata)
예제 #6
0
 def test_serialize(self):
     metadata = {'name': 'image1',
                 'is_public': True,
                 'foo': 'bar',
                 'properties': {
                     'prop1': 'propvalue1',
                     'mappings': [
                         {'virtual': 'aaa',
                          'device': 'bbb'},
                         {'virtual': 'xxx',
                          'device': 'yyy'}],
                     'block_device_mapping': [
                         {'virtual_device': 'fake',
                          'device_name': '/dev/fake'},
                         {'virtual_device': 'ephemeral0',
                          'device_name': '/dev/fake0'}]}}
     # NOTE(tdurakov): Assertion of serialized objects won't work
     # during using of random PYTHONHASHSEED. Assertion of
     # serialized/deserialized object and initial one is enough
     converted = glance._convert_to_string(metadata)
     self.assertEqual(glance._convert_from_string(converted), metadata)