Merge pull request #616 from huizh/CP-13072

CP-13072: HealthCheckService: Use proxy for bundle upload.
This commit is contained in:
Mihaela Stoica 2015-08-19 10:07:13 +01:00
commit f68be9d466
3 changed files with 10 additions and 5 deletions

View File

@ -101,7 +101,7 @@ namespace XenAdmin.Actions
// Upload the zip file to CIS uploading server.
var uploadUrl = string.Format("{0}{1}", UPLOAD_DOMAIN_NAME, UPLOAD_URL);
XenServerHealthCheckUpload upload = new XenServerHealthCheckUpload(uploadToken, 9, uploadUrl);
XenServerHealthCheckUpload upload = new XenServerHealthCheckUpload(uploadToken, 9, uploadUrl, null);
string uploadUuid = upload.UploadZip(bundleToUpload, cts.Token);
// Return the uuid of upload.

View File

@ -31,11 +31,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Net;
using System.Text;
using System.Web.Script.Serialization;
using XenAdmin;
using XenAdmin.Network;
namespace XenServerHealthCheck
@ -49,8 +50,9 @@ namespace XenServerHealthCheck
private int verbosityLevel;
private string uploadToken;
private IWebProxy proxy;
public XenServerHealthCheckUpload(string token, int verbosity, string uploadUrl)
public XenServerHealthCheckUpload(string token, int verbosity, string uploadUrl, IXenConnection connection)
{
uploadToken = token;
verbosityLevel = verbosity;
@ -60,6 +62,7 @@ namespace XenServerHealthCheck
{
UPLOAD_URL = uploadUrl;
}
proxy = XenAdminConfigManager.Provider.GetProxyFromSettings(connection);
}
// Request an upload and fetch the uploading id from CIS.
@ -78,6 +81,7 @@ namespace XenServerHealthCheck
request.Method = "POST";
request.ContentType = "application/json";
request.ServicePoint.Expect100Continue = false;
request.Proxy = proxy;
using (var streamWriter = new StreamWriter(request.GetRequestStream()))
{
@ -124,6 +128,7 @@ namespace XenServerHealthCheck
req.Method = "POST";
req.ContentType = "application/octet-stream";
req.Headers.Add("Authorization", "BT " + uploadToken);
req.Proxy = proxy;
using (Stream destination = req.GetRequestStream())
{

View File

@ -246,7 +246,7 @@ namespace XenServerHealthCheck
// Upload the zip file to CIS uploading server.
string upload_url = Registry.HealthCheckUploadDomainName;
log.InfoFormat("Upload report to {0}", upload_url);
XenServerHealthCheckUpload upload = new XenServerHealthCheckUpload(uploadToken, VERBOSITY_LEVEL, upload_url);
XenServerHealthCheckUpload upload = new XenServerHealthCheckUpload(uploadToken, VERBOSITY_LEVEL, upload_url, connection);
string upload_uuid = "";
try