private static async Task Main(string[] args) { Console.WriteLine("Hello World!"); var resultstr = Environment.GetFolderPath(Environment.SpecialFolder.Personal); var file = File.ReadAllText(resultstr + "\\pass\\doc2.txt").Trim(); var sp = file.Split(';'); var con = GetConnection(sp); var client = new OmvHttpService(null, con); client.SetHandlers(new NewtonsoftJsonSerializer(LocalJsonConverter.Singleton)); if (await client.LoginAsync(sp[0], sp[1])) { var objTest = new OmvSystemClient(client); var result = await objTest.GetSystemInformations(); var filesystem = new OmvFileSystemMgmtClient(client); var resultfile = await filesystem.GetFilesystems(); var omvExecClient = new OmvExecClient(client); var GetCandidatesBgstring = await filesystem.GetCandidatesBg(); var output = new Output <string>(); do { await Task.Delay(TimeSpan.FromSeconds(3)); output = await omvExecClient.GetOutput <string>(GetCandidatesBgstring, 0); } while (output.Running); } Console.ReadKey(); }
public async Task GetSystemInformations() { var logger = new Mock <ILogger>(); var rpc = new OmvHttpService(logger.Object, new LocalIHttpClient()); var systemClient = new OmvSystemClient(rpc); Assert.IsNotNull(systemClient); var obj = await systemClient.GetSystemInformations(); Assert.IsFalse(obj.ConfigDirty); Assert.AreEqual("Intel(R) Celeron(R) CPU J3455 @ 1.50GHz", obj.CpuModelName); Assert.AreEqual(0.9900990099009901d, obj.CpuUsage); Assert.AreEqual("openmediavault.local", obj.Hostname); Assert.AreEqual("Linux 5.10.0-7-amd64", obj.Kernel); Assert.IsFalse(obj.LegacyMode); //Assert.AreEqual("", obj.LoadAverage); Assert.AreEqual(1023819776L, obj.MemTotal); Assert.AreEqual(120344576L, obj.MemUsed); Assert.IsTrue(obj.PkgUpdatesAvailable); Assert.IsFalse(obj.RebootRequired); Assert.AreEqual("6.0-16 (Shaitan)", obj.Version); //Assert.AreEqual("", obj.Uptime); Assert.AreEqual(1628067143L, obj.Ts); Assert.AreEqual("Wed 04 Aug 2021 10:52:23 AM CEST", obj.Time); }
public async Task GetSystemInformationsV5() { var rpcClient = new Mock <IRpcClient>(); //rpcClient.Setup(c => c.ExecuteTaskAsync<object>(It.Is<IRpcRequest>(t => t.Method == "getInformation"))) // .ReturnsAsync("Usul"); //rpcClient.SetupSequence(c => c.ExecuteTaskAsync<object>(It.IsAny<IRpcRequest>())) // .ReturnsAsync("Usul") // .ReturnsAsync(new OMVInformations()); // rpcClient.Setup(c => c.ExecuteTaskAsync<It.IsSubtype<OMVInformations>(It.Is<IRpcRequest>(t => t.Method == "getInformation"))) // .ReturnsAsync("Usul"); rpcClient.Setup(c => c.ExecuteTaskAsync <object>(It.Is <IRpcRequest>(t => t.Method == "getInformation"))) .ReturnsAsync(OMVVersions.Usul); rpcClient.Setup(c => c.ExecuteTaskAsync <OMVInformations>(It.Is <IRpcRequest>(t => t.Method == "getInformation"))) .ReturnsAsync(new OMVInformations()); var obj = new OmvSystemClient(rpcClient.Object); Assert.IsNotNull(obj); obj.SetOMVVersion(OMVVersions.Version5); var result = await obj.GetSystemInformations(); Assert.IsNotNull(result); }
public async Task GetSystemInformationsV6() { var rpcClient = new Mock <IRpcClient>(); rpcClient.Setup(c => c.ExecuteTaskAsync <object>(It.Is <IRpcRequest>(t => t.Method == "getInformation"))) .ReturnsAsync(OMVVersions.Shaitan); rpcClient.Setup(c => c.ExecuteTaskAsync <Doods.Openmediavault.Rpc.Std.Data.V6.OMVInformations>(It.Is <IRpcRequest>(t => t.Method == "getInformation"))) .ReturnsAsync(new Doods.Openmediavault.Rpc.Std.Data.V6.OMVInformations()); var obj = new OmvSystemClient(rpcClient.Object); Assert.IsNotNull(obj); obj.SetOMVVersion(OMVVersions.Version6); var result = await obj.GetSystemInformations(); Assert.IsNotNull(result); }
public Task <OMVInformations> GetSystemInformations() { return(_omvSystemClient.GetSystemInformations()); }
public async Task GetSystemInformationsV4() { var rpcClient = new Mock <IRpcClient>(); var slt = new List <SystemInformation>(); var info = new SystemInformation(); info.Name = "ts"; info.Value = (ValueUnion)"1000"; slt.Add(info); info = new SystemInformation(); info.Name = "System time"; info.Value = (ValueUnion)"System_time_string"; slt.Add(info); info = new SystemInformation(); info.Name = "Hostname"; info.Value = (ValueUnion)"Hostname_string"; slt.Add(info); info = new SystemInformation(); info.Name = "Version"; info.Value = (ValueUnion)"Version_string"; slt.Add(info); info = new SystemInformation(); info.Name = "Processor"; info.Value = (ValueUnion)"Processor_string"; slt.Add(info); info = new SystemInformation(); info.Name = "MemTotal"; info.Value = (ValueUnion)"2000"; slt.Add(info); info = new SystemInformation(); info.Name = "Kernel"; info.Value = (ValueUnion)"Kernel_string"; slt.Add(info); info = new SystemInformation(); info.Name = "Uptime"; info.Value = (ValueUnion)"Uptime_string"; slt.Add(info); info = new SystemInformation(); info.Name = "Load average"; info.Value = (ValueUnion)"Load_average_string"; slt.Add(info); info = new SystemInformation(); info.Name = "configDirty"; info.Value = (ValueUnion)"true"; slt.Add(info); info = new SystemInformation(); info.Name = "rebootRequired"; info.Value = (ValueUnion)"false"; slt.Add(info); info = new SystemInformation(); info.Name = "pkgUpdatesAvailable"; info.Value = (ValueUnion)"true"; slt.Add(info); //rpcClient.Setup(c => c.ExecuteTaskAsync<IEnumerable<SystemInformation>>(It.IsAny<IRpcRequest>())) // .ReturnsAsync(slt); //rpcClient.Setup(c => c.ExecuteTaskAsync<IEnumerable<SystemInformation>>(It.IsAny<IRpcRequest>())) // .ReturnsAsync(slt); rpcClient.Setup(c => c.ExecuteTaskAsync <object>(It.Is <IRpcRequest>(t => t.Method == "getInformation"))) .ReturnsAsync(OMVVersions.Arrakis); rpcClient.Setup(c => c.ExecuteTaskAsync <IEnumerable <SystemInformation> > (It.IsAny <IRpcRequest>())) .ReturnsAsync(slt); //rpcClient.Setup(c => c.ExecuteTaskAsync<object>(It.Is<IRpcRequest>(t => t.Method == "getInformation"))) // .ReturnsAsync("Arrakis"); var obj = new OmvSystemClient(rpcClient.Object); Assert.IsNotNull(obj); obj.SetOMVVersion(OMVVersions.Version4); var result = await obj.GetSystemInformations(); Assert.IsNotNull(result); }