stacktach/migrations/010_populate_past_deletes.py
Manali Latkar cfab4cc6cc api to store AH event id along with send_status by yagi
Change-Id: Ied32cb88e5fbcb000c5b32f4d1190da6da3dc8ec

basic debianization

Change-Id: I1fdcb4c7040f350e034e2cfd44272a7b35178221

basic debianization

Change-Id: I8ba97fc088426b07f583c4335a695ec7a7af49b4

Making the type and null check for os_version optional according to import image_type

Change-Id: Ide512b4462d5c2d21ec1538325e5c2971b6b2934

Adding host and deployment info to missing exists entries in the nova usage audit

Change-Id: Icc1d093ab42e8164dfe98133458ede056becfaa0

Added column headers for host and deployment in json reports

Change-Id: Ic8a7b171b4f717e1a2da2e626eb5bcf1863037e1

Switched to Apache licensing

Change-Id: Ifdbc6c46d51913dacb8fca4a8f770f3f6f57f8f8

Freshen up with latest from RackerLabs (and include tox.ini)

Added instance hours report

Initial version of report to calculate unit hours used
for nova instances

Breakdown by flavor, flavor class, account/billing types and by tenant.

Moved license so script has shebang as the first line
Add tenant info cache.
Refactor Instance hr report.
Added cache table for basic tenant info for reports.
Refactor instance_hours report to use table.
Improve performance of tenant info update.

use bulk sql operations to speed up the tenant info update,
as it's taking ~40s/1000 tenants to update on a decent machine.

Fix some tests broken by rebase. Fix unittests broken by
rebase. Also, renumber migration due to collision.

Add Apache license header to new files.

Fixed bug with fetching deployment information in
reconciler. Reverted old method for fetching
current usage's deployment and added new method to
fetch latest deployment information for
a request_id.

Made the field mismatch error message more readable
Refactored nova and glance verifier tests

the exists are updated with 201 send_status as part of stacktach down repair mechanism

Revert "Fixed bug with fetching deployment information in"

Revert "Adding host and deployment info to missing exists entries in the nova usage audit"

Revert "Added column headers for host and deployment in json reports"

Only log ERROR on last retry

fixed the wrong status name for sent_failed variable in audit report

fixing documentation for urls that are not available for glance

deprecating stacky urls (usage, deletes, exists) that are not
used anymore

Revert "Revert "Added column headers for host and deployment in json reports""

Revert "Revert "Adding host and deployment info to missing exists entries in the nova usage audit""

Revert "Revert "Fixed bug with fetching deployment information in""

Cell and compute info added for verification failures as well.
If that is not present(request_id is not populated for an
InstanceUsage entry), the cells display '-'

Add tox support for move to stackforge

Add tox support for move to stackforge

Change-Id: Id94c2a7f1f9061e972e90c3f54e39c9dec11943b
2014-07-03 20:07:24 +05:30

65 lines
2.3 KiB
Python

# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
import datetime
import os
import sys
POSSIBLE_TOPDIR = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
os.pardir, os.pardir))
if os.path.exists(os.path.join(POSSIBLE_TOPDIR, 'stacktach')):
sys.path.insert(0, POSSIBLE_TOPDIR)
from django.db.models import Min
from stacktach import models
if __name__ != '__main__':
sys.exit(1)
def add_past_deletes(start, end):
exists = models.InstanceExists.objects.select_related()\
.filter(audit_period_beginning=start,
audit_period_ending=end,
deleted_at__isnull=False)
i = 0
for exist in exists:
i += 1
if models.InstanceDeletes.objects\
.filter(instance=exist.instance).count() == 0:
# No deletes found for an instance that was deleted.
values = {'instance': exist.instance,
'launched_at': exist.launched_at,
'deleted_at': exist.deleted_at}
print values
models.InstanceDeletes(**values).save()
def find_earliest_daily_audit_period_beginning():
where = 'audit_period_ending = audit_period_beginning + (60*60*24)'
query = models.InstanceExists.objects.extra(where=[where])\
.aggregate(Min('audit_period_beginning'))
return query['audit_period_beginning__min']
start = find_earliest_daily_audit_period_beginning()
end = start + (60 * 60 * 24)
add_past_deletes(start, end)