Skip to content
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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

V3.x #86

Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,6 @@ returned package ID

## Tiles ##

+ Deployed applications on an environment at a specific moment in time
+ Deployed applications on an environment at a specific moment in time. This tile will retrieve up to 90 days worth of release version data from XL Deploy.

![image](images/XLDVersionsTile.png)
3 changes: 3 additions & 0 deletions src/main/resources/synthetic.xml
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,9 @@
required="true"/>
<property name="date" category="input" required="false"
description="Date in format yyyy-MM-dd. If not provided, latest deployed applications are shown."/>
<property name="maxDays" default="90" category="input" kind="integer" hidden="true"/>
<property name="numberOfDays" category="input" required="false" default="30" kind="integer"
description="The number of days worth of (release version) data to reterive from XL Deploy."/>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: "reterive" --> "retrieve"


</type>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
}

function createSummaryGridOptions(xldeployData) {
var filterHeaderTemplate = "<div data-ng-include=\"'partials/releases/grid/templates/name-filter-template.html'\"></div>";
var filterHeaderTemplate = `<div data-ng-include="partials/releases/grid/templates/name-filter-template.html"></div>`;
var columnDefs = [
{
displayName: "Application",
Expand Down
19 changes: 17 additions & 2 deletions src/main/resources/xlr_xldeploy/XLDVersionsTile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The 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
Copy link
Contributor

Choose a reason for hiding this comment

The 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"}
8 changes: 4 additions & 4 deletions src/main/resources/xlr_xldeploy/XLDeployClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe rename last argument from date to end_date

archived_tasks = self.query_archived_tasks(begin_date, date)
deployed_apps = {}
if archived_tasks:
tasks = json.loads(archived_tasks)
Expand Down