예제 #1
0
 public PNetPowerShell GetPower(string hostName)
 {
     if (_power is null)
     {
         _power = new PNetPowerShell(hostName, "root", null); //remote
     }
     return(_power);
 }
예제 #2
0
        public LinuxNodeService(IOptions <HypervCsiDriverOptions> options)
        {
            _options = options.Value;

            if (string.IsNullOrEmpty(_options.HostName)) //local
            {
                _power = new PNetPowerShell();
            }
            else //remote for debug
            {
                _power = new PNetPowerShell(_options.HostName, _options.UserName, _options.KeyFile);
            }
        }
예제 #3
0
        public LinuxNodeService(IOptions <HypervCsiDriverOptions> options, ILogger <LinuxNodeService>?logger)
        {
            _logger = logger ?? (ILogger)NullLogger.Instance;

            _options = options.Value;

            if (string.IsNullOrEmpty(_options.HostName)) //local
            {
                _power = new PNetPowerShell();
            }
            else //remote for debug
            {
                _power = new PNetPowerShell(_options.HostName, _options.UserName, _options.KeyFile);
            }
        }
        public async Task redirect_stderr_from_local_native_commands()
        {
            var power = new PNetPowerShell();

            Command cmd;
            var     commands = new List <Command>(2);

            cmd = new Command("& more -? 2>&1", true);
            commands.Add(cmd);

            var results = await power.InvokeAsync(commands)
                          .ToListAsync();

            Assert.NotEmpty(results);
            Assert.Equal("Cannot access file -?", results.Last());
        }
        public async Task throw_on_errors_from_local_native_commands()
        {
            var power = new PNetPowerShell();

            Command cmd;
            var     commands = new List <Command>(2);

            cmd = new Command("& more -?", true);
            commands.Add(cmd);

            await Assert.ThrowsAsync <System.Management.Automation.RemoteException>(async() =>
            {
                var result = await power.InvokeAsync(commands).ThrowOnError()
                             .FirstOrDefaultAsync();
            });
        }
예제 #6
0
        public LinuxNodeService(string hostName, string userName, string?keyFile = null, ILogger <LinuxNodeService>?logger = null)
        {
            _logger = logger ?? (ILogger)NullLogger.Instance;

            _power = new PNetPowerShell(hostName, userName, keyFile); //remote
        }
예제 #7
0
 public HypervHost(string hostName, string userName, string keyFile = null)
 {
     _power    = new PNetPowerShell(hostName, userName, keyFile);
     _hostName = hostName;
 }
예제 #8
0
 public LinuxNodeService(string hostName, string userName, string keyFile = null)
 {
     _power = new PNetPowerShell(hostName, userName, keyFile); //remote
 }