Merge lp:~vishvananda/nova/consistent-utcnow into lp:~hudson-openstack/nova/trunk
- consistent-utcnow
- Merge into trunk
Proposed by
Vish Ishaya
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Josh Kearney | ||||
Approved revision: | 1143 | ||||
Merged at revision: | 1147 | ||||
Proposed branch: | lp:~vishvananda/nova/consistent-utcnow | ||||
Merge into: | lp:~hudson-openstack/nova/trunk | ||||
Diff against target: |
905 lines (+77/-95) 31 files modified
bin/nova-manage (+1/-2) nova/api/ec2/admin.py (+1/-2) nova/api/ec2/cloud.py (+2/-3) nova/api/openstack/auth.py (+2/-3) nova/api/openstack/contrib/__init__.py (+1/-1) nova/api/openstack/limits.py (+1/-1) nova/api/openstack/ratelimiting/__init__.py (+1/-1) nova/compute/api.py (+1/-2) nova/compute/manager.py (+1/-2) nova/compute/monitor.py (+1/-1) nova/context.py (+0/-1) nova/db/sqlalchemy/api.py (+14/-15) nova/db/sqlalchemy/migrate_repo/versions/016_make_quotas_key_and_value.py (+5/-5) nova/db/sqlalchemy/models.py (+4/-5) nova/network/manager.py (+1/-1) nova/notifier/api.py (+3/-4) nova/scheduler/driver.py (+2/-1) nova/scheduler/simple.py (+5/-6) nova/scheduler/zone_manager.py (+8/-7) nova/test.py (+2/-2) nova/tests/api/openstack/fakes.py (+1/-2) nova/tests/api/openstack/test_images.py (+0/-1) nova/tests/api/openstack/test_servers.py (+4/-4) nova/tests/test_compute.py (+2/-3) nova/tests/test_console.py (+0/-2) nova/tests/test_middleware.py (+0/-1) nova/tests/test_scheduler.py (+8/-8) nova/utils.py (+1/-1) nova/virt/xenapi/fake.py (+2/-2) nova/volume/api.py (+2/-3) nova/volume/manager.py (+1/-3) |
||||
To merge this branch: | bzr merge lp:~vishvananda/nova/consistent-utcnow | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Josh Kearney (community) | Approve | ||
Devin Carlen (community) | Approve | ||
Review via email: mp+63302@code.launchpad.net |
Commit message
Description of the change
Changes all uses of utcnow to use the version in utils. This is a simple wrapper for datetime.
There are still a few places in the Zone code that is using datetime.now(), I'd prefer to move this to utils.utcnow() as well but I want to chat with sandy first to make sure that there won't be any issues.
To post a comment you must log in.
- 1143. By Vish Ishaya
-
switch zones to use utcnow
Revision history for this message
Vish Ishaya (vishvananda) wrote : | # |
> I'm assuming the changes to fake the values in the tests are being treated as
> a separate issue?
The only test that is using the time override stuff right now is test_middleware.py. I don't know if this is because other parts of the system aren't time sensitive, or if people just didn't write tests because they didn't know that the time override exists.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'bin/nova-manage' | |||
2 | --- bin/nova-manage 2011-06-01 23:01:41 +0000 | |||
3 | +++ bin/nova-manage 2011-06-02 21:52:56 +0000 | |||
4 | @@ -53,7 +53,6 @@ | |||
5 | 53 | CLI interface for nova management. | 53 | CLI interface for nova management. |
6 | 54 | """ | 54 | """ |
7 | 55 | 55 | ||
8 | 56 | import datetime | ||
9 | 57 | import gettext | 56 | import gettext |
10 | 58 | import glob | 57 | import glob |
11 | 59 | import json | 58 | import json |
12 | @@ -689,7 +688,7 @@ | |||
13 | 689 | """Show a list of all running services. Filter by host & service name. | 688 | """Show a list of all running services. Filter by host & service name. |
14 | 690 | args: [host] [service]""" | 689 | args: [host] [service]""" |
15 | 691 | ctxt = context.get_admin_context() | 690 | ctxt = context.get_admin_context() |
17 | 692 | now = datetime.datetime.utcnow() | 691 | now = utils.utcnow() |
18 | 693 | services = db.service_get_all(ctxt) | 692 | services = db.service_get_all(ctxt) |
19 | 694 | if host: | 693 | if host: |
20 | 695 | services = [s for s in services if s['host'] == host] | 694 | services = [s for s in services if s['host'] == host] |
21 | 696 | 695 | ||
22 | === modified file 'nova/api/ec2/admin.py' | |||
23 | --- nova/api/ec2/admin.py 2011-04-19 16:19:52 +0000 | |||
24 | +++ nova/api/ec2/admin.py 2011-06-02 21:52:56 +0000 | |||
25 | @@ -21,7 +21,6 @@ | |||
26 | 21 | """ | 21 | """ |
27 | 22 | 22 | ||
28 | 23 | import base64 | 23 | import base64 |
29 | 24 | import datetime | ||
30 | 25 | 24 | ||
31 | 26 | from nova import db | 25 | from nova import db |
32 | 27 | from nova import exception | 26 | from nova import exception |
33 | @@ -305,7 +304,7 @@ | |||
34 | 305 | * Volume Count | 304 | * Volume Count |
35 | 306 | """ | 305 | """ |
36 | 307 | services = db.service_get_all(context, False) | 306 | services = db.service_get_all(context, False) |
38 | 308 | now = datetime.datetime.utcnow() | 307 | now = utils.utcnow() |
39 | 309 | hosts = [] | 308 | hosts = [] |
40 | 310 | rv = [] | 309 | rv = [] |
41 | 311 | for host in [service['host'] for service in services]: | 310 | for host in [service['host'] for service in services]: |
42 | 312 | 311 | ||
43 | === modified file 'nova/api/ec2/cloud.py' | |||
44 | --- nova/api/ec2/cloud.py 2011-05-27 05:13:17 +0000 | |||
45 | +++ nova/api/ec2/cloud.py 2011-06-02 21:52:56 +0000 | |||
46 | @@ -23,7 +23,6 @@ | |||
47 | 23 | """ | 23 | """ |
48 | 24 | 24 | ||
49 | 25 | import base64 | 25 | import base64 |
50 | 26 | import datetime | ||
51 | 27 | import IPy | 26 | import IPy |
52 | 28 | import os | 27 | import os |
53 | 29 | import urllib | 28 | import urllib |
54 | @@ -235,7 +234,7 @@ | |||
55 | 235 | 'zoneState': 'available'}]} | 234 | 'zoneState': 'available'}]} |
56 | 236 | 235 | ||
57 | 237 | services = db.service_get_all(context, False) | 236 | services = db.service_get_all(context, False) |
59 | 238 | now = datetime.datetime.utcnow() | 237 | now = utils.utcnow() |
60 | 239 | hosts = [] | 238 | hosts = [] |
61 | 240 | for host in [service['host'] for service in services]: | 239 | for host in [service['host'] for service in services]: |
62 | 241 | if not host in hosts: | 240 | if not host in hosts: |
63 | @@ -595,7 +594,7 @@ | |||
64 | 595 | instance_id = ec2utils.ec2_id_to_id(ec2_id) | 594 | instance_id = ec2utils.ec2_id_to_id(ec2_id) |
65 | 596 | output = self.compute_api.get_console_output( | 595 | output = self.compute_api.get_console_output( |
66 | 597 | context, instance_id=instance_id) | 596 | context, instance_id=instance_id) |
68 | 598 | now = datetime.datetime.utcnow() | 597 | now = utils.utcnow() |
69 | 599 | return {"InstanceId": ec2_id, | 598 | return {"InstanceId": ec2_id, |
70 | 600 | "Timestamp": now, | 599 | "Timestamp": now, |
71 | 601 | "output": base64.b64encode(output)} | 600 | "output": base64.b64encode(output)} |
72 | 602 | 601 | ||
73 | === modified file 'nova/api/openstack/auth.py' | |||
74 | --- nova/api/openstack/auth.py 2011-05-17 19:12:48 +0000 | |||
75 | +++ nova/api/openstack/auth.py 2011-06-02 21:52:56 +0000 | |||
76 | @@ -13,9 +13,8 @@ | |||
77 | 13 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | 13 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
78 | 14 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | 14 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
79 | 15 | # License for the specific language governing permissions and limitations | 15 | # License for the specific language governing permissions and limitations |
81 | 16 | # under the License.import datetime | 16 | # under the License. |
82 | 17 | 17 | ||
83 | 18 | import datetime | ||
84 | 19 | import hashlib | 18 | import hashlib |
85 | 20 | import time | 19 | import time |
86 | 21 | 20 | ||
87 | @@ -127,7 +126,7 @@ | |||
88 | 127 | except exception.NotFound: | 126 | except exception.NotFound: |
89 | 128 | return None | 127 | return None |
90 | 129 | if token: | 128 | if token: |
92 | 130 | delta = datetime.datetime.utcnow() - token['created_at'] | 129 | delta = utils.utcnow() - token['created_at'] |
93 | 131 | if delta.days >= 2: | 130 | if delta.days >= 2: |
94 | 132 | self.db.auth_token_destroy(ctxt, token['token_hash']) | 131 | self.db.auth_token_destroy(ctxt, token['token_hash']) |
95 | 133 | else: | 132 | else: |
96 | 134 | 133 | ||
97 | === modified file 'nova/api/openstack/contrib/__init__.py' | |||
98 | --- nova/api/openstack/contrib/__init__.py 2011-03-30 01:16:09 +0000 | |||
99 | +++ nova/api/openstack/contrib/__init__.py 2011-06-02 21:52:56 +0000 | |||
100 | @@ -13,7 +13,7 @@ | |||
101 | 13 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | 13 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
102 | 14 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | 14 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
103 | 15 | # License for the specific language governing permissions and limitations | 15 | # License for the specific language governing permissions and limitations |
105 | 16 | # under the License.import datetime | 16 | # under the License. |
106 | 17 | 17 | ||
107 | 18 | """Contrib contains extensions that are shipped with nova. | 18 | """Contrib contains extensions that are shipped with nova. |
108 | 19 | 19 | ||
109 | 20 | 20 | ||
110 | === modified file 'nova/api/openstack/limits.py' | |||
111 | --- nova/api/openstack/limits.py 2011-05-26 16:06:54 +0000 | |||
112 | +++ nova/api/openstack/limits.py 2011-06-02 21:52:56 +0000 | |||
113 | @@ -11,7 +11,7 @@ | |||
114 | 11 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | 11 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
115 | 12 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | 12 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
116 | 13 | # License for the specific language governing permissions and limitations | 13 | # License for the specific language governing permissions and limitations |
118 | 14 | # under the License.import datetime | 14 | # under the License. |
119 | 15 | 15 | ||
120 | 16 | """ | 16 | """ |
121 | 17 | Module dedicated functions/classes dealing with rate limiting requests. | 17 | Module dedicated functions/classes dealing with rate limiting requests. |
122 | 18 | 18 | ||
123 | === modified file 'nova/api/openstack/ratelimiting/__init__.py' | |||
124 | --- nova/api/openstack/ratelimiting/__init__.py 2011-03-03 16:04:33 +0000 | |||
125 | +++ nova/api/openstack/ratelimiting/__init__.py 2011-06-02 21:52:56 +0000 | |||
126 | @@ -13,7 +13,7 @@ | |||
127 | 13 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | 13 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
128 | 14 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | 14 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
129 | 15 | # License for the specific language governing permissions and limitations | 15 | # License for the specific language governing permissions and limitations |
131 | 16 | # under the License.import datetime | 16 | # under the License. |
132 | 17 | 17 | ||
133 | 18 | """Rate limiting of arbitrary actions.""" | 18 | """Rate limiting of arbitrary actions.""" |
134 | 19 | 19 | ||
135 | 20 | 20 | ||
136 | === modified file 'nova/compute/api.py' | |||
137 | --- nova/compute/api.py 2011-06-02 17:16:06 +0000 | |||
138 | +++ nova/compute/api.py 2011-06-02 21:52:56 +0000 | |||
139 | @@ -18,7 +18,6 @@ | |||
140 | 18 | 18 | ||
141 | 19 | """Handles all requests relating to instances (guest vms).""" | 19 | """Handles all requests relating to instances (guest vms).""" |
142 | 20 | 20 | ||
143 | 21 | import datetime | ||
144 | 22 | import eventlet | 21 | import eventlet |
145 | 23 | import re | 22 | import re |
146 | 24 | import time | 23 | import time |
147 | @@ -405,7 +404,7 @@ | |||
148 | 405 | instance['id'], | 404 | instance['id'], |
149 | 406 | state_description='terminating', | 405 | state_description='terminating', |
150 | 407 | state=0, | 406 | state=0, |
152 | 408 | terminated_at=datetime.datetime.utcnow()) | 407 | terminated_at=utils.utcnow()) |
153 | 409 | 408 | ||
154 | 410 | host = instance['host'] | 409 | host = instance['host'] |
155 | 411 | if host: | 410 | if host: |
156 | 412 | 411 | ||
157 | === modified file 'nova/compute/manager.py' | |||
158 | --- nova/compute/manager.py 2011-05-29 03:10:42 +0000 | |||
159 | +++ nova/compute/manager.py 2011-06-02 21:52:56 +0000 | |||
160 | @@ -35,7 +35,6 @@ | |||
161 | 35 | 35 | ||
162 | 36 | """ | 36 | """ |
163 | 37 | 37 | ||
164 | 38 | import datetime | ||
165 | 39 | import os | 38 | import os |
166 | 40 | import socket | 39 | import socket |
167 | 41 | import sys | 40 | import sys |
168 | @@ -159,7 +158,7 @@ | |||
169 | 159 | 158 | ||
170 | 160 | def _update_launched_at(self, context, instance_id, launched_at=None): | 159 | def _update_launched_at(self, context, instance_id, launched_at=None): |
171 | 161 | """Update the launched_at parameter of the given instance.""" | 160 | """Update the launched_at parameter of the given instance.""" |
173 | 162 | data = {'launched_at': launched_at or datetime.datetime.utcnow()} | 161 | data = {'launched_at': launched_at or utils.utcnow()} |
174 | 163 | self.db.instance_update(context, instance_id, data) | 162 | self.db.instance_update(context, instance_id, data) |
175 | 164 | 163 | ||
176 | 165 | def _update_image_id(self, context, instance_id, image_id): | 164 | def _update_image_id(self, context, instance_id, image_id): |
177 | 166 | 165 | ||
178 | === modified file 'nova/compute/monitor.py' | |||
179 | --- nova/compute/monitor.py 2011-04-18 23:40:03 +0000 | |||
180 | +++ nova/compute/monitor.py 2011-06-02 21:52:56 +0000 | |||
181 | @@ -86,7 +86,7 @@ | |||
182 | 86 | ]} | 86 | ]} |
183 | 87 | 87 | ||
184 | 88 | 88 | ||
186 | 89 | utcnow = datetime.datetime.utcnow | 89 | utcnow = utils.utcnow |
187 | 90 | 90 | ||
188 | 91 | 91 | ||
189 | 92 | LOG = logging.getLogger('nova.compute.monitor') | 92 | LOG = logging.getLogger('nova.compute.monitor') |
190 | 93 | 93 | ||
191 | === modified file 'nova/context.py' | |||
192 | --- nova/context.py 2011-04-20 19:08:22 +0000 | |||
193 | +++ nova/context.py 2011-06-02 21:52:56 +0000 | |||
194 | @@ -18,7 +18,6 @@ | |||
195 | 18 | 18 | ||
196 | 19 | """RequestContext: context for requests that persist through all of nova.""" | 19 | """RequestContext: context for requests that persist through all of nova.""" |
197 | 20 | 20 | ||
198 | 21 | import datetime | ||
199 | 22 | import random | 21 | import random |
200 | 23 | 22 | ||
201 | 24 | from nova import exception | 23 | from nova import exception |
202 | 25 | 24 | ||
203 | === modified file 'nova/db/sqlalchemy/api.py' | |||
204 | --- nova/db/sqlalchemy/api.py 2011-05-31 20:15:52 +0000 | |||
205 | +++ nova/db/sqlalchemy/api.py 2011-06-02 21:52:56 +0000 | |||
206 | @@ -19,7 +19,6 @@ | |||
207 | 19 | Implementation of SQLAlchemy backend. | 19 | Implementation of SQLAlchemy backend. |
208 | 20 | """ | 20 | """ |
209 | 21 | 21 | ||
210 | 22 | import datetime | ||
211 | 23 | import warnings | 22 | import warnings |
212 | 24 | 23 | ||
213 | 25 | from nova import db | 24 | from nova import db |
214 | @@ -674,7 +673,7 @@ | |||
215 | 674 | filter_by(allocated=0).\ | 673 | filter_by(allocated=0).\ |
216 | 675 | update({'instance_id': None, | 674 | update({'instance_id': None, |
217 | 676 | 'leased': 0, | 675 | 'leased': 0, |
219 | 677 | 'updated_at': datetime.datetime.utcnow()}, | 676 | 'updated_at': utils.utcnow()}, |
220 | 678 | synchronize_session='fetch') | 677 | synchronize_session='fetch') |
221 | 679 | return result | 678 | return result |
222 | 680 | 679 | ||
223 | @@ -820,17 +819,17 @@ | |||
224 | 820 | session.query(models.Instance).\ | 819 | session.query(models.Instance).\ |
225 | 821 | filter_by(id=instance_id).\ | 820 | filter_by(id=instance_id).\ |
226 | 822 | update({'deleted': True, | 821 | update({'deleted': True, |
228 | 823 | 'deleted_at': datetime.datetime.utcnow(), | 822 | 'deleted_at': utils.utcnow(), |
229 | 824 | 'updated_at': literal_column('updated_at')}) | 823 | 'updated_at': literal_column('updated_at')}) |
230 | 825 | session.query(models.SecurityGroupInstanceAssociation).\ | 824 | session.query(models.SecurityGroupInstanceAssociation).\ |
231 | 826 | filter_by(instance_id=instance_id).\ | 825 | filter_by(instance_id=instance_id).\ |
232 | 827 | update({'deleted': True, | 826 | update({'deleted': True, |
234 | 828 | 'deleted_at': datetime.datetime.utcnow(), | 827 | 'deleted_at': utils.utcnow(), |
235 | 829 | 'updated_at': literal_column('updated_at')}) | 828 | 'updated_at': literal_column('updated_at')}) |
236 | 830 | session.query(models.InstanceMetadata).\ | 829 | session.query(models.InstanceMetadata).\ |
237 | 831 | filter_by(instance_id=instance_id).\ | 830 | filter_by(instance_id=instance_id).\ |
238 | 832 | update({'deleted': True, | 831 | update({'deleted': True, |
240 | 833 | 'deleted_at': datetime.datetime.utcnow(), | 832 | 'deleted_at': utils.utcnow(), |
241 | 834 | 'updated_at': literal_column('updated_at')}) | 833 | 'updated_at': literal_column('updated_at')}) |
242 | 835 | 834 | ||
243 | 836 | 835 | ||
244 | @@ -1123,7 +1122,7 @@ | |||
245 | 1123 | session.query(models.KeyPair).\ | 1122 | session.query(models.KeyPair).\ |
246 | 1124 | filter_by(user_id=user_id).\ | 1123 | filter_by(user_id=user_id).\ |
247 | 1125 | update({'deleted': 1, | 1124 | update({'deleted': 1, |
249 | 1126 | 'deleted_at': datetime.datetime.utcnow(), | 1125 | 'deleted_at': utils.utcnow(), |
250 | 1127 | 'updated_at': literal_column('updated_at')}) | 1126 | 'updated_at': literal_column('updated_at')}) |
251 | 1128 | 1127 | ||
252 | 1129 | 1128 | ||
253 | @@ -1655,7 +1654,7 @@ | |||
254 | 1655 | session.query(models.Volume).\ | 1654 | session.query(models.Volume).\ |
255 | 1656 | filter_by(id=volume_id).\ | 1655 | filter_by(id=volume_id).\ |
256 | 1657 | update({'deleted': 1, | 1656 | update({'deleted': 1, |
258 | 1658 | 'deleted_at': datetime.datetime.utcnow(), | 1657 | 'deleted_at': utils.utcnow(), |
259 | 1659 | 'updated_at': literal_column('updated_at')}) | 1658 | 'updated_at': literal_column('updated_at')}) |
260 | 1660 | session.query(models.ExportDevice).\ | 1659 | session.query(models.ExportDevice).\ |
261 | 1661 | filter_by(volume_id=volume_id).\ | 1660 | filter_by(volume_id=volume_id).\ |
262 | @@ -1813,7 +1812,7 @@ | |||
263 | 1813 | session.query(models.Snapshot).\ | 1812 | session.query(models.Snapshot).\ |
264 | 1814 | filter_by(id=snapshot_id).\ | 1813 | filter_by(id=snapshot_id).\ |
265 | 1815 | update({'deleted': 1, | 1814 | update({'deleted': 1, |
267 | 1816 | 'deleted_at': datetime.datetime.utcnow(), | 1815 | 'deleted_at': utils.utcnow(), |
268 | 1817 | 'updated_at': literal_column('updated_at')}) | 1816 | 'updated_at': literal_column('updated_at')}) |
269 | 1818 | 1817 | ||
270 | 1819 | 1818 | ||
271 | @@ -1968,17 +1967,17 @@ | |||
272 | 1968 | session.query(models.SecurityGroup).\ | 1967 | session.query(models.SecurityGroup).\ |
273 | 1969 | filter_by(id=security_group_id).\ | 1968 | filter_by(id=security_group_id).\ |
274 | 1970 | update({'deleted': 1, | 1969 | update({'deleted': 1, |
276 | 1971 | 'deleted_at': datetime.datetime.utcnow(), | 1970 | 'deleted_at': utils.utcnow(), |
277 | 1972 | 'updated_at': literal_column('updated_at')}) | 1971 | 'updated_at': literal_column('updated_at')}) |
278 | 1973 | session.query(models.SecurityGroupInstanceAssociation).\ | 1972 | session.query(models.SecurityGroupInstanceAssociation).\ |
279 | 1974 | filter_by(security_group_id=security_group_id).\ | 1973 | filter_by(security_group_id=security_group_id).\ |
280 | 1975 | update({'deleted': 1, | 1974 | update({'deleted': 1, |
282 | 1976 | 'deleted_at': datetime.datetime.utcnow(), | 1975 | 'deleted_at': utils.utcnow(), |
283 | 1977 | 'updated_at': literal_column('updated_at')}) | 1976 | 'updated_at': literal_column('updated_at')}) |
284 | 1978 | session.query(models.SecurityGroupIngressRule).\ | 1977 | session.query(models.SecurityGroupIngressRule).\ |
285 | 1979 | filter_by(group_id=security_group_id).\ | 1978 | filter_by(group_id=security_group_id).\ |
286 | 1980 | update({'deleted': 1, | 1979 | update({'deleted': 1, |
288 | 1981 | 'deleted_at': datetime.datetime.utcnow(), | 1980 | 'deleted_at': utils.utcnow(), |
289 | 1982 | 'updated_at': literal_column('updated_at')}) | 1981 | 'updated_at': literal_column('updated_at')}) |
290 | 1983 | 1982 | ||
291 | 1984 | 1983 | ||
292 | @@ -1989,11 +1988,11 @@ | |||
293 | 1989 | with session.begin(): | 1988 | with session.begin(): |
294 | 1990 | session.query(models.SecurityGroup).\ | 1989 | session.query(models.SecurityGroup).\ |
295 | 1991 | update({'deleted': 1, | 1990 | update({'deleted': 1, |
297 | 1992 | 'deleted_at': datetime.datetime.utcnow(), | 1991 | 'deleted_at': utils.utcnow(), |
298 | 1993 | 'updated_at': literal_column('updated_at')}) | 1992 | 'updated_at': literal_column('updated_at')}) |
299 | 1994 | session.query(models.SecurityGroupIngressRule).\ | 1993 | session.query(models.SecurityGroupIngressRule).\ |
300 | 1995 | update({'deleted': 1, | 1994 | update({'deleted': 1, |
302 | 1996 | 'deleted_at': datetime.datetime.utcnow(), | 1995 | 'deleted_at': utils.utcnow(), |
303 | 1997 | 'updated_at': literal_column('updated_at')}) | 1996 | 'updated_at': literal_column('updated_at')}) |
304 | 1998 | 1997 | ||
305 | 1999 | 1998 | ||
306 | @@ -2627,7 +2626,7 @@ | |||
307 | 2627 | filter_by(key=key).\ | 2626 | filter_by(key=key).\ |
308 | 2628 | filter_by(deleted=False).\ | 2627 | filter_by(deleted=False).\ |
309 | 2629 | update({'deleted': True, | 2628 | update({'deleted': True, |
311 | 2630 | 'deleted_at': datetime.datetime.utcnow(), | 2629 | 'deleted_at': utils.utcnow(), |
312 | 2631 | 'updated_at': literal_column('updated_at')}) | 2630 | 'updated_at': literal_column('updated_at')}) |
313 | 2632 | 2631 | ||
314 | 2633 | 2632 | ||
315 | @@ -2638,7 +2637,7 @@ | |||
316 | 2638 | filter_by(instance_id=instance_id).\ | 2637 | filter_by(instance_id=instance_id).\ |
317 | 2639 | filter_by(deleted=False).\ | 2638 | filter_by(deleted=False).\ |
318 | 2640 | update({'deleted': True, | 2639 | update({'deleted': True, |
320 | 2641 | 'deleted_at': datetime.datetime.utcnow(), | 2640 | 'deleted_at': utils.utcnow(), |
321 | 2642 | 'updated_at': literal_column('updated_at')}) | 2641 | 'updated_at': literal_column('updated_at')}) |
322 | 2643 | 2642 | ||
323 | 2644 | 2643 | ||
324 | 2645 | 2644 | ||
325 | === modified file 'nova/db/sqlalchemy/migrate_repo/versions/016_make_quotas_key_and_value.py' | |||
326 | --- nova/db/sqlalchemy/migrate_repo/versions/016_make_quotas_key_and_value.py 2011-06-01 14:58:17 +0000 | |||
327 | +++ nova/db/sqlalchemy/migrate_repo/versions/016_make_quotas_key_and_value.py 2011-06-02 21:52:56 +0000 | |||
328 | @@ -17,7 +17,7 @@ | |||
329 | 17 | from sqlalchemy import Boolean, Column, DateTime, Integer | 17 | from sqlalchemy import Boolean, Column, DateTime, Integer |
330 | 18 | from sqlalchemy import MetaData, String, Table | 18 | from sqlalchemy import MetaData, String, Table |
331 | 19 | 19 | ||
333 | 20 | import datetime | 20 | from nova import utils |
334 | 21 | 21 | ||
335 | 22 | meta = MetaData() | 22 | meta = MetaData() |
336 | 23 | 23 | ||
337 | @@ -35,9 +35,9 @@ | |||
338 | 35 | return Table(name, meta, | 35 | return Table(name, meta, |
339 | 36 | Column('id', Integer(), primary_key=True), | 36 | Column('id', Integer(), primary_key=True), |
340 | 37 | Column('created_at', DateTime(), | 37 | Column('created_at', DateTime(), |
342 | 38 | default=datetime.datetime.utcnow), | 38 | default=utils.utcnow), |
343 | 39 | Column('updated_at', DateTime(), | 39 | Column('updated_at', DateTime(), |
345 | 40 | onupdate=datetime.datetime.utcnow), | 40 | onupdate=utils.utcnow), |
346 | 41 | Column('deleted_at', DateTime()), | 41 | Column('deleted_at', DateTime()), |
347 | 42 | Column('deleted', Boolean(), default=False), | 42 | Column('deleted', Boolean(), default=False), |
348 | 43 | Column('project_id', | 43 | Column('project_id', |
349 | @@ -57,9 +57,9 @@ | |||
350 | 57 | return Table(name, meta, | 57 | return Table(name, meta, |
351 | 58 | Column('id', Integer(), primary_key=True), | 58 | Column('id', Integer(), primary_key=True), |
352 | 59 | Column('created_at', DateTime(), | 59 | Column('created_at', DateTime(), |
354 | 60 | default=datetime.datetime.utcnow), | 60 | default=utils.utcnow), |
355 | 61 | Column('updated_at', DateTime(), | 61 | Column('updated_at', DateTime(), |
357 | 62 | onupdate=datetime.datetime.utcnow), | 62 | onupdate=utils.utcnow), |
358 | 63 | Column('deleted_at', DateTime()), | 63 | Column('deleted_at', DateTime()), |
359 | 64 | Column('deleted', Boolean(), default=False), | 64 | Column('deleted', Boolean(), default=False), |
360 | 65 | Column('project_id', | 65 | Column('project_id', |
361 | 66 | 66 | ||
362 | === modified file 'nova/db/sqlalchemy/models.py' | |||
363 | --- nova/db/sqlalchemy/models.py 2011-05-27 04:50:20 +0000 | |||
364 | +++ nova/db/sqlalchemy/models.py 2011-06-02 21:52:56 +0000 | |||
365 | @@ -19,8 +19,6 @@ | |||
366 | 19 | SQLAlchemy models for nova data. | 19 | SQLAlchemy models for nova data. |
367 | 20 | """ | 20 | """ |
368 | 21 | 21 | ||
369 | 22 | import datetime | ||
370 | 23 | |||
371 | 24 | from sqlalchemy.orm import relationship, backref, object_mapper | 22 | from sqlalchemy.orm import relationship, backref, object_mapper |
372 | 25 | from sqlalchemy import Column, Integer, String, schema | 23 | from sqlalchemy import Column, Integer, String, schema |
373 | 26 | from sqlalchemy import ForeignKey, DateTime, Boolean, Text | 24 | from sqlalchemy import ForeignKey, DateTime, Boolean, Text |
374 | @@ -33,6 +31,7 @@ | |||
375 | 33 | from nova import auth | 31 | from nova import auth |
376 | 34 | from nova import exception | 32 | from nova import exception |
377 | 35 | from nova import flags | 33 | from nova import flags |
378 | 34 | from nova import utils | ||
379 | 36 | 35 | ||
380 | 37 | 36 | ||
381 | 38 | FLAGS = flags.FLAGS | 37 | FLAGS = flags.FLAGS |
382 | @@ -43,8 +42,8 @@ | |||
383 | 43 | """Base class for Nova Models.""" | 42 | """Base class for Nova Models.""" |
384 | 44 | __table_args__ = {'mysql_engine': 'InnoDB'} | 43 | __table_args__ = {'mysql_engine': 'InnoDB'} |
385 | 45 | __table_initialized__ = False | 44 | __table_initialized__ = False |
388 | 46 | created_at = Column(DateTime, default=datetime.datetime.utcnow) | 45 | created_at = Column(DateTime, default=utils.utcnow) |
389 | 47 | updated_at = Column(DateTime, onupdate=datetime.datetime.utcnow) | 46 | updated_at = Column(DateTime, onupdate=utils.utcnow) |
390 | 48 | deleted_at = Column(DateTime) | 47 | deleted_at = Column(DateTime) |
391 | 49 | deleted = Column(Boolean, default=False) | 48 | deleted = Column(Boolean, default=False) |
392 | 50 | 49 | ||
393 | @@ -64,7 +63,7 @@ | |||
394 | 64 | def delete(self, session=None): | 63 | def delete(self, session=None): |
395 | 65 | """Delete this object.""" | 64 | """Delete this object.""" |
396 | 66 | self.deleted = True | 65 | self.deleted = True |
398 | 67 | self.deleted_at = datetime.datetime.utcnow() | 66 | self.deleted_at = utils.utcnow() |
399 | 68 | self.save(session=session) | 67 | self.save(session=session) |
400 | 69 | 68 | ||
401 | 70 | def __setitem__(self, key, value): | 69 | def __setitem__(self, key, value): |
402 | 71 | 70 | ||
403 | === modified file 'nova/network/manager.py' | |||
404 | --- nova/network/manager.py 2011-05-11 19:24:01 +0000 | |||
405 | +++ nova/network/manager.py 2011-06-02 21:52:56 +0000 | |||
406 | @@ -235,7 +235,7 @@ | |||
407 | 235 | inst_addr = instance_ref['mac_address'] | 235 | inst_addr = instance_ref['mac_address'] |
408 | 236 | raise exception.Error(_('IP %(address)s leased to bad mac' | 236 | raise exception.Error(_('IP %(address)s leased to bad mac' |
409 | 237 | ' %(inst_addr)s vs %(mac)s') % locals()) | 237 | ' %(inst_addr)s vs %(mac)s') % locals()) |
411 | 238 | now = datetime.datetime.utcnow() | 238 | now = utils.utcnow() |
412 | 239 | self.db.fixed_ip_update(context, | 239 | self.db.fixed_ip_update(context, |
413 | 240 | fixed_ip_ref['address'], | 240 | fixed_ip_ref['address'], |
414 | 241 | {'leased': True, | 241 | {'leased': True, |
415 | 242 | 242 | ||
416 | === modified file 'nova/notifier/api.py' | |||
417 | --- nova/notifier/api.py 2011-05-18 17:55:17 +0000 | |||
418 | +++ nova/notifier/api.py 2011-06-02 21:52:56 +0000 | |||
419 | @@ -11,9 +11,8 @@ | |||
420 | 11 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | 11 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
421 | 12 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | 12 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
422 | 13 | # License for the specific language governing permissions and limitations | 13 | # License for the specific language governing permissions and limitations |
424 | 14 | # under the License.import datetime | 14 | # under the License. |
425 | 15 | 15 | ||
426 | 16 | import datetime | ||
427 | 17 | import uuid | 16 | import uuid |
428 | 18 | 17 | ||
429 | 19 | from nova import flags | 18 | from nova import flags |
430 | @@ -64,7 +63,7 @@ | |||
431 | 64 | 63 | ||
432 | 65 | {'message_id': str(uuid.uuid4()), | 64 | {'message_id': str(uuid.uuid4()), |
433 | 66 | 'publisher_id': 'compute.host1', | 65 | 'publisher_id': 'compute.host1', |
435 | 67 | 'timestamp': datetime.datetime.utcnow(), | 66 | 'timestamp': utils.utcnow(), |
436 | 68 | 'priority': 'WARN', | 67 | 'priority': 'WARN', |
437 | 69 | 'event_type': 'compute.create_instance', | 68 | 'event_type': 'compute.create_instance', |
438 | 70 | 'payload': {'instance_id': 12, ... }} | 69 | 'payload': {'instance_id': 12, ... }} |
439 | @@ -79,5 +78,5 @@ | |||
440 | 79 | event_type=event_type, | 78 | event_type=event_type, |
441 | 80 | priority=priority, | 79 | priority=priority, |
442 | 81 | payload=payload, | 80 | payload=payload, |
444 | 82 | timestamp=str(datetime.datetime.utcnow())) | 81 | timestamp=str(utils.utcnow())) |
445 | 83 | driver.notify(msg) | 82 | driver.notify(msg) |
446 | 84 | 83 | ||
447 | === modified file 'nova/scheduler/driver.py' | |||
448 | --- nova/scheduler/driver.py 2011-04-27 21:03:05 +0000 | |||
449 | +++ nova/scheduler/driver.py 2011-06-02 21:52:56 +0000 | |||
450 | @@ -28,6 +28,7 @@ | |||
451 | 28 | from nova import flags | 28 | from nova import flags |
452 | 29 | from nova import log as logging | 29 | from nova import log as logging |
453 | 30 | from nova import rpc | 30 | from nova import rpc |
454 | 31 | from nova import utils | ||
455 | 31 | from nova.compute import power_state | 32 | from nova.compute import power_state |
456 | 32 | 33 | ||
457 | 33 | FLAGS = flags.FLAGS | 34 | FLAGS = flags.FLAGS |
458 | @@ -61,7 +62,7 @@ | |||
459 | 61 | """Check whether a service is up based on last heartbeat.""" | 62 | """Check whether a service is up based on last heartbeat.""" |
460 | 62 | last_heartbeat = service['updated_at'] or service['created_at'] | 63 | last_heartbeat = service['updated_at'] or service['created_at'] |
461 | 63 | # Timestamps in DB are UTC. | 64 | # Timestamps in DB are UTC. |
463 | 64 | elapsed = datetime.datetime.utcnow() - last_heartbeat | 65 | elapsed = utils.utcnow() - last_heartbeat |
464 | 65 | return elapsed < datetime.timedelta(seconds=FLAGS.service_down_time) | 66 | return elapsed < datetime.timedelta(seconds=FLAGS.service_down_time) |
465 | 66 | 67 | ||
466 | 67 | def hosts_up(self, context, topic): | 68 | def hosts_up(self, context, topic): |
467 | 68 | 69 | ||
468 | === modified file 'nova/scheduler/simple.py' | |||
469 | --- nova/scheduler/simple.py 2011-03-31 19:29:16 +0000 | |||
470 | +++ nova/scheduler/simple.py 2011-06-02 21:52:56 +0000 | |||
471 | @@ -21,10 +21,9 @@ | |||
472 | 21 | Simple Scheduler | 21 | Simple Scheduler |
473 | 22 | """ | 22 | """ |
474 | 23 | 23 | ||
475 | 24 | import datetime | ||
476 | 25 | |||
477 | 26 | from nova import db | 24 | from nova import db |
478 | 27 | from nova import flags | 25 | from nova import flags |
479 | 26 | from nova import utils | ||
480 | 28 | from nova.scheduler import driver | 27 | from nova.scheduler import driver |
481 | 29 | from nova.scheduler import chance | 28 | from nova.scheduler import chance |
482 | 30 | 29 | ||
483 | @@ -54,7 +53,7 @@ | |||
484 | 54 | 53 | ||
485 | 55 | # TODO(vish): this probably belongs in the manager, if we | 54 | # TODO(vish): this probably belongs in the manager, if we |
486 | 56 | # can generalize this somehow | 55 | # can generalize this somehow |
488 | 57 | now = datetime.datetime.utcnow() | 56 | now = utils.utcnow() |
489 | 58 | db.instance_update(context, instance_id, {'host': host, | 57 | db.instance_update(context, instance_id, {'host': host, |
490 | 59 | 'scheduled_at': now}) | 58 | 'scheduled_at': now}) |
491 | 60 | return host | 59 | return host |
492 | @@ -66,7 +65,7 @@ | |||
493 | 66 | if self.service_is_up(service): | 65 | if self.service_is_up(service): |
494 | 67 | # NOTE(vish): this probably belongs in the manager, if we | 66 | # NOTE(vish): this probably belongs in the manager, if we |
495 | 68 | # can generalize this somehow | 67 | # can generalize this somehow |
497 | 69 | now = datetime.datetime.utcnow() | 68 | now = utils.utcnow() |
498 | 70 | db.instance_update(context, | 69 | db.instance_update(context, |
499 | 71 | instance_id, | 70 | instance_id, |
500 | 72 | {'host': service['host'], | 71 | {'host': service['host'], |
501 | @@ -90,7 +89,7 @@ | |||
502 | 90 | 89 | ||
503 | 91 | # TODO(vish): this probably belongs in the manager, if we | 90 | # TODO(vish): this probably belongs in the manager, if we |
504 | 92 | # can generalize this somehow | 91 | # can generalize this somehow |
506 | 93 | now = datetime.datetime.utcnow() | 92 | now = utils.utcnow() |
507 | 94 | db.volume_update(context, volume_id, {'host': host, | 93 | db.volume_update(context, volume_id, {'host': host, |
508 | 95 | 'scheduled_at': now}) | 94 | 'scheduled_at': now}) |
509 | 96 | return host | 95 | return host |
510 | @@ -103,7 +102,7 @@ | |||
511 | 103 | if self.service_is_up(service): | 102 | if self.service_is_up(service): |
512 | 104 | # NOTE(vish): this probably belongs in the manager, if we | 103 | # NOTE(vish): this probably belongs in the manager, if we |
513 | 105 | # can generalize this somehow | 104 | # can generalize this somehow |
515 | 106 | now = datetime.datetime.utcnow() | 105 | now = utils.utcnow() |
516 | 107 | db.volume_update(context, | 106 | db.volume_update(context, |
517 | 108 | volume_id, | 107 | volume_id, |
518 | 109 | {'host': service['host'], | 108 | {'host': service['host'], |
519 | 110 | 109 | ||
520 | === modified file 'nova/scheduler/zone_manager.py' | |||
521 | --- nova/scheduler/zone_manager.py 2011-05-05 14:35:44 +0000 | |||
522 | +++ nova/scheduler/zone_manager.py 2011-06-02 21:52:56 +0000 | |||
523 | @@ -17,16 +17,17 @@ | |||
524 | 17 | ZoneManager oversees all communications with child Zones. | 17 | ZoneManager oversees all communications with child Zones. |
525 | 18 | """ | 18 | """ |
526 | 19 | 19 | ||
527 | 20 | import datetime | ||
528 | 20 | import novaclient | 21 | import novaclient |
529 | 21 | import thread | 22 | import thread |
530 | 22 | import traceback | 23 | import traceback |
531 | 23 | 24 | ||
532 | 24 | from datetime import datetime | ||
533 | 25 | from eventlet import greenpool | 25 | from eventlet import greenpool |
534 | 26 | 26 | ||
535 | 27 | from nova import db | 27 | from nova import db |
536 | 28 | from nova import flags | 28 | from nova import flags |
537 | 29 | from nova import log as logging | 29 | from nova import log as logging |
538 | 30 | from nova import utils | ||
539 | 30 | 31 | ||
540 | 31 | FLAGS = flags.FLAGS | 32 | FLAGS = flags.FLAGS |
541 | 32 | flags.DEFINE_integer('zone_db_check_interval', 60, | 33 | flags.DEFINE_integer('zone_db_check_interval', 60, |
542 | @@ -42,7 +43,7 @@ | |||
543 | 42 | self.name = None | 43 | self.name = None |
544 | 43 | self.capabilities = None | 44 | self.capabilities = None |
545 | 44 | self.attempt = 0 | 45 | self.attempt = 0 |
547 | 45 | self.last_seen = datetime.min | 46 | self.last_seen = datetime.datetime.min |
548 | 46 | self.last_exception = None | 47 | self.last_exception = None |
549 | 47 | self.last_exception_time = None | 48 | self.last_exception_time = None |
550 | 48 | 49 | ||
551 | @@ -56,7 +57,7 @@ | |||
552 | 56 | def update_metadata(self, zone_metadata): | 57 | def update_metadata(self, zone_metadata): |
553 | 57 | """Update zone metadata after successful communications with | 58 | """Update zone metadata after successful communications with |
554 | 58 | child zone.""" | 59 | child zone.""" |
556 | 59 | self.last_seen = datetime.now() | 60 | self.last_seen = utils.utcnow() |
557 | 60 | self.attempt = 0 | 61 | self.attempt = 0 |
558 | 61 | self.name = zone_metadata.get("name", "n/a") | 62 | self.name = zone_metadata.get("name", "n/a") |
559 | 62 | self.capabilities = ", ".join(["%s=%s" % (k, v) | 63 | self.capabilities = ", ".join(["%s=%s" % (k, v) |
560 | @@ -72,7 +73,7 @@ | |||
561 | 72 | """Something went wrong. Check to see if zone should be | 73 | """Something went wrong. Check to see if zone should be |
562 | 73 | marked as offline.""" | 74 | marked as offline.""" |
563 | 74 | self.last_exception = exception | 75 | self.last_exception = exception |
565 | 75 | self.last_exception_time = datetime.now() | 76 | self.last_exception_time = utils.utcnow() |
566 | 76 | api_url = self.api_url | 77 | api_url = self.api_url |
567 | 77 | logging.warning(_("'%(exception)s' error talking to " | 78 | logging.warning(_("'%(exception)s' error talking to " |
568 | 78 | "zone %(api_url)s") % locals()) | 79 | "zone %(api_url)s") % locals()) |
569 | @@ -104,7 +105,7 @@ | |||
570 | 104 | class ZoneManager(object): | 105 | class ZoneManager(object): |
571 | 105 | """Keeps the zone states updated.""" | 106 | """Keeps the zone states updated.""" |
572 | 106 | def __init__(self): | 107 | def __init__(self): |
574 | 107 | self.last_zone_db_check = datetime.min | 108 | self.last_zone_db_check = datetime.datetime.min |
575 | 108 | self.zone_states = {} # { <zone_id> : ZoneState } | 109 | self.zone_states = {} # { <zone_id> : ZoneState } |
576 | 109 | self.service_states = {} # { <host> : { <service> : { cap k : v }}} | 110 | self.service_states = {} # { <host> : { <service> : { cap k : v }}} |
577 | 110 | self.green_pool = greenpool.GreenPool() | 111 | self.green_pool = greenpool.GreenPool() |
578 | @@ -158,10 +159,10 @@ | |||
579 | 158 | 159 | ||
580 | 159 | def ping(self, context=None): | 160 | def ping(self, context=None): |
581 | 160 | """Ping should be called periodically to update zone status.""" | 161 | """Ping should be called periodically to update zone status.""" |
583 | 161 | diff = datetime.now() - self.last_zone_db_check | 162 | diff = utils.utcnow() - self.last_zone_db_check |
584 | 162 | if diff.seconds >= FLAGS.zone_db_check_interval: | 163 | if diff.seconds >= FLAGS.zone_db_check_interval: |
585 | 163 | logging.debug(_("Updating zone cache from db.")) | 164 | logging.debug(_("Updating zone cache from db.")) |
587 | 164 | self.last_zone_db_check = datetime.now() | 165 | self.last_zone_db_check = utils.utcnow() |
588 | 165 | self._refresh_from_db(context) | 166 | self._refresh_from_db(context) |
589 | 166 | self._poll_zones(context) | 167 | self._poll_zones(context) |
590 | 167 | 168 | ||
591 | 168 | 169 | ||
592 | === modified file 'nova/test.py' | |||
593 | --- nova/test.py 2011-05-25 22:42:49 +0000 | |||
594 | +++ nova/test.py 2011-06-02 21:52:56 +0000 | |||
595 | @@ -23,7 +23,6 @@ | |||
596 | 23 | 23 | ||
597 | 24 | """ | 24 | """ |
598 | 25 | 25 | ||
599 | 26 | import datetime | ||
600 | 27 | import functools | 26 | import functools |
601 | 28 | import os | 27 | import os |
602 | 29 | import shutil | 28 | import shutil |
603 | @@ -37,6 +36,7 @@ | |||
604 | 37 | from nova import fakerabbit | 36 | from nova import fakerabbit |
605 | 38 | from nova import flags | 37 | from nova import flags |
606 | 39 | from nova import rpc | 38 | from nova import rpc |
607 | 39 | from nova import utils | ||
608 | 40 | from nova import service | 40 | from nova import service |
609 | 41 | from nova import wsgi | 41 | from nova import wsgi |
610 | 42 | from nova.virt import fake | 42 | from nova.virt import fake |
611 | @@ -69,7 +69,7 @@ | |||
612 | 69 | # NOTE(vish): We need a better method for creating fixtures for tests | 69 | # NOTE(vish): We need a better method for creating fixtures for tests |
613 | 70 | # now that we have some required db setup for the system | 70 | # now that we have some required db setup for the system |
614 | 71 | # to work properly. | 71 | # to work properly. |
616 | 72 | self.start = datetime.datetime.utcnow() | 72 | self.start = utils.utcnow() |
617 | 73 | shutil.copyfile(os.path.join(FLAGS.state_path, FLAGS.sqlite_clean_db), | 73 | shutil.copyfile(os.path.join(FLAGS.state_path, FLAGS.sqlite_clean_db), |
618 | 74 | os.path.join(FLAGS.state_path, FLAGS.sqlite_db)) | 74 | os.path.join(FLAGS.state_path, FLAGS.sqlite_db)) |
619 | 75 | 75 | ||
620 | 76 | 76 | ||
621 | === modified file 'nova/tests/api/openstack/fakes.py' | |||
622 | --- nova/tests/api/openstack/fakes.py 2011-05-24 20:44:28 +0000 | |||
623 | +++ nova/tests/api/openstack/fakes.py 2011-06-02 21:52:56 +0000 | |||
624 | @@ -16,7 +16,6 @@ | |||
625 | 16 | # under the License. | 16 | # under the License. |
626 | 17 | 17 | ||
627 | 18 | import copy | 18 | import copy |
628 | 19 | import datetime | ||
629 | 20 | import json | 19 | import json |
630 | 21 | import random | 20 | import random |
631 | 22 | import string | 21 | import string |
632 | @@ -253,7 +252,7 @@ | |||
633 | 253 | 252 | ||
634 | 254 | @staticmethod | 253 | @staticmethod |
635 | 255 | def auth_token_create(context, token): | 254 | def auth_token_create(context, token): |
637 | 256 | fake_token = FakeToken(created_at=datetime.datetime.now(), **token) | 255 | fake_token = FakeToken(created_at=utils.utcnow(), **token) |
638 | 257 | FakeAuthDatabase.data[fake_token.token_hash] = fake_token | 256 | FakeAuthDatabase.data[fake_token.token_hash] = fake_token |
639 | 258 | FakeAuthDatabase.data['id_%i' % fake_token.id] = fake_token | 257 | FakeAuthDatabase.data['id_%i' % fake_token.id] = fake_token |
640 | 259 | return fake_token | 258 | return fake_token |
641 | 260 | 259 | ||
642 | === modified file 'nova/tests/api/openstack/test_images.py' | |||
643 | --- nova/tests/api/openstack/test_images.py 2011-05-26 17:59:25 +0000 | |||
644 | +++ nova/tests/api/openstack/test_images.py 2011-06-02 21:52:56 +0000 | |||
645 | @@ -22,7 +22,6 @@ | |||
646 | 22 | 22 | ||
647 | 23 | import copy | 23 | import copy |
648 | 24 | import json | 24 | import json |
649 | 25 | import datetime | ||
650 | 26 | import os | 25 | import os |
651 | 27 | import shutil | 26 | import shutil |
652 | 28 | import tempfile | 27 | import tempfile |
653 | 29 | 28 | ||
654 | === modified file 'nova/tests/api/openstack/test_servers.py' | |||
655 | --- nova/tests/api/openstack/test_servers.py 2011-06-01 22:46:01 +0000 | |||
656 | +++ nova/tests/api/openstack/test_servers.py 2011-06-02 21:52:56 +0000 | |||
657 | @@ -16,7 +16,6 @@ | |||
658 | 16 | # under the License. | 16 | # under the License. |
659 | 17 | 17 | ||
660 | 18 | import base64 | 18 | import base64 |
661 | 19 | import datetime | ||
662 | 20 | import json | 19 | import json |
663 | 21 | import unittest | 20 | import unittest |
664 | 22 | from xml.dom import minidom | 21 | from xml.dom import minidom |
665 | @@ -29,6 +28,7 @@ | |||
666 | 29 | from nova import exception | 28 | from nova import exception |
667 | 30 | from nova import flags | 29 | from nova import flags |
668 | 31 | from nova import test | 30 | from nova import test |
669 | 31 | from nova import utils | ||
670 | 32 | import nova.api.openstack | 32 | import nova.api.openstack |
671 | 33 | from nova.api.openstack import servers | 33 | from nova.api.openstack import servers |
672 | 34 | import nova.compute.api | 34 | import nova.compute.api |
673 | @@ -114,9 +114,9 @@ | |||
674 | 114 | "user_data": "", | 114 | "user_data": "", |
675 | 115 | "reservation_id": "", | 115 | "reservation_id": "", |
676 | 116 | "mac_address": "", | 116 | "mac_address": "", |
680 | 117 | "scheduled_at": datetime.datetime.now(), | 117 | "scheduled_at": utils.utcnow(), |
681 | 118 | "launched_at": datetime.datetime.now(), | 118 | "launched_at": utils.utcnow(), |
682 | 119 | "terminated_at": datetime.datetime.now(), | 119 | "terminated_at": utils.utcnow(), |
683 | 120 | "availability_zone": "", | 120 | "availability_zone": "", |
684 | 121 | "display_name": "server%s" % id, | 121 | "display_name": "server%s" % id, |
685 | 122 | "display_description": "", | 122 | "display_description": "", |
686 | 123 | 123 | ||
687 | === modified file 'nova/tests/test_compute.py' | |||
688 | --- nova/tests/test_compute.py 2011-05-11 19:41:39 +0000 | |||
689 | +++ nova/tests/test_compute.py 2011-06-02 21:52:56 +0000 | |||
690 | @@ -19,7 +19,6 @@ | |||
691 | 19 | Tests For Compute | 19 | Tests For Compute |
692 | 20 | """ | 20 | """ |
693 | 21 | 21 | ||
694 | 22 | import datetime | ||
695 | 23 | import mox | 22 | import mox |
696 | 24 | import stubout | 23 | import stubout |
697 | 25 | 24 | ||
698 | @@ -217,12 +216,12 @@ | |||
699 | 217 | instance_ref = db.instance_get(self.context, instance_id) | 216 | instance_ref = db.instance_get(self.context, instance_id) |
700 | 218 | self.assertEqual(instance_ref['launched_at'], None) | 217 | self.assertEqual(instance_ref['launched_at'], None) |
701 | 219 | self.assertEqual(instance_ref['deleted_at'], None) | 218 | self.assertEqual(instance_ref['deleted_at'], None) |
703 | 220 | launch = datetime.datetime.utcnow() | 219 | launch = utils.utcnow() |
704 | 221 | self.compute.run_instance(self.context, instance_id) | 220 | self.compute.run_instance(self.context, instance_id) |
705 | 222 | instance_ref = db.instance_get(self.context, instance_id) | 221 | instance_ref = db.instance_get(self.context, instance_id) |
706 | 223 | self.assert_(instance_ref['launched_at'] > launch) | 222 | self.assert_(instance_ref['launched_at'] > launch) |
707 | 224 | self.assertEqual(instance_ref['deleted_at'], None) | 223 | self.assertEqual(instance_ref['deleted_at'], None) |
709 | 225 | terminate = datetime.datetime.utcnow() | 224 | terminate = utils.utcnow() |
710 | 226 | self.compute.terminate_instance(self.context, instance_id) | 225 | self.compute.terminate_instance(self.context, instance_id) |
711 | 227 | self.context = self.context.elevated(True) | 226 | self.context = self.context.elevated(True) |
712 | 228 | instance_ref = db.instance_get(self.context, instance_id) | 227 | instance_ref = db.instance_get(self.context, instance_id) |
713 | 229 | 228 | ||
714 | === modified file 'nova/tests/test_console.py' | |||
715 | --- nova/tests/test_console.py 2011-04-04 20:17:04 +0000 | |||
716 | +++ nova/tests/test_console.py 2011-06-02 21:52:56 +0000 | |||
717 | @@ -20,8 +20,6 @@ | |||
718 | 20 | Tests For Console proxy. | 20 | Tests For Console proxy. |
719 | 21 | """ | 21 | """ |
720 | 22 | 22 | ||
721 | 23 | import datetime | ||
722 | 24 | |||
723 | 25 | from nova import context | 23 | from nova import context |
724 | 26 | from nova import db | 24 | from nova import db |
725 | 27 | from nova import exception | 25 | from nova import exception |
726 | 28 | 26 | ||
727 | === modified file 'nova/tests/test_middleware.py' | |||
728 | --- nova/tests/test_middleware.py 2011-03-18 13:56:05 +0000 | |||
729 | +++ nova/tests/test_middleware.py 2011-06-02 21:52:56 +0000 | |||
730 | @@ -16,7 +16,6 @@ | |||
731 | 16 | # License for the specific language governing permissions and limitations | 16 | # License for the specific language governing permissions and limitations |
732 | 17 | # under the License. | 17 | # under the License. |
733 | 18 | 18 | ||
734 | 19 | import datetime | ||
735 | 20 | import webob | 19 | import webob |
736 | 21 | import webob.dec | 20 | import webob.dec |
737 | 22 | import webob.exc | 21 | import webob.exc |
738 | 23 | 22 | ||
739 | === modified file 'nova/tests/test_scheduler.py' | |||
740 | --- nova/tests/test_scheduler.py 2011-05-13 01:07:54 +0000 | |||
741 | +++ nova/tests/test_scheduler.py 2011-06-02 21:52:56 +0000 | |||
742 | @@ -196,7 +196,7 @@ | |||
743 | 196 | service.topic = 'compute' | 196 | service.topic = 'compute' |
744 | 197 | service.id = kwargs['id'] | 197 | service.id = kwargs['id'] |
745 | 198 | service.availability_zone = kwargs['zone'] | 198 | service.availability_zone = kwargs['zone'] |
747 | 199 | service.created_at = datetime.datetime.utcnow() | 199 | service.created_at = utils.utcnow() |
748 | 200 | return service | 200 | return service |
749 | 201 | 201 | ||
750 | 202 | def test_with_two_zones(self): | 202 | def test_with_two_zones(self): |
751 | @@ -290,7 +290,7 @@ | |||
752 | 290 | dic['host'] = kwargs.get('host', 'dummy') | 290 | dic['host'] = kwargs.get('host', 'dummy') |
753 | 291 | s_ref = db.service_create(self.context, dic) | 291 | s_ref = db.service_create(self.context, dic) |
754 | 292 | if 'created_at' in kwargs.keys() or 'updated_at' in kwargs.keys(): | 292 | if 'created_at' in kwargs.keys() or 'updated_at' in kwargs.keys(): |
756 | 293 | t = datetime.datetime.utcnow() - datetime.timedelta(0) | 293 | t = utils.utcnow() - datetime.timedelta(0) |
757 | 294 | dic['created_at'] = kwargs.get('created_at', t) | 294 | dic['created_at'] = kwargs.get('created_at', t) |
758 | 295 | dic['updated_at'] = kwargs.get('updated_at', t) | 295 | dic['updated_at'] = kwargs.get('updated_at', t) |
759 | 296 | db.service_update(self.context, s_ref['id'], dic) | 296 | db.service_update(self.context, s_ref['id'], dic) |
760 | @@ -401,7 +401,7 @@ | |||
761 | 401 | FLAGS.compute_manager) | 401 | FLAGS.compute_manager) |
762 | 402 | compute1.start() | 402 | compute1.start() |
763 | 403 | s1 = db.service_get_by_args(self.context, 'host1', 'nova-compute') | 403 | s1 = db.service_get_by_args(self.context, 'host1', 'nova-compute') |
765 | 404 | now = datetime.datetime.utcnow() | 404 | now = utils.utcnow() |
766 | 405 | delta = datetime.timedelta(seconds=FLAGS.service_down_time * 2) | 405 | delta = datetime.timedelta(seconds=FLAGS.service_down_time * 2) |
767 | 406 | past = now - delta | 406 | past = now - delta |
768 | 407 | db.service_update(self.context, s1['id'], {'updated_at': past}) | 407 | db.service_update(self.context, s1['id'], {'updated_at': past}) |
769 | @@ -542,7 +542,7 @@ | |||
770 | 542 | def test_wont_sechedule_if_specified_host_is_down(self): | 542 | def test_wont_sechedule_if_specified_host_is_down(self): |
771 | 543 | compute1 = self.start_service('compute', host='host1') | 543 | compute1 = self.start_service('compute', host='host1') |
772 | 544 | s1 = db.service_get_by_args(self.context, 'host1', 'nova-compute') | 544 | s1 = db.service_get_by_args(self.context, 'host1', 'nova-compute') |
774 | 545 | now = datetime.datetime.utcnow() | 545 | now = utils.utcnow() |
775 | 546 | delta = datetime.timedelta(seconds=FLAGS.service_down_time * 2) | 546 | delta = datetime.timedelta(seconds=FLAGS.service_down_time * 2) |
776 | 547 | past = now - delta | 547 | past = now - delta |
777 | 548 | db.service_update(self.context, s1['id'], {'updated_at': past}) | 548 | db.service_update(self.context, s1['id'], {'updated_at': past}) |
778 | @@ -692,7 +692,7 @@ | |||
779 | 692 | dic = {'instance_id': instance_id, 'size': 1} | 692 | dic = {'instance_id': instance_id, 'size': 1} |
780 | 693 | v_ref = db.volume_create(self.context, {'instance_id': instance_id, | 693 | v_ref = db.volume_create(self.context, {'instance_id': instance_id, |
781 | 694 | 'size': 1}) | 694 | 'size': 1}) |
783 | 695 | t1 = datetime.datetime.utcnow() - datetime.timedelta(1) | 695 | t1 = utils.utcnow() - datetime.timedelta(1) |
784 | 696 | dic = {'created_at': t1, 'updated_at': t1, 'binary': 'nova-volume', | 696 | dic = {'created_at': t1, 'updated_at': t1, 'binary': 'nova-volume', |
785 | 697 | 'topic': 'volume', 'report_count': 0} | 697 | 'topic': 'volume', 'report_count': 0} |
786 | 698 | s_ref = db.service_create(self.context, dic) | 698 | s_ref = db.service_create(self.context, dic) |
787 | @@ -709,7 +709,7 @@ | |||
788 | 709 | """Confirms src-compute node is alive.""" | 709 | """Confirms src-compute node is alive.""" |
789 | 710 | instance_id = self._create_instance() | 710 | instance_id = self._create_instance() |
790 | 711 | i_ref = db.instance_get(self.context, instance_id) | 711 | i_ref = db.instance_get(self.context, instance_id) |
792 | 712 | t = datetime.datetime.utcnow() - datetime.timedelta(10) | 712 | t = utils.utcnow() - datetime.timedelta(10) |
793 | 713 | s_ref = self._create_compute_service(created_at=t, updated_at=t, | 713 | s_ref = self._create_compute_service(created_at=t, updated_at=t, |
794 | 714 | host=i_ref['host']) | 714 | host=i_ref['host']) |
795 | 715 | 715 | ||
796 | @@ -737,7 +737,7 @@ | |||
797 | 737 | """Confirms exception raises in case dest host does not exist.""" | 737 | """Confirms exception raises in case dest host does not exist.""" |
798 | 738 | instance_id = self._create_instance() | 738 | instance_id = self._create_instance() |
799 | 739 | i_ref = db.instance_get(self.context, instance_id) | 739 | i_ref = db.instance_get(self.context, instance_id) |
801 | 740 | t = datetime.datetime.utcnow() - datetime.timedelta(10) | 740 | t = utils.utcnow() - datetime.timedelta(10) |
802 | 741 | s_ref = self._create_compute_service(created_at=t, updated_at=t, | 741 | s_ref = self._create_compute_service(created_at=t, updated_at=t, |
803 | 742 | host=i_ref['host']) | 742 | host=i_ref['host']) |
804 | 743 | 743 | ||
805 | @@ -796,7 +796,7 @@ | |||
806 | 796 | # mocks for live_migration_common_check() | 796 | # mocks for live_migration_common_check() |
807 | 797 | instance_id = self._create_instance() | 797 | instance_id = self._create_instance() |
808 | 798 | i_ref = db.instance_get(self.context, instance_id) | 798 | i_ref = db.instance_get(self.context, instance_id) |
810 | 799 | t1 = datetime.datetime.utcnow() - datetime.timedelta(10) | 799 | t1 = utils.utcnow() - datetime.timedelta(10) |
811 | 800 | s_ref = self._create_compute_service(created_at=t1, updated_at=t1, | 800 | s_ref = self._create_compute_service(created_at=t1, updated_at=t1, |
812 | 801 | host=dest) | 801 | host=dest) |
813 | 802 | 802 | ||
814 | 803 | 803 | ||
815 | === modified file 'nova/utils.py' | |||
816 | --- nova/utils.py 2011-05-16 18:14:03 +0000 | |||
817 | +++ nova/utils.py 2011-06-02 21:52:56 +0000 | |||
818 | @@ -307,7 +307,7 @@ | |||
819 | 307 | 307 | ||
820 | 308 | 308 | ||
821 | 309 | def utcnow(): | 309 | def utcnow(): |
823 | 310 | """Overridable version of datetime.datetime.utcnow.""" | 310 | """Overridable version of utils.utcnow.""" |
824 | 311 | if utcnow.override_time: | 311 | if utcnow.override_time: |
825 | 312 | return utcnow.override_time | 312 | return utcnow.override_time |
826 | 313 | return datetime.datetime.utcnow() | 313 | return datetime.datetime.utcnow() |
827 | 314 | 314 | ||
828 | === modified file 'nova/virt/xenapi/fake.py' | |||
829 | --- nova/virt/xenapi/fake.py 2011-05-26 19:27:27 +0000 | |||
830 | +++ nova/virt/xenapi/fake.py 2011-06-02 21:52:56 +0000 | |||
831 | @@ -51,13 +51,13 @@ | |||
832 | 51 | """ | 51 | """ |
833 | 52 | 52 | ||
834 | 53 | 53 | ||
835 | 54 | import datetime | ||
836 | 55 | import uuid | 54 | import uuid |
837 | 56 | 55 | ||
838 | 57 | from pprint import pformat | 56 | from pprint import pformat |
839 | 58 | 57 | ||
840 | 59 | from nova import exception | 58 | from nova import exception |
841 | 60 | from nova import log as logging | 59 | from nova import log as logging |
842 | 60 | from nova import utils | ||
843 | 61 | 61 | ||
844 | 62 | 62 | ||
845 | 63 | _CLASSES = ['host', 'network', 'session', 'SR', 'VBD', | 63 | _CLASSES = ['host', 'network', 'session', 'SR', 'VBD', |
846 | @@ -540,7 +540,7 @@ | |||
847 | 540 | except Failure, exc: | 540 | except Failure, exc: |
848 | 541 | task['error_info'] = exc.details | 541 | task['error_info'] = exc.details |
849 | 542 | task['status'] = 'failed' | 542 | task['status'] = 'failed' |
851 | 543 | task['finished'] = datetime.datetime.now() | 543 | task['finished'] = utils.utcnow() |
852 | 544 | return task_ref | 544 | return task_ref |
853 | 545 | 545 | ||
854 | 546 | def _check_session(self, params): | 546 | def _check_session(self, params): |
855 | 547 | 547 | ||
856 | === modified file 'nova/volume/api.py' | |||
857 | --- nova/volume/api.py 2011-05-27 05:13:17 +0000 | |||
858 | +++ nova/volume/api.py 2011-06-02 21:52:56 +0000 | |||
859 | @@ -20,14 +20,13 @@ | |||
860 | 20 | Handles all requests relating to volumes. | 20 | Handles all requests relating to volumes. |
861 | 21 | """ | 21 | """ |
862 | 22 | 22 | ||
863 | 23 | import datetime | ||
864 | 24 | 23 | ||
865 | 25 | from nova import db | ||
866 | 26 | from nova import exception | 24 | from nova import exception |
867 | 27 | from nova import flags | 25 | from nova import flags |
868 | 28 | from nova import log as logging | 26 | from nova import log as logging |
869 | 29 | from nova import quota | 27 | from nova import quota |
870 | 30 | from nova import rpc | 28 | from nova import rpc |
871 | 29 | from nova import utils | ||
872 | 31 | from nova.db import base | 30 | from nova.db import base |
873 | 32 | 31 | ||
874 | 33 | FLAGS = flags.FLAGS | 32 | FLAGS = flags.FLAGS |
875 | @@ -78,7 +77,7 @@ | |||
876 | 78 | volume = self.get(context, volume_id) | 77 | volume = self.get(context, volume_id) |
877 | 79 | if volume['status'] != "available": | 78 | if volume['status'] != "available": |
878 | 80 | raise exception.ApiError(_("Volume status must be available")) | 79 | raise exception.ApiError(_("Volume status must be available")) |
880 | 81 | now = datetime.datetime.utcnow() | 80 | now = utils.utcnow() |
881 | 82 | self.db.volume_update(context, volume_id, {'status': 'deleting', | 81 | self.db.volume_update(context, volume_id, {'status': 'deleting', |
882 | 83 | 'terminated_at': now}) | 82 | 'terminated_at': now}) |
883 | 84 | host = volume['host'] | 83 | host = volume['host'] |
884 | 85 | 84 | ||
885 | === modified file 'nova/volume/manager.py' | |||
886 | --- nova/volume/manager.py 2011-05-27 05:13:17 +0000 | |||
887 | +++ nova/volume/manager.py 2011-06-02 21:52:56 +0000 | |||
888 | @@ -42,8 +42,6 @@ | |||
889 | 42 | 42 | ||
890 | 43 | """ | 43 | """ |
891 | 44 | 44 | ||
892 | 45 | import datetime | ||
893 | 46 | |||
894 | 47 | 45 | ||
895 | 48 | from nova import context | 46 | from nova import context |
896 | 49 | from nova import exception | 47 | from nova import exception |
897 | @@ -127,7 +125,7 @@ | |||
898 | 127 | volume_ref['id'], {'status': 'error'}) | 125 | volume_ref['id'], {'status': 'error'}) |
899 | 128 | raise | 126 | raise |
900 | 129 | 127 | ||
902 | 130 | now = datetime.datetime.utcnow() | 128 | now = utils.utcnow() |
903 | 131 | self.db.volume_update(context, | 129 | self.db.volume_update(context, |
904 | 132 | volume_ref['id'], {'status': 'available', | 130 | volume_ref['id'], {'status': 'available', |
905 | 133 | 'launched_at': now}) | 131 | 'launched_at': now}) |
lgtm
I'm assuming the changes to fake the values in the tests are being treated as a separate issue?