Merge lp:~sdqali/openstack-guest-agents/windows-agent-key-read-fix into lp:openstack-guest-agents

Proposed by sdqali
Status: Merged
Approved by: Chris Behrens
Approved revision: no longer in the source branch.
Merged at revision: 106
Proposed branch: lp:~sdqali/openstack-guest-agents/windows-agent-key-read-fix
Merge into: lp:openstack-guest-agents
Diff against target: 80 lines (+31/-10)
2 files modified
windows/xenserver/src/Rackspace.Cloud.Server.Agent.Specs/XenStoreSpec.cs (+22/-4)
windows/xenserver/src/Rackspace.Cloud.Server.Agent/XenStore.cs (+9/-6)
To merge this branch: bzr merge lp:~sdqali/openstack-guest-agents/windows-agent-key-read-fix
Reviewer Review Type Date Requested Status
Chris Behrens Pending
Review via email: mp+88308@code.launchpad.net

Description of the change

XenStore Agent ignores message keys whose files were removed by the client due to timeout. These will be reissued by the client.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'windows/xenserver/src/Rackspace.Cloud.Server.Agent.Specs/XenStoreSpec.cs'
--- windows/xenserver/src/Rackspace.Cloud.Server.Agent.Specs/XenStoreSpec.cs 2011-03-02 21:56:51 +0000
+++ windows/xenserver/src/Rackspace.Cloud.Server.Agent.Specs/XenStoreSpec.cs 2012-01-12 06:41:24 +0000
@@ -1,4 +1,7 @@
1using NUnit.Framework;1using System;
2using System.Collections.Generic;
3using NUnit.Framework;
4using Rackspace.Cloud.Server.Agent.Configuration;
2using Rackspace.Cloud.Server.Agent.Interfaces;5using Rackspace.Cloud.Server.Agent.Interfaces;
3using Rhino.Mocks;6using Rhino.Mocks;
47
@@ -17,12 +20,27 @@
17 }20 }
1821
19 [Test]22 [Test]
20 public void should_call_executable_implementation_with_the_right_parameters_when_writing_to_xenstore()23 public void Should_call_executable_implementation_with_the_right_parameters_when_writing_to_xenstore()
21 {24 {
22
23 xenStore.Write("name1", "value1");25 xenStore.Write("name1", "value1");
24
25 executable.AssertWasCalled(x => x.Run(Constants.XenClientPath, "write data/guest/name1 value1"));26 executable.AssertWasCalled(x => x.Run(Constants.XenClientPath, "write data/guest/name1 value1"));
26 }27 }
28
29 [Test]
30 public void Should_Ignore_MessageKeys_For_Which_The_File_Was_Removed()
31 {
32 var messageKey = Guid.NewGuid().ToString();
33 executable.Expect(process => process.Run(Constants.XenClientPath, "dir " + Constants.WritableDataHostBase)).Return(ExecutableResult(messageKey));
34 executable.Expect(
35 process => process.Run(Constants.XenClientPath, string.Format("read data/host/{0}", messageKey))).Return(
36 ExecutableResult(string.Format("reading data/host/{0}: The system cannot find the file specified.", messageKey)));
37 var commands = xenStore.GetCommands();
38 Assert.IsTrue(commands.Count == 0);
39 }
40
41 private static ExecutableResult ExecutableResult(string messageKey)
42 {
43 return new ExecutableResult { Output = new List<string>{messageKey} };
44 }
27 }45 }
28}46}
2947
=== modified file 'windows/xenserver/src/Rackspace.Cloud.Server.Agent/XenStore.cs'
--- windows/xenserver/src/Rackspace.Cloud.Server.Agent/XenStore.cs 2011-03-04 00:43:41 +0000
+++ windows/xenserver/src/Rackspace.Cloud.Server.Agent/XenStore.cs 2012-01-12 06:41:24 +0000
@@ -13,6 +13,7 @@
13// License for the specific language governing permissions and limitations13// License for the specific language governing permissions and limitations
14// under the License.14// under the License.
1515
16using System;
16using System.Collections.Generic;17using System.Collections.Generic;
17using Rackspace.Cloud.Server.Agent.Configuration;18using Rackspace.Cloud.Server.Agent.Configuration;
18using Rackspace.Cloud.Server.Agent.Interfaces;19using Rackspace.Cloud.Server.Agent.Interfaces;
@@ -34,16 +35,18 @@
34 var messageKeysAsUuids = Read(Constants.WritableDataHostBase).ValidateAndClean();35 var messageKeysAsUuids = Read(Constants.WritableDataHostBase).ValidateAndClean();
35 IList<Command> commands = new List<Command>();36 IList<Command> commands = new List<Command>();
3637
37 foreach (var messageKey in messageKeysAsUuids) {38 foreach (var messageKey in messageKeysAsUuids) {
38 var command = new Json<Command>().Deserialize(ReadKey(messageKey));39 var result = ReadKey(messageKey);
39 command.key = messageKey;40 if (result.Contains("The system cannot find the file specified.")) continue;
40 commands.Add(command);41 var command = new Json<Command>().Deserialize(result);
42 command.key = messageKey;
43 commands.Add(command);
41 }44 }
42
43 return commands;45 return commands;
44 }46 }
4547
46 public string ReadKey(string key) {48 public string ReadKey(string key)
49 {
47 var result = _executableProcess.Run(Constants.XenClientPath, "read " + Constants.Combine(Constants.WritableDataHostBase, key));50 var result = _executableProcess.Run(Constants.XenClientPath, "read " + Constants.Combine(Constants.WritableDataHostBase, key));
48 return result.Output.First();51 return result.Output.First();
49 }52 }

Subscribers

People subscribed via source and target branches