Remove Commands.Omi module
This was a temporary work-around that now needs to be removed (mostly because the xUnit tests are out-of-date because we didn't have a runner, and it's not worth it to fix them). Rather than let more cruft accumulate, we need to remove it. Resolves #551
This commit is contained in:
parent
eb43300842
commit
c68164f280
|
@ -1,129 +0,0 @@
|
|||
/********************************************************************++
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
--********************************************************************/
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Management.Automation;
|
||||
|
||||
namespace Microsoft.PowerShell.Commands.Omi
|
||||
{
|
||||
#region Start-DscConfiguration
|
||||
|
||||
/// <summary>
|
||||
/// implementation for the Start-DscConfiguration command
|
||||
/// </summary>
|
||||
[Cmdlet( VerbsLifecycle.Start, "DscConfiguration" )]
|
||||
[OutputType(typeof(object))]
|
||||
public sealed class StartDscConfigurationCommand : Cmdlet
|
||||
{
|
||||
#region parameters
|
||||
|
||||
[Parameter(Mandatory = true)]
|
||||
[Alias("CM")]
|
||||
public string ConfigurationMof
|
||||
{
|
||||
get
|
||||
{
|
||||
return mofPath;
|
||||
}
|
||||
set
|
||||
{
|
||||
mofPath = value;
|
||||
}
|
||||
}
|
||||
private string mofPath;
|
||||
|
||||
#endregion
|
||||
|
||||
#region methods
|
||||
|
||||
protected override void ProcessRecord()
|
||||
{
|
||||
if (mofPath == null)
|
||||
{
|
||||
throw new ArgumentNullException();
|
||||
}
|
||||
|
||||
if (!Platform.IsLinux())
|
||||
{
|
||||
throw new PlatformNotSupportedException();
|
||||
}
|
||||
|
||||
OmiInterface oi = new OmiInterface();
|
||||
|
||||
const string nameSpace = "root/Microsoft/DesiredStateConfiguration";
|
||||
const string instanceName = "{ MSFT_DSCLocalConfigurationManager }";
|
||||
const string methodName = "SendConfigurationApply";
|
||||
|
||||
string mof = File.ReadAllText(mofPath);
|
||||
byte[] asciiBytes = Encoding.ASCII.GetBytes(mof);
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.Append(" { ConfigurationData [ ");
|
||||
foreach (byte b in asciiBytes)
|
||||
{
|
||||
sb.Append(b.ToString());
|
||||
sb.Append(' ');
|
||||
}
|
||||
sb.Append("] ");
|
||||
sb.Append("}");
|
||||
string parameters = sb.ToString();
|
||||
|
||||
string arguments = $"iv {nameSpace} {instanceName} {methodName} {parameters} -xml";
|
||||
oi.ExecuteOmiCliCommand(arguments);
|
||||
|
||||
OmiData data = oi.GetOmiData();
|
||||
object[] array = data.ToObjectArray();
|
||||
|
||||
WriteObject(array, true);
|
||||
|
||||
} // EndProcessing
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Get-DscConfiguration
|
||||
|
||||
/// <summary>
|
||||
/// implementation for the Get-DscConfiguration command
|
||||
/// </summary>
|
||||
[Cmdlet( VerbsCommon.Get, "DscConfiguration" )]
|
||||
[OutputType(typeof(object))]
|
||||
public sealed class GetDscConfigurationCommand : Cmdlet
|
||||
{
|
||||
#region methods
|
||||
|
||||
protected override void ProcessRecord()
|
||||
{
|
||||
if (!Platform.IsLinux())
|
||||
{
|
||||
throw new PlatformNotSupportedException();
|
||||
}
|
||||
|
||||
OmiInterface oi = new OmiInterface();
|
||||
|
||||
const string nameSpace = "root/Microsoft/DesiredStateConfiguration";
|
||||
const string instanceName = "{ MSFT_DSCLocalConfigurationManager }";
|
||||
const string methodName = "GetConfiguration";
|
||||
|
||||
string arguments = $"iv {nameSpace} {instanceName} {methodName} -xml";
|
||||
oi.ExecuteOmiCliCommand(arguments);
|
||||
|
||||
OmiData data = oi.GetOmiData();
|
||||
object[] array = data.ToObjectArray();
|
||||
|
||||
WriteObject(array, true);
|
||||
|
||||
} // EndProcessing
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
} // namespace Microsoft.PowerShell.Commands
|
||||
|
||||
|
|
@ -1,129 +0,0 @@
|
|||
/********************************************************************++
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
--********************************************************************/
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Management.Automation;
|
||||
|
||||
namespace Microsoft.PowerShell.Commands.Omi
|
||||
{
|
||||
#region Set-DscLocalConfigurationManager
|
||||
|
||||
/// <summary>
|
||||
/// implementation for the Set-DscLocalConfiguration command
|
||||
/// </summary>
|
||||
[Cmdlet(VerbsCommon.Set, "DscLocalConfigurationManager" )]
|
||||
[OutputType(typeof(object))]
|
||||
public sealed class SetDscLocalConfigurationManagerCommand : Cmdlet
|
||||
{
|
||||
#region parameters
|
||||
|
||||
[Parameter(Mandatory = true)]
|
||||
[Alias("CM")]
|
||||
public string ConfigurationMof
|
||||
{
|
||||
get
|
||||
{
|
||||
return mofPath;
|
||||
}
|
||||
set
|
||||
{
|
||||
mofPath = value;
|
||||
}
|
||||
}
|
||||
private string mofPath;
|
||||
|
||||
#endregion
|
||||
|
||||
#region methods
|
||||
|
||||
protected override void ProcessRecord()
|
||||
{
|
||||
if (mofPath == null)
|
||||
{
|
||||
throw new ArgumentNullException();
|
||||
}
|
||||
|
||||
if (!Platform.IsLinux())
|
||||
{
|
||||
throw new PlatformNotSupportedException();
|
||||
}
|
||||
|
||||
OmiInterface oi = new OmiInterface();
|
||||
|
||||
const string nameSpace = "root/Microsoft/DesiredStateConfiguration";
|
||||
const string instanceName = "{ MSFT_DSCLocalConfigurationManager }";
|
||||
const string methodName = "SendMetaConfigurationApply";
|
||||
|
||||
string mof = File.ReadAllText(mofPath);
|
||||
byte[] asciiBytes = Encoding.ASCII.GetBytes(mof);
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.Append(" { ConfigurationData [ ");
|
||||
foreach (byte b in asciiBytes)
|
||||
{
|
||||
sb.Append(b.ToString());
|
||||
sb.Append(' ');
|
||||
}
|
||||
sb.Append("] ");
|
||||
sb.Append("}");
|
||||
string parameters = sb.ToString();
|
||||
|
||||
string arguments = $"iv {nameSpace} {instanceName} {methodName} {parameters} -xml";
|
||||
oi.ExecuteOmiCliCommand(arguments);
|
||||
|
||||
OmiData data = oi.GetOmiData();
|
||||
object[] array = data.ToObjectArray();
|
||||
|
||||
WriteObject(array, true);
|
||||
|
||||
} // EndProcessing
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Get-DscLocalConfigurationManager
|
||||
|
||||
/// <summary>
|
||||
/// implementation for the Get-DscLocalConfigurationManager command
|
||||
/// </summary>
|
||||
[Cmdlet(VerbsCommon.Get, "DscLocalConfigurationManager" )]
|
||||
[OutputType(typeof(object))]
|
||||
public sealed class GetDscLocalConfigurationManagerCommand : Cmdlet
|
||||
{
|
||||
#region methods
|
||||
|
||||
protected override void ProcessRecord()
|
||||
{
|
||||
if (!Platform.IsLinux())
|
||||
{
|
||||
throw new PlatformNotSupportedException();
|
||||
}
|
||||
|
||||
OmiInterface oi = new OmiInterface();
|
||||
|
||||
const string nameSpace = "root/Microsoft/DesiredStateConfiguration";
|
||||
const string instanceName = "{ MSFT_DSCLocalConfigurationManager }";
|
||||
const string methodName = "GetMetaConfiguration";
|
||||
|
||||
string arguments = $"iv {nameSpace} {instanceName} {methodName} -xml";
|
||||
oi.ExecuteOmiCliCommand(arguments);
|
||||
|
||||
OmiData data = oi.GetOmiData();
|
||||
object[] array = data.ToObjectArray();
|
||||
|
||||
WriteObject(array, true);
|
||||
|
||||
} // EndProcessing
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
} // namespace Microsoft.PowerShell.Commands
|
||||
|
||||
|
|
@ -1,120 +0,0 @@
|
|||
/********************************************************************++
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
--********************************************************************/
|
||||
using System;
|
||||
using System.Xml.Linq;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Management.Automation;
|
||||
|
||||
namespace Microsoft.PowerShell.Commands.Omi
|
||||
{
|
||||
#region Get-OmiInstance
|
||||
|
||||
/// <summary>
|
||||
/// implementation for the Get-OmiInstance command
|
||||
/// </summary>
|
||||
[Cmdlet( VerbsCommon.Get, "OmiInstance" )]
|
||||
[OutputType(typeof(string))]
|
||||
[OutputType(typeof(object[]))]
|
||||
public sealed class GetOmiInstanceCommand : Cmdlet
|
||||
{
|
||||
#region parameters
|
||||
|
||||
[Parameter(Mandatory = true)]
|
||||
[Alias("NS")]
|
||||
public string Namespace
|
||||
{
|
||||
get
|
||||
{
|
||||
return nameSpace;
|
||||
}
|
||||
set
|
||||
{
|
||||
nameSpace = value;
|
||||
}
|
||||
}
|
||||
private string nameSpace;
|
||||
|
||||
[Parameter(Mandatory = true)]
|
||||
[Alias("CN")]
|
||||
public string ClassName
|
||||
{
|
||||
get
|
||||
{
|
||||
return className;
|
||||
}
|
||||
set
|
||||
{
|
||||
className = value;
|
||||
}
|
||||
}
|
||||
private string className;
|
||||
|
||||
[Parameter]
|
||||
public string Property
|
||||
{
|
||||
get
|
||||
{
|
||||
return property;
|
||||
}
|
||||
set
|
||||
{
|
||||
property = value;
|
||||
propertySpecified = true;
|
||||
}
|
||||
}
|
||||
private string property;
|
||||
private bool propertySpecified = false;
|
||||
|
||||
#endregion
|
||||
|
||||
#region methods
|
||||
|
||||
protected override void ProcessRecord()
|
||||
{
|
||||
if (nameSpace == null || className == null)
|
||||
{
|
||||
throw new ArgumentNullException();
|
||||
}
|
||||
|
||||
if (!Platform.IsLinux())
|
||||
{
|
||||
throw new PlatformNotSupportedException();
|
||||
}
|
||||
|
||||
OmiInterface oi = new OmiInterface();
|
||||
|
||||
string arguments = $"ei {nameSpace} {className} -xml";
|
||||
oi.ExecuteOmiCliCommand(arguments);
|
||||
|
||||
if (propertySpecified)
|
||||
{
|
||||
if (property == null)
|
||||
{
|
||||
throw new ArgumentNullException();
|
||||
}
|
||||
|
||||
string value;
|
||||
string type;
|
||||
oi.GetValue(className, property, out type, out value);
|
||||
|
||||
WriteObject(value);
|
||||
return;
|
||||
}
|
||||
|
||||
OmiData data = oi.GetOmiData();
|
||||
object[] array = data.ToObjectArray();
|
||||
|
||||
WriteObject(array, true);
|
||||
|
||||
} // EndProcessing
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
} // namespace Microsoft.PowerShell.Commands
|
||||
|
||||
|
|
@ -1,235 +0,0 @@
|
|||
/********************************************************************++
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
--********************************************************************/
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Management.Automation;
|
||||
|
||||
namespace Microsoft.PowerShell.Commands.Omi
|
||||
{
|
||||
internal static class Platform
|
||||
{
|
||||
internal static bool IsLinux()
|
||||
{
|
||||
return RuntimeInformation.IsOSPlatform(OSPlatform.Linux);
|
||||
}
|
||||
|
||||
internal static bool IsWindows()
|
||||
{
|
||||
return RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Data from OMI
|
||||
/// </summary>
|
||||
public class OmiData
|
||||
{
|
||||
public HashSet<string> Properties;
|
||||
public HashSet<Dictionary<string, string>> Values;
|
||||
public OmiData()
|
||||
{
|
||||
Properties = new HashSet<string>();
|
||||
Values = new HashSet<Dictionary<string, string>>();
|
||||
}
|
||||
public void Debug()
|
||||
{
|
||||
foreach (string p in Properties)
|
||||
{
|
||||
Console.Write("{0,-22}", p);
|
||||
}
|
||||
Console.WriteLine();
|
||||
|
||||
foreach (Dictionary<string, string> d in Values)
|
||||
{
|
||||
foreach (string p in Properties)
|
||||
{
|
||||
string value = String.Empty;
|
||||
if (d.ContainsKey(p))
|
||||
{
|
||||
value = Truncate(d[p], 16);
|
||||
}
|
||||
Console.Write("{0,-22}", value);
|
||||
}
|
||||
Console.WriteLine();
|
||||
}
|
||||
}
|
||||
|
||||
public Object[] ToObjectArray()
|
||||
{
|
||||
// Convert to array of objects
|
||||
ArrayList array = new ArrayList();
|
||||
foreach (Dictionary<string, string> d in Values)
|
||||
{
|
||||
PSObject o = new PSObject();
|
||||
|
||||
foreach (string p in Properties)
|
||||
{
|
||||
string value = String.Empty;
|
||||
if (d.ContainsKey(p))
|
||||
{
|
||||
value = d[p];
|
||||
}
|
||||
PSNoteProperty psp = new PSNoteProperty(p, value);
|
||||
o.Members.Add(psp);
|
||||
}
|
||||
array.Add(o);
|
||||
}
|
||||
|
||||
return (Object[])(array.ToArray());
|
||||
}
|
||||
|
||||
private string Truncate(string s, int maxChars)
|
||||
{
|
||||
return s.Length < maxChars ? s : s.Substring(0, maxChars) + " ...";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Interfaces that cmdlets can use to interface with OMI
|
||||
/// </summary>
|
||||
public class OmiInterface
|
||||
{
|
||||
private string _xmlString = null;
|
||||
|
||||
public void ExecuteOmiCliCommand(string arguments)
|
||||
{
|
||||
using (Process process = new Process())
|
||||
{
|
||||
// Assume omicli is somewhere in PATH...
|
||||
process.StartInfo.FileName = "omicli";
|
||||
process.StartInfo.Arguments = arguments;
|
||||
process.StartInfo.UseShellExecute = false;
|
||||
process.StartInfo.RedirectStandardOutput = true;
|
||||
process.StartInfo.CreateNoWindow = true;
|
||||
|
||||
process.Start();
|
||||
|
||||
string output = process.StandardOutput.ReadToEnd();
|
||||
|
||||
process.WaitForExit();
|
||||
if (process.ExitCode != 0)
|
||||
{
|
||||
throw new IOException();
|
||||
}
|
||||
|
||||
_xmlString = $"<INSTANCES>{output}</INSTANCES>";
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
public void GetValue(string className, string propertyName, out string type, out string value)
|
||||
{
|
||||
// parse xml
|
||||
XElement cim = XElement.Parse(_xmlString);
|
||||
|
||||
IEnumerable<XElement> elements =
|
||||
from el in cim.Elements("INSTANCE")
|
||||
where (string)el.Attribute("CLASSNAME") == className
|
||||
select el;
|
||||
|
||||
IEnumerable<XElement> properties =
|
||||
from el in elements.First().Elements("PROPERTY")
|
||||
where (string)el.Attribute("NAME") == propertyName
|
||||
select el;
|
||||
|
||||
XElement property = properties.First();
|
||||
XElement p = property.Element("VALUE");
|
||||
|
||||
type = (string)property.Attribute("TYPE");
|
||||
value = p.Value;
|
||||
}
|
||||
|
||||
private IEnumerable<XElement> GetValueIEnumerable()
|
||||
{
|
||||
// parse xml
|
||||
XElement cim = XElement.Parse(_xmlString);
|
||||
|
||||
IEnumerable<XElement> elements = cim.Elements();
|
||||
return elements;
|
||||
}
|
||||
|
||||
public OmiData GetOmiData()
|
||||
{
|
||||
OmiData data = new OmiData();
|
||||
|
||||
const string VALUE = "VALUE";
|
||||
const string VALUEARRAY = "VALUE.ARRAY";
|
||||
const string PROPERTY = "PROPERTY";
|
||||
const string PROPERTYARRAY = "PROPERTY.ARRAY";
|
||||
|
||||
IEnumerable<XElement> instances = GetValueIEnumerable();
|
||||
foreach (XElement instance in instances)
|
||||
{
|
||||
// First, do PROPERTY elements
|
||||
IEnumerable<XElement> properties = instance.Elements(PROPERTY);
|
||||
|
||||
foreach (XElement property in properties)
|
||||
{
|
||||
Dictionary<string, string> d = new Dictionary<string, string>();
|
||||
IEnumerable<XAttribute> attrs = property.Attributes();
|
||||
|
||||
foreach (XAttribute attr in attrs)
|
||||
{
|
||||
data.Properties.Add(attr.Name.LocalName);
|
||||
d[attr.Name.LocalName] = attr.Value;
|
||||
}
|
||||
|
||||
// Now look for "VALUE" sub-element
|
||||
IEnumerable<XElement> values = property.Elements(VALUE);
|
||||
foreach (XElement value in values)
|
||||
{
|
||||
data.Properties.Add(VALUE);
|
||||
d[VALUE] = value.Value;
|
||||
}
|
||||
|
||||
data.Values.Add(d);
|
||||
}
|
||||
|
||||
// Next, do PROPERTY.ARRAY elements
|
||||
IEnumerable<XElement> propertyArrays = instance.Elements(PROPERTYARRAY);
|
||||
foreach (XElement property in propertyArrays)
|
||||
{
|
||||
Dictionary<string, string> dCommon = new Dictionary<string, string>();
|
||||
IEnumerable<XAttribute> attrs = property.Attributes();
|
||||
|
||||
foreach (XAttribute attr in attrs)
|
||||
{
|
||||
data.Properties.Add(attr.Name.LocalName);
|
||||
dCommon[attr.Name.LocalName] = attr.Value;
|
||||
}
|
||||
|
||||
IEnumerable<XElement> valueArrays = property.Elements(VALUEARRAY);
|
||||
|
||||
if (valueArrays.Count() > 0)
|
||||
{
|
||||
foreach (XElement valueArray in valueArrays)
|
||||
{
|
||||
IEnumerable<XElement> values = valueArray.Elements(VALUE);
|
||||
foreach (XElement value in values)
|
||||
{
|
||||
Dictionary<string, string> d = new Dictionary<string, string>(dCommon);
|
||||
data.Properties.Add(VALUE);
|
||||
d[VALUE] = value.Value;
|
||||
data.Values.Add(d);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
data.Values.Add(dCommon);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
{
|
||||
"version": "1.0.0-*",
|
||||
"description": "Microsoft.PowerShell.Commands.Omi Library",
|
||||
"authors": [ "palladia", "andschwa" ],
|
||||
|
||||
"dependencies": {
|
||||
"System.Management.Automation": {
|
||||
"type": "build",
|
||||
"version": "1.0.0-*"
|
||||
}
|
||||
},
|
||||
|
||||
"frameworks": {
|
||||
"dnxcore50": {
|
||||
"dependencies": {
|
||||
"System.Xml.XDocument": "4.0.11-rc3-23729"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
# Note that omicli must be in PATH and omiserver should be started with
|
||||
# --ignoreAuthentication option
|
||||
|
||||
Describe "Get-OmiInstance" {
|
||||
Import-Module Microsoft.PowerShell.Commands.Omi
|
||||
|
||||
It "Should execute basic command correctly" {
|
||||
$instance = Get-OmiInstance -NameSpace root/omi -ClassName OMI_Identify
|
||||
|
||||
# This test is a workaround
|
||||
$instance.Value.Contains("OMI") | Should Be $true
|
||||
|
||||
# TODO: test these when available
|
||||
#$instance.ProductName | Should Be "OMI"
|
||||
#$instance.ProductVendor | Should Be "Microsoft"
|
||||
#$instance.OperatingSystem | Should Be "LINUX"
|
||||
}
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
# Note that omicli must be in PATH and omiserver should be started with
|
||||
# --ignoreAuthentication option
|
||||
|
||||
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||
$mof = "$here/sample.mof"
|
||||
$mofCleanup = "$here/sample-cleanup.mof"
|
||||
$mofMeta = "$here/sampleMeta.mof"
|
||||
$file = "/tmp/linux.txt"
|
||||
|
||||
Describe "DscConfiguration" {
|
||||
Import-Module Microsoft.PowerShell.Commands.Omi
|
||||
|
||||
It "Should create file per sample MOF file" {
|
||||
$s = Start-DscConfiguration -ConfigurationMof $mof |
|
||||
Where-Object {$_.NAME -eq "ReturnValue"}
|
||||
$s.VALUE | Should Be "0"
|
||||
$file | Should Exist
|
||||
}
|
||||
|
||||
It "Should get DSC configuration successfully" {
|
||||
$s = Get-DscConfiguration | Where-Object {$_.NAME -eq "ReturnValue"}
|
||||
$s.VALUE | Should Be "0"
|
||||
}
|
||||
|
||||
It "Should remove temp file just created" {
|
||||
$s = Start-DscConfiguration -ConfigurationMof $mofCleanup |
|
||||
Where-Object {$_.NAME -eq "ReturnValue"}
|
||||
$s.VALUE | Should Be "0"
|
||||
$file | Should Not Exist
|
||||
}
|
||||
|
||||
It "Should set Meta MOF file properly" {
|
||||
$s = Set-DscLocalConfigurationManager -ConfigurationMof $mofMeta |
|
||||
Where-Object {$_.NAME -eq "ReturnValue"}
|
||||
$s.VALUE | Should Be "0"
|
||||
}
|
||||
|
||||
It "Should get DSC local configuration successfully" {
|
||||
$s = Get-DscLocalConfigurationManager | Where-Object {$_.NAME -eq "ReturnValue"}
|
||||
$s.VALUE | Should Be "0"
|
||||
}
|
||||
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
instance of MSFT_nxFileResource
|
||||
{
|
||||
Contents = "my contents";
|
||||
DestinationPath = "/tmp/linux.txt";
|
||||
Ensure = "Absent";
|
||||
Type = "File";
|
||||
ResourceId = "[MSFT_nxFileResource]File1";
|
||||
ModuleName = "nx";
|
||||
ModuleVersion = "1.0";
|
||||
|
||||
|
||||
};
|
||||
|
||||
instance of OMI_ConfigurationDocument
|
||||
{
|
||||
Version="1.0.0";
|
||||
|
||||
};
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
instance of MSFT_nxFileResource
|
||||
{
|
||||
Contents = "my contents";
|
||||
DestinationPath = "/tmp/linux.txt";
|
||||
Ensure = "Present";
|
||||
Type = "File";
|
||||
Owner = "root";
|
||||
Group = "root";
|
||||
Mode = "644";
|
||||
ResourceId = "[MSFT_nxFileResource]File1";
|
||||
ModuleName = "nx";
|
||||
ModuleVersion = "1.0";
|
||||
|
||||
|
||||
};
|
||||
|
||||
instance of OMI_ConfigurationDocument
|
||||
{
|
||||
Version="1.0.0";
|
||||
|
||||
};
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
/*
|
||||
@TargetNode='10.199.192.181'
|
||||
@GeneratedBy=johnkord
|
||||
@GenerationDate=01/15/2015 14:34:29
|
||||
@GenerationHost=JKORDIC-1
|
||||
*/
|
||||
|
||||
|
||||
instance of MSFT_DSCMetaConfiguration as $MSFT_DSCMetaConfiguration1ref
|
||||
{
|
||||
DownloadManagerName = "WebDownloadManager";
|
||||
RefreshMode = "Push";
|
||||
ConfigurationMode = "ApplyAndAutoCorrect";
|
||||
|
||||
};
|
||||
|
||||
instance of OMI_ConfigurationDocument
|
||||
{
|
||||
Version="1.0.0";
|
||||
Author="johnkord";
|
||||
GenerationDate="01/15/2015 14:34:29";
|
||||
GenerationHost="JKORDIC-1";
|
||||
};
|
||||
|
|
@ -14,10 +14,6 @@
|
|||
"type": "build",
|
||||
"version": "1.0.0-*"
|
||||
},
|
||||
"Microsoft.PowerShell.Commands.Omi": {
|
||||
"type": "build",
|
||||
"version": "1.0.0-*"
|
||||
},
|
||||
"Microsoft.PowerShell.Commands.Utility": {
|
||||
"type": "build",
|
||||
"version": "1.0.0-*"
|
||||
|
|
|
@ -1,71 +0,0 @@
|
|||
using Xunit;
|
||||
using System;
|
||||
using System.Management.Automation;
|
||||
using System.Diagnostics;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace PSTests
|
||||
{
|
||||
public static class OmiInterfaceTests
|
||||
{
|
||||
[Fact]
|
||||
public static void TestHostName()
|
||||
{
|
||||
const string ns = "root/omi";
|
||||
const string cn = "OMI_Identify";
|
||||
const string property = "SystemName";
|
||||
|
||||
string expected = null;
|
||||
|
||||
var startInfo = new ProcessStartInfo
|
||||
{
|
||||
FileName = @"/usr/bin/env",
|
||||
Arguments = "hostname",
|
||||
RedirectStandardOutput = true,
|
||||
UseShellExecute = false
|
||||
};
|
||||
using (Process process = Process.Start(startInfo))
|
||||
{
|
||||
// Get output of call to hostname without trailing newline
|
||||
expected = process.StandardOutput.ReadToEnd().Trim();
|
||||
process.WaitForExit();
|
||||
|
||||
// The process should return an exit code of 0 on success
|
||||
Assert.Equal(0, process.ExitCode);
|
||||
}
|
||||
|
||||
string value = null;
|
||||
OmiInterface oi = new OmiInterface();
|
||||
oi.GetOmiValue(ns, cn, property, out value);
|
||||
Assert.Equal(expected, value);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public static void TestXHugeNumberEnumerable()
|
||||
{
|
||||
const string ns = "interop";
|
||||
const string cn = "X_HugeNumber";
|
||||
|
||||
OmiInterface oi = new OmiInterface();
|
||||
IEnumerable<XElement> elements;
|
||||
oi.GetOmiValues(ns, cn, out elements);
|
||||
Assert.True(elements.FirstOrDefault() != null);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public static void TestXHugeNumberOmiData()
|
||||
{
|
||||
const string ns = "interop";
|
||||
const string cn = "X_HugeNumber";
|
||||
|
||||
OmiInterface oi = new OmiInterface();
|
||||
|
||||
OmiData data;
|
||||
oi.GetOmiValues(ns, cn, out data);
|
||||
Assert.True(data != null);
|
||||
Assert.Equal(data.Values.Count(), 22);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue