151 lines
3.8 KiB
C#
151 lines
3.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Management.Automation;
|
|
using System.Management.Automation.Provider;
|
|
using Intel.Management.Mei;
|
|
using Intel.Management.Wsman;
|
|
|
|
namespace Intel.Management.Module.Amt
|
|
{
|
|
class AmtDriveInfo : DriveInfo
|
|
{
|
|
|
|
|
|
class ConfigDrive : DriveContainer
|
|
{
|
|
WsmanConnection _conn;
|
|
public ConfigDrive(WsmanConnection conn)
|
|
: base("Configuration")
|
|
{
|
|
_conn = conn;
|
|
_items = null;
|
|
}
|
|
|
|
public override ManagedItem[] GetChildItems(bool force)
|
|
{
|
|
List<ManagedItem> list = new List<ManagedItem>();
|
|
if (_items == null)
|
|
{
|
|
|
|
list.Add(new StorageAdmin(_conn).RootFolder);
|
|
|
|
_items = list.ToArray();
|
|
}
|
|
return _items;
|
|
}
|
|
}
|
|
|
|
class RootDrive : DriveContainer
|
|
{
|
|
WsmanConnection _conn;
|
|
|
|
public RootDrive(WsmanConnection conn) : base(string.Empty)
|
|
{
|
|
_conn = conn;
|
|
_items = null;
|
|
}
|
|
|
|
public override ManagedItem[] GetChildItems(bool force)
|
|
{
|
|
List<ManagedItem> list = new List<ManagedItem>();
|
|
if (_items == null)
|
|
{
|
|
list.Add(new ConfigDrive(_conn));
|
|
list.Add(new StorageManager(_conn).RootFolder);
|
|
|
|
_items = list.ToArray();
|
|
}
|
|
return _items;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public AmtDriveInfo(PSDriveInfo driveInfo,AmtDriveParameters driveParams)
|
|
: base(driveInfo)
|
|
{
|
|
WsmanConnection conn = new WsmanConnection();
|
|
|
|
|
|
string prefix = "http://";
|
|
string port=":16992";
|
|
if (driveParams.TLS.IsPresent)
|
|
{
|
|
prefix = "https://";
|
|
port = ":16993";
|
|
}
|
|
|
|
char[] splits = {':'};
|
|
string[] hostParts = driveParams.ComputerName.Split(splits);
|
|
if (hostParts.Length > 1)
|
|
{
|
|
if (hostParts[1].Equals("80") || hostParts[1].Equals("443"))
|
|
{
|
|
port = string.Empty;
|
|
}
|
|
else
|
|
{
|
|
port = ":" + hostParts[1];
|
|
}
|
|
}
|
|
|
|
|
|
conn.Address = prefix + hostParts[0] + port + "/wsman";
|
|
|
|
|
|
string user = string.Empty;
|
|
object pass = string.Empty;
|
|
|
|
if (Credential.UserName != null)
|
|
user = Credential.UserName;
|
|
if (Credential.Password != null)
|
|
pass = Credential.Password;
|
|
|
|
conn.SetCredentials(user, pass);
|
|
|
|
_root = new RootDrive(conn);
|
|
|
|
/*
|
|
|
|
List<ManagedItem> driveList = new List<ManagedItem>();
|
|
|
|
//define the admin container
|
|
StorageAdmin stgAdmin = new StorageAdmin(_conn);
|
|
|
|
|
|
ManagedItem[] adminChildren = { stgAdmin.RootFolder };
|
|
DriveContainer configContainer = new DriveContainer("Config", adminChildren);
|
|
|
|
driveList.Add(configContainer);
|
|
driveList.Add(new StorageItem(this));
|
|
|
|
if (string.Compare(driveInfo.Root,"Admin", true) == 0)
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
else if (string.Compare(driveInfo.Root, "Storage", true) == 0)
|
|
{
|
|
|
|
}
|
|
|
|
else
|
|
{
|
|
|
|
}
|
|
|
|
_root = new DriveContainer(string.Empty, driveList.ToArray());
|
|
//if (Root=
|
|
//"https://serverhame:16992/wsman"*/
|
|
}
|
|
|
|
|
|
}
|
|
}
|