91 lines
2.6 KiB
C#
91 lines
2.6 KiB
C#
//----------------------------------------------------------------------------
|
|
//
|
|
// Copyright (c) Intel Corporation, 2010-2014 All Rights Reserved.
|
|
//
|
|
//----------------------------------------------------------------------------
|
|
|
|
using System;
|
|
using Intel.Manageability;
|
|
using Intel.Manageability.Exceptions;
|
|
using Intel.Manageability.KVM;
|
|
using Common.Utils;
|
|
using System.IO;
|
|
using System.Security;
|
|
|
|
namespace KVMSample
|
|
{
|
|
class Program
|
|
{
|
|
static void Main(string[] args)
|
|
{
|
|
IAMTInstance amt = null;
|
|
ConnectionInfoEX ci = null;
|
|
SecureString rfbPass = null;
|
|
|
|
try
|
|
{
|
|
// Check if JSON path was provided as an argument. If not, default path would be used.
|
|
try
|
|
{
|
|
ci = ProgramInput.DeserializeJsonToStruct(args.Length > 0 ? args[0] : null);
|
|
}
|
|
catch (IOException e)
|
|
{
|
|
Console.WriteLine($"Could not read argument file: {e.Message}");
|
|
return;
|
|
}
|
|
|
|
amt = AMTInstanceFactory.CreateEX(ci);
|
|
}
|
|
catch (ManageabilityException e)
|
|
{
|
|
ci?.Dispose();
|
|
Console.WriteLine(e.Message);
|
|
return;
|
|
}
|
|
|
|
try
|
|
{
|
|
// Enable KVM interface
|
|
KVMFunctionality.EnableKVMInterface(amt);
|
|
|
|
// Set the RFB password
|
|
Console.WriteLine("Setting new RFB Password \n");
|
|
rfbPass = ProgramInput.PasswordPrompt("new RFB");
|
|
try
|
|
{
|
|
KVMFunctionality.SetNewRFBPass(amt, rfbPass);
|
|
}
|
|
catch
|
|
{
|
|
rfbPass?.Dispose();
|
|
throw;
|
|
}
|
|
|
|
// Set the opt-in timeout
|
|
KVMFunctionality.SetOptInTimeout(amt, 1000);
|
|
|
|
// Set the KVM ports state
|
|
KVMFunctionality.SetPortsState(amt, KVMPortsState.EnableAllPorts);
|
|
|
|
// Set the TCP session timeout
|
|
KVMFunctionality.SetTCPSessionTimeout(amt, 100);
|
|
|
|
// Set the default monitor
|
|
KVMFunctionality.SetDefaultMonitor(amt);
|
|
|
|
// Get KVM capabilities
|
|
KVMFunctionality.DisplayCapabilities(amt);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Console.WriteLine(ex.Message);
|
|
}
|
|
finally
|
|
{
|
|
rfbPass?.Dispose();
|
|
amt?.Dispose();
|
|
}
|
|
}
|
|
}
|
|
} |