get container
This commit is contained in:
parent
57ba7f9148
commit
ae9b826c45
7 changed files with 141 additions and 0 deletions
44
Connection/Connect.cs
Normal file
44
Connection/Connect.cs
Normal file
|
@ -0,0 +1,44 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Management.Automation;
|
||||
using System.Management.Automation.Runspaces;
|
||||
|
||||
namespace FrostFS.Powershell.Connection
|
||||
{
|
||||
[Cmdlet(VerbsCommunications.Connect, "FrostFSNode")]
|
||||
[OutputType(typeof(Connection))]
|
||||
public class ConnectCmdlet : PSCmdlet
|
||||
{
|
||||
[Parameter(Mandatory = true)]
|
||||
public string Endpoint { get; set; }
|
||||
|
||||
[Parameter(Mandatory = true)]
|
||||
public string KeyPath { get; set; }
|
||||
|
||||
protected override void ProcessRecord()
|
||||
{
|
||||
try
|
||||
{
|
||||
var keyData = File.ReadAllText(KeyPath);
|
||||
var client = FrostFS.SDK.ClientV2.Client.GetInstance(keyData, Endpoint);
|
||||
WriteObject(new Connection
|
||||
{
|
||||
Client = client,
|
||||
Host = Endpoint
|
||||
});
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
WriteError(new ErrorRecord(e, "", ErrorCategory.InvalidOperation, this));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class Connection
|
||||
{
|
||||
internal FrostFS.SDK.ClientV2.Interfaces.IFrostFSClient Client { get; set; }
|
||||
|
||||
public string Host { get; internal set; }
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue