コード例 #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
ファイル: test_glance.py プロジェクト: StackOps/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)
コード例 #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
ファイル: test_glance.py プロジェクト: blueboxgroup/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)