forked from enolfc/caso
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix record extraction and do not request only deleted records
Commit 0058b6c introduced a bug in how we retrieve the records, since we introduced the "deleted" filter and this was filtering out all the instances that are not deleted. Moreover, the way we were retrieving the results was wrong as only servers with a changed status within the requested period were considered for the record building. We cannot use 'changes-since' in the servers.list() API query, as it will only include changes that have chanted its status after that date. Also, we cannot just get all the usages and then query the servers.get() server by server, as deleted servers are not returned by ths servers.get() call. What we do now is the following. 1.- List all the deleted servers that changed after the start date 2.- Build the records for the period [start, end] 3.- Get all the usages 4.- Iter over the usages and: 4.1.- get information for non deleted servers 4.2.- do nothing with deleted servers, as we collected in in step (2) However, usage was eventually correctly reported, as sooner or later one server may have a changed status and we will generate the record. In order to get accurate results, accounting records must be regenerated at sites, possibly month by month, like: caso-extract --extract-from 2017-01-01 --extract-to 2017-01-31 caso-extract --extract-from 2017-02-01 --extract-to 2017-02-28 (...) Closes #47
- Loading branch information
1 parent
ae6eb97
commit 2161a33
Showing
2 changed files
with
78 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
# Licensed 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. | ||
|
||
from caso.extract import nova | ||
from caso.tests import base | ||
|
||
|
||
class TestCasoManager(base.TestCase): | ||
def setUp(self): | ||
super(TestCasoManager, self).setUp() | ||
self.flags(mapping_file="etc/caso/voms.json.sample") | ||
self.extractor = nova.OpenStackExtractor() | ||
|
||
def tearDown(self): | ||
self.reset_flags() | ||
|
||
super(TestCasoManager, self).tearDown() |