~cbehrens/openstack-guest-agents/lp764221

« back to all changes in this revision

Viewing changes to src/xenserver/windows/src/Rackspace.Cloud.Server.Agent.UpdaterService/Commands/AgentDownload.cs

  • Committer: Antony Messerli
  • Date: 2011-03-02 21:56:51 UTC
  • Revision ID: amesserl@rackspace.com-20110302215651-0clqh49spumg13c6
Initial commit Rackspace Windows Guest Agent

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
using System.IO;
 
2
using System.Net;
 
3
using Rackspace.Cloud.Server.Common.AgentUpdate;
 
4
using Rackspace.Cloud.Server.Common.Configuration;
 
5
using Rackspace.Cloud.Server.Common.Logging;
 
6
 
 
7
namespace Rackspace.Cloud.Server.Agent.UpdaterService.Commands {
 
8
    public interface IAgentDownload : ICommand {
 
9
    }
 
10
 
 
11
    public class AgentDownload : IAgentDownload {
 
12
        private readonly ILogger _logger;
 
13
 
 
14
        public AgentDownload(ILogger logger) {
 
15
            _logger = logger;
 
16
        }
 
17
 
 
18
        public void Execute(AgentUpdateInfo agentUpdateInfo) {
 
19
            _logger.Log("Downloading Agent ...");
 
20
 
 
21
            if (!Directory.Exists(SvcConfiguration.AgentVersionUpdatesPath))
 
22
                Directory.CreateDirectory(SvcConfiguration.AgentVersionUpdatesPath);
 
23
 
 
24
            var webClient = new WebClient();
 
25
            webClient.DownloadFile(agentUpdateInfo.url, Constants.AgentServiceReleasePackage);
 
26
 
 
27
            _logger.Log("Agent downloaded.");
 
28
        }
 
29
    }
 
30
}