summaryrefslogtreecommitdiffstats
path: root/nova/api
diff options
context:
space:
mode:
authorJoe Gordon <jogo@cloudscaling.com>2012-02-29 23:06:09 -0800
committerJoe Gordon <jogo@cloudscaling.com>2012-03-01 13:22:30 -0800
commitf1bf4661ff1e1938a5bc1ef55ccec99cae4f2af7 (patch)
treed6ebd3f56debc05e6b48686f11bf1795afe92c3a /nova/api
parent04e57f169646dff5309177ce5dfa444f668bf8a1 (diff)
downloadnova-f1bf4661ff1e1938a5bc1ef55ccec99cae4f2af7.tar.gz
nova-f1bf4661ff1e1938a5bc1ef55ccec99cae4f2af7.tar.xz
nova-f1bf4661ff1e1938a5bc1ef55ccec99cae4f2af7.zip
Minor cleanup based on HACKING
Change-Id: I59f02c33c3ecb0c446755a07562060a12f85e177
Diffstat (limited to 'nova/api')
-rw-r--r--nova/api/openstack/compute/contrib/simple_tenant_usage.py22
1 files changed, 12 insertions, 10 deletions
diff --git a/nova/api/openstack/compute/contrib/simple_tenant_usage.py b/nova/api/openstack/compute/contrib/simple_tenant_usage.py
index fd1a95949..61fceb39c 100644
--- a/nova/api/openstack/compute/contrib/simple_tenant_usage.py
+++ b/nova/api/openstack/compute/contrib/simple_tenant_usage.py
@@ -15,7 +15,7 @@
# License for the specific language governing permissions and limitations
# under the License.
-from datetime import datetime
+import datetime
import urlparse
import webob
@@ -73,12 +73,12 @@ class SimpleTenantUsageController(object):
launched_at = instance['launched_at']
terminated_at = instance['terminated_at']
if terminated_at is not None:
- if not isinstance(terminated_at, datetime):
+ if not isinstance(terminated_at, datetime.datetime):
terminated_at = datetime.strptime(terminated_at,
"%Y-%m-%d %H:%M:%S.%f")
if launched_at is not None:
- if not isinstance(launched_at, datetime):
+ if not isinstance(launched_at, datetime.datetime):
launched_at = datetime.strptime(launched_at,
"%Y-%m-%d %H:%M:%S.%f")
@@ -153,7 +153,7 @@ class SimpleTenantUsageController(object):
else:
info['state'] = instance['vm_state']
- now = datetime.utcnow()
+ now = datetime.datetime.utcnow()
if info['state'] == 'terminated':
delta = info['ended_at'] - info['started_at']
@@ -188,23 +188,25 @@ class SimpleTenantUsageController(object):
return rval.values()
def _parse_datetime(self, dtstr):
- if isinstance(dtstr, datetime):
+ if isinstance(dtstr, datetime.datetime):
return dtstr
try:
- return datetime.strptime(dtstr, "%Y-%m-%dT%H:%M:%S")
+ return datetime.datetime.strptime(dtstr, "%Y-%m-%dT%H:%M:%S")
except Exception:
try:
- return datetime.strptime(dtstr, "%Y-%m-%dT%H:%M:%S.%f")
+ return datetime.datetime.strptime(dtstr,
+ "%Y-%m-%dT%H:%M:%S.%f")
except Exception:
- return datetime.strptime(dtstr, "%Y-%m-%d %H:%M:%S.%f")
+ return datetime.datetime.strptime(dtstr,
+ "%Y-%m-%d %H:%M:%S.%f")
def _get_datetime_range(self, req):
qs = req.environ.get('QUERY_STRING', '')
env = urlparse.parse_qs(qs)
period_start = self._parse_datetime(env.get('start',
- [datetime.utcnow().isoformat()])[0])
+ [datetime.datetime.utcnow().isoformat()])[0])
period_stop = self._parse_datetime(env.get('end',
- [datetime.utcnow().isoformat()])[0])
+ [datetime.datetime.utcnow().isoformat()])[0])
detailed = bool(env.get('detailed', False))
return (period_start, period_stop, detailed)