~ubuntu-branches/ubuntu/saucy/nova/saucy-proposed

« back to all changes in this revision

Viewing changes to nova/tests/hyperv/db_fakes.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short, Chuck Short, Adam Gandelman
  • Date: 2013-02-22 09:27:29 UTC
  • mfrom: (1.1.68)
  • Revision ID: package-import@ubuntu.com-20130222092729-nn3gt8rf97uvts77
Tags: 2013.1.g3-0ubuntu1
[ Chuck Short ]
* New usptream release. 
* debian/patches/debian/patches/fix-ubuntu-tests.patch: Refreshed.
* debian/nova-baremetal.logrotate: Fix logfile path.
* debian/control, debian/nova-spiceproxy.{install, logrotate, upstart}:
  Add spice html5 proxy support.
* debian/nova-novncproxy.upstart: Start on runlevel [2345]
* debian/rules: Call testr directly since run_tests.sh -N gives weird return
  value when tests pass.
* debian/pyddist-overrides: Add websockify.
* debian/nova-common.postinst: Removed config file conversion, since
  the option is no longer available. (LP: #1110567)
* debian/control: Add python-pyasn1 as a dependency.
* debian/control: Add python-oslo-config as a dependency.
* debian/control: Suggest sysfsutils, sg3-utils, multipath-tools for fibre
  channel support.

[ Adam Gandelman ]
* debian/control: Fix typo (websocikfy -> websockify).

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
 
30
30
def get_fake_instance_data(name, project_id, user_id):
31
31
    return {'name': name,
32
 
              'id': 1,
33
 
              'uuid': str(uuid.uuid4()),
34
 
              'project_id': project_id,
35
 
              'user_id': user_id,
36
 
              'image_ref': "1",
37
 
              'kernel_id': "1",
38
 
              'ramdisk_id': "1",
39
 
              'mac_address': "de:ad:be:ef:be:ef",
40
 
              'instance_type':
41
 
                {'name': 'm1.tiny',
42
 
                'memory_mb': 512,
43
 
                'vcpus': 1,
44
 
                'root_gb': 0,
45
 
                'flavorid': 1,
46
 
                'rxtx_factor': 1}
47
 
              }
 
32
            'id': 1,
 
33
            'uuid': str(uuid.uuid4()),
 
34
            'project_id': project_id,
 
35
            'user_id': user_id,
 
36
            'image_ref': "1",
 
37
            'kernel_id': "1",
 
38
            'ramdisk_id': "1",
 
39
            'mac_address': "de:ad:be:ef:be:ef",
 
40
            'instance_type':
 
41
            {'name': 'm1.tiny',
 
42
             'memory_mb': 512,
 
43
             'vcpus': 1,
 
44
             'root_gb': 0,
 
45
             'flavorid': 1,
 
46
             'rxtx_factor': 1}
 
47
            }
48
48
 
49
49
 
50
50
def get_fake_image_data(project_id, user_id):
51
51
    return {'name': 'image1',
52
 
              'id': 1,
53
 
              'project_id': project_id,
54
 
              'user_id': user_id,
55
 
              'image_ref': "1",
56
 
              'kernel_id': "1",
57
 
              'ramdisk_id': "1",
58
 
              'mac_address': "de:ad:be:ef:be:ef",
59
 
              'instance_type': 'm1.tiny',
60
 
              }
 
52
            'id': 1,
 
53
            'project_id': project_id,
 
54
            'user_id': user_id,
 
55
            'image_ref': "1",
 
56
            'kernel_id': "1",
 
57
            'ramdisk_id': "1",
 
58
            'mac_address': "de:ad:be:ef:be:ef",
 
59
            'instance_type': 'm1.tiny',
 
60
            }
61
61
 
62
62
 
63
63
def get_fake_volume_info_data(target_portal, volume_id):
72
72
            'auth_method': 'fake',
73
73
            'auth_method': 'fake',
74
74
        }
75
 
}
 
75
    }
76
76
 
77
77
 
78
78
def get_fake_block_device_info(target_portal, volume_id):
79
 
    return {
80
 
            'block_device_mapping': [{'connection_info': {
81
 
                'driver_volume_type': 'iscsi',
82
 
                'data': {'target_lun': 1,
83
 
                         'volume_id': volume_id,
84
 
                         'target_iqn': 'iqn.2010-10.org.openstack:volume-' +
85
 
                            volume_id,
86
 
                         'target_portal': target_portal,
87
 
                         'target_discovered': False}},
88
 
                'mount_device': 'vda',
89
 
                'delete_on_termination': False}],
 
79
    return {'block_device_mapping': [{'connection_info': {
 
80
                                      'driver_volume_type': 'iscsi',
 
81
                                      'data': {'target_lun': 1,
 
82
                                      'volume_id': volume_id,
 
83
                                      'target_iqn':
 
84
                                      'iqn.2010-10.org.openstack:volume-' +
 
85
                                      volume_id,
 
86
                                      'target_portal': target_portal,
 
87
                                      'target_discovered': False}},
 
88
                                     'mount_device': 'vda',
 
89
                                     'delete_on_termination': False}],
90
90
            'root_device_name': None,
91
91
            'ephemerals': [],
92
92
            'swap': None
93
 
    }
 
93
            }
94
94
 
95
95
 
96
96
def stub_out_db_instance_api(stubs):
99
99
    INSTANCE_TYPES = {
100
100
        'm1.tiny': dict(memory_mb=512, vcpus=1, root_gb=0, flavorid=1),
101
101
        'm1.small': dict(memory_mb=2048, vcpus=1, root_gb=20, flavorid=2),
102
 
        'm1.medium':
103
 
            dict(memory_mb=4096, vcpus=2, root_gb=40, flavorid=3),
 
102
        'm1.medium': dict(memory_mb=4096, vcpus=2, root_gb=40, flavorid=3),
104
103
        'm1.large': dict(memory_mb=8192, vcpus=4, root_gb=80, flavorid=4),
105
 
        'm1.xlarge':
106
 
            dict(memory_mb=16384, vcpus=8, root_gb=160, flavorid=5)}
 
104
        'm1.xlarge': dict(memory_mb=16384, vcpus=8, root_gb=160, flavorid=5)}
107
105
 
108
106
    class FakeModel(object):
109
107
        """Stubs out for model."""
152
150
            'vcpus': instance_type['vcpus'],
153
151
            'mac_addresses': [{'address': values['mac_address']}],
154
152
            'root_gb': instance_type['root_gb'],
155
 
            }
 
153
        }
156
154
        return FakeModel(base_options)
157
155
 
158
 
    def fake_network_get_by_instance(context, instance_id):
159
 
        """Stubs out the db.network_get_by_instance method."""
160
 
 
161
 
        fields = {
162
 
            'bridge': 'vmnet0',
163
 
            'netmask': '255.255.255.0',
164
 
            'gateway': '10.10.10.1',
165
 
            'broadcast': '10.10.10.255',
166
 
            'dns1': 'fake',
167
 
            'vlan': 100}
168
 
        return FakeModel(fields)
169
 
 
170
156
    def fake_instance_type_get_all(context, inactive=0, filters=None):
171
157
        return INSTANCE_TYPES.values()
172
158
 
177
163
        return {}
178
164
 
179
165
    stubs.Set(db, 'instance_create', fake_instance_create)
180
 
    stubs.Set(db, 'network_get_by_instance', fake_network_get_by_instance)
181
166
    stubs.Set(db, 'instance_type_get_all', fake_instance_type_get_all)
182
167
    stubs.Set(db, 'instance_type_get_by_name', fake_instance_type_get_by_name)
183
168
    stubs.Set(db, 'block_device_mapping_get_all_by_instance',
184
 
        fake_block_device_mapping_get_all_by_instance)
 
169
              fake_block_device_mapping_get_all_by_instance)