~ubuntu-branches/ubuntu/vivid/ironic/vivid-updates

« back to all changes in this revision

Viewing changes to ironic/tests/db/utils.py

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2015-01-05 12:21:37 UTC
  • mfrom: (1.2.4)
  • Revision ID: package-import@ubuntu.com-20150105122137-171bqrdpcxqipunk
Tags: 2015.1~b1-0ubuntu1
* New upstream beta release:
  - d/control: Align version requirements with upstream release.
* d/watch: Update uversionmangle to deal with kilo beta versioning
  changes.
* d/control: Bumped Standards-Version to 3.9.6, no changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
from oslo.utils import timeutils
19
19
 
20
20
from ironic.common import states
 
21
from ironic.db import api as db_api
21
22
 
22
23
 
23
24
def get_test_ipmi_info():
107
108
    return {
108
109
        'image_source': 'fake-image',
109
110
        'image_url': 'http://image',
110
 
        'image_checksum': 'checksum'
 
111
        'image_checksum': 'checksum',
 
112
        'image_disk_format': 'qcow2',
 
113
        'image_container_format': 'bare',
111
114
    }
112
115
 
113
116
 
169
172
        'properties': kw.get('properties', properties),
170
173
        'reservation': kw.get('reservation'),
171
174
        'maintenance': kw.get('maintenance', False),
 
175
        'maintenance_reason': kw.get('maintenance_reason'),
172
176
        'console_enabled': kw.get('console_enabled', False),
173
177
        'extra': kw.get('extra', {}),
174
 
        'updated_at': kw.get('created_at'),
175
 
        'created_at': kw.get('updated_at'),
 
178
        'updated_at': kw.get('updated_at'),
 
179
        'created_at': kw.get('created_at'),
176
180
    }
177
181
 
178
182
 
 
183
def create_test_node(**kw):
 
184
    """Create test node entry in DB and return Node DB object.
 
185
 
 
186
    Function to be used to create test Node objects in the database.
 
187
 
 
188
    :param kw: kwargs with overriding values for node's attributes.
 
189
    :returns: Test Node DB object.
 
190
 
 
191
    """
 
192
    node = get_test_node(**kw)
 
193
    # Let DB generate ID if it isn't specified explicitly
 
194
    if 'id' not in kw:
 
195
        del node['id']
 
196
    dbapi = db_api.get_instance()
 
197
    return dbapi.create_node(node)
 
198
 
 
199
 
179
200
def get_test_port(**kw):
180
201
    return {
181
202
        'id': kw.get('id', 987),
188
209
    }
189
210
 
190
211
 
 
212
def create_test_port(**kw):
 
213
    """Create test port entry in DB and return Port DB object.
 
214
 
 
215
    Function to be used to create test Port objects in the database.
 
216
 
 
217
    :param kw: kwargs with overriding values for port's attributes.
 
218
    :returns: Test Port DB object.
 
219
 
 
220
    """
 
221
    port = get_test_port(**kw)
 
222
    # Let DB generate ID if it isn't specified explicitly
 
223
    if 'id' not in kw:
 
224
        del port['id']
 
225
    dbapi = db_api.get_instance()
 
226
    return dbapi.create_port(port)
 
227
 
 
228
 
191
229
def get_test_chassis(**kw):
192
230
    return {
193
231
        'id': kw.get('id', 42),