Skip to content

Commit

Permalink
Fixed bug in machine inspect response parser #33
Browse files Browse the repository at this point in the history
The response for memory size is now "MemSize" instead of "Memory" in old machine. The fix copes with both types.
  • Loading branch information
Mario Toffia committed May 22, 2017
1 parent ef8f672 commit 79f4a6f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,12 @@ public void InspectDockerMachine()

var start = "test-machine".Start();
Assert.AreEqual(true, start.Success);

var inspect = "test-machine".Inspect().Data;
Assert.AreEqual(1024, inspect.MemorySizeMb);
Assert.AreEqual(20000, inspect.StorageSizeMb);
Assert.AreEqual("test-machine", inspect.Name);
Assert.AreEqual(true, inspect.RequireTls);
Assert.AreEqual("virtualbox", inspect.DriverName);
Assert.AreEqual(CommandDefaults.MachineDriver, inspect.DriverName);
Assert.AreEqual(1, inspect.CpuCount);
Assert.IsFalse(Equals(IPAddress.None, inspect.IpAddress));
Assert.IsNotNull(inspect.AuthConfig);
Expand All @@ -37,7 +36,7 @@ public void InspectDockerMachine()
}
finally
{
"test-machine".Delete(true /*force*/);
//"test-machine".Delete(true /*force*/);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Net;
using System.Linq;
using System.Net;
using Ductus.FluentDocker.Model.Containers;
using Ductus.FluentDocker.Model.Machines;
using Newtonsoft.Json;
Expand All @@ -25,12 +26,24 @@ public IProcessResponse<MachineConfiguration> Process(ProcessExecutionResult res
var ip = j["Driver"]["IPAddress"].Value<string>();
var authConfig = JsonConvert.DeserializeObject<MachineAuthConfig>(str);

int memsize = 0;
if (null != j["Driver"]["Memory"])
{
memsize = j["Driver"]["Memory"].Value<int>();
}

if (null != j["Driver"]["MemSize"])
{
memsize = j["Driver"]["MemSize"].Value<int>();
}


var config = new MachineConfiguration
{
AuthConfig = authConfig,
IpAddress = string.IsNullOrEmpty(ip) ? IPAddress.None : IPAddress.Parse(ip),
DriverName = j["DriverName"].Value<string>(),
MemorySizeMb = j["Driver"]["Memory"].Value<int>(),
MemorySizeMb = memsize,
Name = j["Name"].Value<string>(),
RequireTls = j["HostOptions"]["EngineOptions"]["TlsVerify"].Value<bool>(),
StorageSizeMb = j["Driver"]["DiskSize"].Value<int>(),
Expand Down

0 comments on commit 79f4a6f

Please sign in to comment.