-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
V3.x #86
base: master
Are you sure you want to change the base?
V3.x #86
Changes from 5 commits
4e7018f
adedcfa
1eba431
56589bc
0caaf34
8091970
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,14 +11,29 @@ | |
|
||
from xlr_xldeploy.XLDeployClientUtil import XLDeployClientUtil | ||
|
||
import org.joda.time.DateTime | ||
import org.joda.time.format.DateTimeFormat | ||
|
||
if not xldeployServer: | ||
raise Exception("XL Deploy server ID must be provided") | ||
|
||
#check the range of values for numberOfDays, | ||
if not 1 <= numberOfDays <= maxDays: | ||
numberOfDays = maxDays | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we log something here? So that it's clear in the logs that the data was truncated? |
||
|
||
xld_client = XLDeployClientUtil.create_xldeploy_client(xldeployServer, username, password) | ||
if xld_client.check_ci_exist(environment): | ||
if date: | ||
data = xld_client.get_deployed_applications_for_environment(environment, date) | ||
#if date provided, set a begin_date based on provided date - number of days | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's now quite some duplication between the two branches... Consider refactoring it. |
||
date_obj = org.joda.time.DateTime.parse(date, org.joda.time.format.DateTimeFormat.forPattern("yyyy-MM-dd")) | ||
begin_date = date_obj.minusDays(numberOfDays) | ||
begin_date = begin_date.toString("yyyy-MM-dd") | ||
data = xld_client.get_deployed_applications_for_environment(environment, begin_date, date) | ||
else: | ||
data = xld_client.get_deployed_applications_for_environment(environment) | ||
#set the begin_date equal to today's date - number of days | ||
today = org.joda.time.DateTime() | ||
begin_date = today.minusDays(numberOfDays) | ||
begin_date = begin_date.toString("yyyy-MM-dd") | ||
data = xld_client.get_deployed_applications_for_environment(environment, begin_date) | ||
else: | ||
data = {"Invalid environment name"} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -451,18 +451,18 @@ def display_step_logs(self, task_id): | |
print "%s\n" % item.tag | ||
print "%s\n" % item.text | ||
|
||
def query_archived_tasks(self, end_date=None): | ||
def query_archived_tasks(self, begin_date, end_date=None): | ||
get_tasks = '/deployit/tasks/v2/query' | ||
if end_date: | ||
get_tasks += '?begindate=2008-01-01&enddate=%s' % end_date | ||
get_tasks += '?begindate=%s&enddate=%s' % (begin_date, end_date) | ||
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'} | ||
response = self.http_request.get(get_tasks, headers=headers) | ||
check_response(response, "Failed to get archived tasks. Server return [%s], with content [%s]" % ( | ||
response.status, response.response)) | ||
return response.getResponse() | ||
|
||
def get_deployed_applications_for_environment(self, environment, date=None): | ||
archived_tasks = self.query_archived_tasks(date) | ||
def get_deployed_applications_for_environment(self, environment, begin_date, date=None): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe rename last argument from |
||
archived_tasks = self.query_archived_tasks(begin_date, date) | ||
deployed_apps = {} | ||
if archived_tasks: | ||
tasks = json.loads(archived_tasks) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: "reterive" --> "retrieve"