Beispiel #1
0
        /// <summary>
        /// Execution Entry point
        /// Individual function differences separated into delagate methods.
        /// </summary>
        /// <param name="device"></param>
        /// <param name="assetInfo"></param>
        /// <param name="pluginExecutionData"></param>
        /// <returns></returns>
        public bool ExecuteJob(JediDevice device, AssetInfo assetInfo, PluginExecutionData pluginExecutionData)
        {
            Type type   = typeof(ProtocolSettingsData);
            bool result = true;
            Dictionary <string, object> properties = new Dictionary <string, object>();

            //we have to set SnmpV1V2 to read/write else this won't work.
            SetSnmpReadWrite(device);

            foreach (PropertyInfo prop in type.GetProperties().Where(x => x.PropertyType == typeof(DataPair <string>)))
            {
                properties.Add(prop.Name, prop.GetValue(this));
            }

            foreach (var item in properties)
            {
                switch (item.Key)
                {
                case "P9100":
                {
                    result &= SetProtocolDefaultValues("1.3.6.1.4.1.11.2.4.3.7.24.0", (DataPair <string>)item.Value, device, assetInfo, "P9100", pluginExecutionData);
                }
                break;

                case "Lpd":
                {
                    result &= SetProtocolDefaultValues("1.3.6.1.4.1.11.2.4.3.7.22.0", (DataPair <string>)item.Value, device, assetInfo, "Lpd", pluginExecutionData);
                }
                break;

                case "WSPrint":
                {
                    result &= SetProtocolDefaultValues("1.3.6.1.4.1.11.2.4.3.7.37.0", (DataPair <string>)item.Value, device, assetInfo, "WSPrint", pluginExecutionData);
                }
                break;

                case "Ftp":
                {
                    result &= SetProtocolDefaultValues("1.3.6.1.4.1.11.2.4.3.7.20.0", (DataPair <string>)item.Value, device, assetInfo, "Ftp", pluginExecutionData);
                }
                break;

                case "Slp":
                {
                    result &= SetProtocolDefaultValues("1.3.6.1.4.1.11.2.4.3.7.21.0", (DataPair <string>)item.Value, device, assetInfo, "Slp", pluginExecutionData);
                }
                break;

                case "Bonjour":
                {
                    result &= SetProtocolDefaultValues("1.3.6.1.4.1.11.2.4.3.7.29.0", (DataPair <string>)item.Value, device, assetInfo, "Bonjour", pluginExecutionData);
                }
                break;

                case "MultiCast":
                {
                    result &= SetProtocolDefaultValues("1.3.6.1.4.1.11.2.4.3.7.30.0", (DataPair <string>)item.Value, device, assetInfo, "MultiCast", pluginExecutionData);
                }
                break;

                case "WSDiscovery":
                {
                    result &= SetProtocolDefaultValues("1.3.6.1.4.1.11.2.4.3.7.36.0", (DataPair <string>)item.Value, device, assetInfo, "WSDiscovery", pluginExecutionData);
                }
                break;

                case "Llmnr":
                {
                    result &= SetProtocolDefaultValues("1.3.6.1.4.1.11.2.4.3.7.38.0", (DataPair <string>)item.Value, device, assetInfo, "Llmnr", pluginExecutionData);
                }
                break;

                case "WinsPort":
                {
                    result &= SetProtocolDefaultValues("1.3.6.1.4.1.11.2.4.3.7.41.0", (DataPair <string>)item.Value, device, assetInfo, "WinsPort", pluginExecutionData);
                }
                break;

                case "WinsRegistration":
                {
                    result &= SetProtocolDefaultValues("1.3.6.1.4.1.11.2.4.3.7.42.0", (DataPair <string>)item.Value, device, assetInfo, "WinsRegistration", pluginExecutionData);
                }
                break;

                case "Telnet":
                {
                    result &= SetProtocolDefaultValues("1.3.6.1.4.1.11.2.4.3.7.19.0", (DataPair <string>)item.Value, device, assetInfo, "Telnet", pluginExecutionData);
                }
                break;

                case "Tftp":
                {
                    result &= SetProtocolDefaultValues("1.3.6.1.4.1.11.2.4.3.7.44.0", (DataPair <string>)item.Value, device, assetInfo, "Tftp", pluginExecutionData);
                }
                break;
                }
            }

            return(result);
        }
Beispiel #2
0
        public bool SetAutoRecoveryMode(DataPair <string> pair, JediDevice device, AssetInfo assetInfo, string fieldChanged, PluginExecutionData data)
        {
            string activityUrn = "urn:hp:imaging:con:service:systemconfiguration:SystemConfigurationService:DeviceInformation";
            string endpoint    = "systemconfiguration";

            Func <WebServiceTicket, WebServiceTicket> change = n =>
            {
                string enabled = pair.Key == "true" ? "enabled" : "disabled";
                n.FindElement("AutoRestartAfterUnrecoverableFirmwareFault").SetValue(enabled);
                return(n);
            };

            return(UpdateField(change, device, pair, activityUrn, endpoint, assetInfo, fieldChanged, data));
        }
Beispiel #3
0
        public bool UpdateWithOid <T>(Action <T> oidUsed, JediDevice device, DataPair <T> pair, AssetInfo assetInfo, string fieldChanged, PluginExecutionData pluginData)
        {
            if (pair.Value)
            {
                JavaScriptSerializer serializer = new JavaScriptSerializer();
                bool success = true;
                DeviceConfigResultLog log = new DeviceConfigResultLog(pluginData, assetInfo.AssetId);
                try
                {
                    var snmpData = GetCdm(device); //incase we have issues with endpoint, it is better to fail the setting than to abruptly stop the execution of the plugin
                    if (!string.IsNullOrEmpty(snmpData))
                    {
                        var objectGraph = serializer.DeserializeObject(snmpData) as Dictionary <string, object>;
                        var snmpEnabled = (string)objectGraph["snmpv1v2Enabled"];
                        if (snmpEnabled == "true")
                        {
                            var accessOption = (string)objectGraph["accessOption"];

                            //We need to change from read only
                            if (accessOption == "readOnly")
                            {
                                string jsonContent =
                                    @"{""snmpv1v2Enabled"": ""true"",""accessOption"": ""readWrite"",""readOnlyPublicAllowed"": ""true"",""readOnlyCommunityNameSet"": ""false"",""writeOnlyCommunitryNameSet"": ""false""}";

                                PutCdm(device, jsonContent);
                            }
                        }
                        //snmpv1v2 is disabled we need to enable it
                        else
                        {
                            string jsonContent =
                                @"{""snmpv1v2Enabled"": ""true"",""accessOption"": ""readWrite"",""readOnlyPublicAllowed"": ""true"",""readOnlyCommunityNameSet"": ""false"",""writeOnlyCommunitryNameSet"": ""false""}";
                            PutCdm(device, jsonContent);
                        }
                    }

                    oidUsed(pair.Key);

                    if (!string.IsNullOrEmpty(snmpData))
                    {
                        //Restore state
                        PutCdm(device, snmpData);
                    }
                }
                catch (Exception ex)
                {
                    Logger.LogError($"Failed to set field {log.FieldChanged}, {ex.Message}");
                    _failedSettings.AppendLine($"Failed to set field {log.FieldChanged}, {ex.Message}");
                    success = false;
                }
                log.FieldChanged   = fieldChanged;
                log.Result         = success ? "Passed" : "Failed";
                log.Value          = pair.Key.ToString();
                log.ControlChanged = "Web/TroubleShooting";

                ExecutionServices.DataLogger.Submit(log);
            }
            return(true);
        }
 /// <summary>
 /// Scan Manager for the ScanToJobStorage plugin.
 /// </summary>
 public JobStorageScanManager(PluginExecutionData executionData)
     : base(executionData)
 {
     _data       = executionData.GetMetadata <ScanToJobStorageData>(ConverterProvider.GetMetadataConverters());
     ScanOptions = _data.ScanOptions;
 }
Beispiel #5
0
        public bool SetServerPort(DataPair <string> pair, JediDevice device, AssetInfo assetInfo, string fieldChanged, PluginExecutionData data)
        {
            string          oid    = "1.3.6.1.4.1.11.2.4.3.18.13.0";
            Action <string> change = n =>
            {
                int number;

                int.TryParse(pair.Key, out number);
                device.Snmp.Set(oid, number);
            };

            return(UpdateWithOid(change, device, pair, assetInfo, fieldChanged, data));
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="CloudConnectorScanManager" /> class.
 /// </summary>
 /// <param name="executionData">The execution data.</param>
 /// <param name="scanOptions">The scan options.</param>
 /// <param name="serverName">Name of the server.</param>
 public CloudConnectorScanManager(PluginExecutionData executionData, LinkScanOptions scanOptions, LockTimeoutData lockTimeoutData, string serverName)
     : base(executionData, scanOptions, lockTimeoutData, serverName)
 {
     ExecutionData = executionData;
     _data         = executionData.GetMetadata <CloudConnectorActivityData>();
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="LinkPrintActivityManager" /> class.
 /// </summary>
 /// <param name="executionData">The execution data.</param>
 /// <param name="linkPrintOptions">The cloud print configuration.</param>
 /// <param name="lockTimeoutData"></param>
 /// <param name="server">The server to log with the scan.</param>
 /// <exception cref="ArgumentNullException">
 /// <paramref name="executionData" /> is null.
 /// <para>or</para>
 /// <paramref name="linkPrintOptions" /> is null.
 /// </exception>
 protected LinkPrintActivityManager(PluginExecutionData executionData, LinkPrintOptions linkPrintOptions, LockTimeoutData lockTimeoutData, ServerInfo server)
     : this(executionData, linkPrintOptions, lockTimeoutData)
 {
     _serverName = server?.HostName;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ConnectivityTestDetailLog"/> class.
 /// </summary>
 public ConnectivityTestDetailLog(PluginExecutionData executionData)
     : base(executionData)
 {
 }
Beispiel #9
0
        public PluginExecutionResult Execute(PluginExecutionData executionData)
        {
            CtcSettings.Initialize(executionData);

            ConnectivityPrintActivityData activityData = executionData.GetMetadata <ConnectivityPrintActivityData>(CtcMetadataConverter.Converters);
            PrinterFamilies family = (PrinterFamilies)Enum.Parse(typeof(PrinterFamilies), Enum <ProductFamilies> .Value(activityData.ProductFamily));

            Printer.Printer printer = PrinterFactory.Create(family, IPAddress.Parse(activityData.Ipv4Address));

            if (!NetworkUtil.PingUntilTimeout(IPAddress.Parse(activityData.Ipv4Address), TimeSpan.FromSeconds(10)))
            {
                MessageBox.Show(string.Concat("Printer IPv4 Address is not accessible\n\n",
                                              "IPv4 address: {0}\n".FormatWith(activityData.Ipv4Address)),
                                @"IPv4 Address Not Accessible", MessageBoxButtons.OK, MessageBoxIcon.Error);

                return(new PluginExecutionResult(PluginResult.Failed, "Printer IPv4 Address is not accessible"));
            }

            // create instance of ews adapter
            EwsWrapper.Instance().Create(family, activityData.ProductName, activityData.Ipv4Address, Path.Combine(activityData.SitemapPath, activityData.SiteMapVersion), BrowserModel.Firefox);
            EwsWrapper.Instance().Start();
            EwsWrapper.Instance().WakeUpPrinter();
            EwsWrapper.Instance().SetAdvancedOptions();
            EwsWrapper.Instance().EnableSnmpv1v2ReadWriteAccess();

            //Enabling IPV6 startup
            EwsWrapper.Instance().SetDHCPv6OnStartup(true);
            EwsWrapper.Instance().SetIPv6(false);
            EwsWrapper.Instance().SetIPv6(true);

            // If printer is not available, assign default IPAddress
            if (printer.PingUntilTimeout(IPAddress.Parse(activityData.Ipv4Address), 1))
            {
                // Get All Ipv6 Addresses
                activityData.Ipv6LinkLocalAddress = printer.IPv6LinkLocalAddress?.ToString() ?? string.Empty;
                activityData.Ipv6StateFullAddress = printer.IPv6StateFullAddress?.ToString() ?? string.Empty;
                activityData.Ipv6StatelessAddress = printer.IPv6StatelessAddresses.Count == 0 ? string.Empty : printer.IPv6StatelessAddresses[0].ToString();
            }
            else
            {
                activityData.Ipv6LinkLocalAddress = string.Empty;
                activityData.Ipv6StateFullAddress = string.Empty;
                activityData.Ipv6StatelessAddress = string.Empty;
            }

            foreach (Ipv6AddressTypes addressType in activityData.Ipv6AddressTypes)
            {
                if (Ipv6AddressTypes.LinkLocal == addressType)
                {
                    if (!NetworkUtil.PingUntilTimeout(IPAddress.Parse(activityData.Ipv6LinkLocalAddress), TimeSpan.FromSeconds(10)))
                    {
                        MessageBox.Show(string.Concat("Printer Link Local Address is not accessible\n\n",
                                                      "Link local address: {0}\n".FormatWith(activityData.Ipv6LinkLocalAddress),
                                                      "Check if Stateless and Stateful address are pinging if you have selected it.\n",
                                                      "Stateless: {0}, Stateful: {1}".FormatWith(activityData.Ipv6StatelessAddress, activityData.Ipv6StateFullAddress)),
                                        @"Link Local Address Not Accessible", MessageBoxButtons.OK, MessageBoxIcon.Error);

                        return(new PluginExecutionResult(PluginResult.Failed, "Printer Link Local Address is not accessible"));
                    }
                }
                else if (Ipv6AddressTypes.Stateless == addressType)
                {
                    if (!NetworkUtil.PingUntilTimeout(IPAddress.Parse(activityData.Ipv6StatelessAddress), TimeSpan.FromSeconds(10)))
                    {
                        MessageBox.Show(string.Concat("Printer Stateless Address is not accessible\n\n",
                                                      "Stateless address: {0}\n".FormatWith(activityData.Ipv6StatelessAddress),
                                                      "Check if Stateful address is pinging if you have selected it.\n",
                                                      "Stateful: {0}".FormatWith(activityData.Ipv6StateFullAddress)),
                                        @"Stateless Address Not Accessible", MessageBoxButtons.OK, MessageBoxIcon.Error);

                        return(new PluginExecutionResult(PluginResult.Failed, "Printer Stateless Address is not accessible"));
                    }
                }
                else if (Ipv6AddressTypes.Stateful == addressType)
                {
                    if (!NetworkUtil.PingUntilTimeout(IPAddress.Parse(activityData.Ipv6StateFullAddress), TimeSpan.FromSeconds(10)))
                    {
                        MessageBox.Show(string.Concat("Printer Stateful Address is not accessible\n\n",
                                                      "Stateful address: {0}\n".FormatWith(activityData.Ipv6StateFullAddress)),
                                        @"Stateful Address Not Accessible", MessageBoxButtons.OK, MessageBoxIcon.Error);

                        return(new PluginExecutionResult(PluginResult.Failed, "Printer Stateful Address is not accessible"));
                    }
                }
            }

            //Reservation for Primary Printer
            string value    = activityData.Ipv4Address.Split(new char[] { '.' })[2];
            string serverIp = DHCP_SERVER_IP_FORMAT.FormatWith(value);

            TraceFactory.Logger.Info("Server IP : {0}".FormatWith(serverIp));
            //string serverIp = Printer.Printer.GetDHCPServerIP(IPAddress.Parse(activityData.Ipv4Address)).ToString();
            string printerMacAddress = printer.MacAddress.Replace(":", string.Empty);

            using (DhcpApplicationServiceClient client = DhcpApplicationServiceClient.Create(serverIp))
            {
                string scope = client.Channel.GetDhcpScopeIP(serverIp);
                TraceFactory.Logger.Info("Scope : {0}".FormatWith(scope));
                client.Channel.DeleteReservation(serverIp, client.Channel.GetDhcpScopeIP(serverIp), activityData.Ipv4Address, printerMacAddress);

                if (client.Channel.CreateReservation(serverIp, client.Channel.GetDhcpScopeIP(serverIp), activityData.Ipv4Address, printerMacAddress, ReservationType.Both))
                {
                    TraceFactory.Logger.Info("Primary Printer IP Address Reservation in DHCP Server for both DHCP and BOOTP : Succeeded");
                }
                else
                {
                    TraceFactory.Logger.Info("Primary Printer IP Address Reservation in DHCP Server for both DHCP and BOOTP: Failed");
                    return(new PluginExecutionResult(PluginResult.Failed, "Primary Printer IP Address Reservation in DHCP Server for both DHCP and BOOTP: Failed"));
                }
            }

            EwsWrapper.Instance().SetAdvancedOptions();

            string documentsPath      = activityData.DocumentsPath;
            string documentsSharePath = Path.Combine(CtcSettings.ConnectivityShare, activityData.ProductFamily.ToString());

            // Combine the connectivity share path with the selected document
            // In case of Re-run, path is already constructed. Hence do not construct it again.
            if (!Directory.Exists(documentsPath))
            {
                if (!documentsPath.StartsWith(documentsSharePath, StringComparison.CurrentCulture))
                {
                    documentsPath = Path.Combine(documentsSharePath, activityData.DocumentsPath, ConnectivityPrintConfigurationControl.DIRECTORY_DOCUMENTS);

                    activityData.DocumentsPath = documentsPath;
                }
            }

            if (activityData.IsWspTestsSelected)
            {
                printer.NotifyWSPrinter += printer_NotifyWSPAddition;
                if (printer.Install(IPAddress.Parse(activityData.Ipv4Address), Printer.Printer.PrintProtocol.WSP, activityData.DriverPackagePath, activityData.DriverModel))
                {
                    MessageBox.Show(@"WS Printer was added successfully.", @"WS Printer Successful", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show(@"WS Printer was not added successfully. All WS Print related tests will fail.", @"WS Printer Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }

            if (null == _printTests)
            {
                _printTests = new ConnectivityPrintTests(activityData);
            }

            foreach (int testNumber in activityData.SelectedTests)
            {
                ExecutionServices.SessionRuntime.AsInternal().WaitIfPaused();
                _printTests.RunTest(executionData, testNumber, IPAddress.Parse(activityData.Ipv4Address), activityData.ProductFamily);
            }

            return(new PluginExecutionResult(PluginResult.Passed));
        }
        public PluginExecutionResult Execute(PluginExecutionData executionData)
        {
            // create activity data
            IPConfigurationActivityData activityData = executionData.GetMetadata <IPConfigurationActivityData>();

            // Check if printer is accessible

            if (!(NetworkUtil.PingUntilTimeout(IPAddress.Parse(activityData.PrimaryWiredIPv4Address), TimeSpan.FromSeconds(20))) &&
                Utility.IsClientConfiguredWithServerIP(activityData.SecondDhcpServerIPAddress, activityData.LinuxServerIPAddress))
            {
                MessageBox.Show(string.Concat("Printer IP Address is not accessible or Client is not configured with Server IP Address.\n\n",
                                              "Make sure you have provided valid Printer IP Address and is accessible.\n",
                                              "Check if Client has acquired IPv4 Address from Secondary DHCP Server.\n",
                                              "Check if Client has acquired IPv4 Address from Linux Server."),
                                "IP Address Not Accessible", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(new PluginExecutionResult(PluginResult.Failed, "Printer IP Address is not accessible or Client is not configured with Server IP Address."));
            }

            // Check if the required services are running on DHCP server
            if (!IsServicesRunning(activityData.PrimaryDhcpServerIPAddress, activityData.SecondDhcpServerIPAddress))
            {
                return(new PluginExecutionResult(PluginResult.Failed, "Services are not running on DHCP server."));
            }

            // create instance of ews adapter
            EwsWrapper.Instance().Create(activityData.ProductFamily, activityData.ProductName, activityData.PrimaryWiredIPv4Address, activityData.SitemapsVersion,
                                         BrowserModel.Firefox, EwsAdapterType.WebDriverAdapter);

            EwsWrapper.Instance().Start();


            EwsWrapper.Instance().WakeUpPrinter();
            EwsWrapper.Instance().SetAdvancedOptions();

            IPAddress secondaryAddress = null;

            if (IPAddress.TryParse(activityData.SecondaryWiredIPv4Address, out secondaryAddress))
            {
                EwsWrapper.Instance().ChangeDeviceAddress(secondaryAddress);
                EwsWrapper.Instance().SetAdvancedOptions();
            }

            if (IPAddress.TryParse(activityData.WirelessIPv4Address, out secondaryAddress))
            {
                EwsWrapper.Instance().ChangeDeviceAddress(secondaryAddress);
                EwsWrapper.Instance().SetAdvancedOptions();
            }

            EwsWrapper.Instance().ChangeDeviceAddress(activityData.PrimaryWiredIPv4Address);

            Printer.Printer printer = PrinterFactory.Create(activityData.ProductFamily, activityData.PrimaryWiredIPv4Address);

            try
            {
                activityData.PrimaryMacAddress = printer.MacAddress.Replace(":", string.Empty);
            }
            catch
            { }

            if (string.IsNullOrEmpty(activityData.PrimaryMacAddress))
            {
                TraceFactory.Logger.Info("Could not get the mac address for Secondary wired interface.");
                return(new PluginExecutionResult(PluginResult.Failed, "Could not get the mac address for Secondary wired interface."));
            }

            if (activityData.PrinterInterfaceType == CtcBase.Controls.InterfaceType.Single)
            {
                if (IPAddress.TryParse(activityData.SecondaryWiredIPv4Address, out secondaryAddress))
                {
                    try
                    {
                        printer = PrinterFactory.Create(activityData.ProductFamily, activityData.SecondaryWiredIPv4Address);
                        activityData.SecondaryMacAddress = printer.MacAddress;
                    }
                    catch { }

                    if (string.IsNullOrEmpty(activityData.SecondaryMacAddress))
                    {
                        TraceFactory.Logger.Info("Could not get the mac address for Secondary wired interface.");
                        return(new PluginExecutionResult(PluginResult.Failed, "Could not get the mac address for Secondary wired interface."));
                    }
                }

                if (IPAddress.TryParse(activityData.WirelessIPv4Address, out secondaryAddress))
                {
                    try
                    {
                        printer = PrinterFactory.Create(activityData.ProductFamily, activityData.WirelessIPv4Address);
                        activityData.WirelessMacAddress = printer.MacAddress;
                    }catch { }

                    if (string.IsNullOrEmpty(activityData.WirelessMacAddress))
                    {
                        TraceFactory.Logger.Info("Could not get the mac address for Secondary wired interface.");
                        return(new PluginExecutionResult(PluginResult.Failed, "Could not get the mac address for wireless interface."));
                    }
                }
            }

            DhcpApplicationServiceClient serviceFunction = DhcpApplicationServiceClient.Create(activityData.PrimaryDhcpServerIPAddress);

            activityData.DHCPScopeIPAddress        = serviceFunction.Channel.GetDhcpScopeIP(activityData.PrimaryDhcpServerIPAddress);
            activityData.ServerDNSPrimaryIPAddress = serviceFunction.Channel.GetPrimaryDnsServer(activityData.PrimaryDhcpServerIPAddress, activityData.DHCPScopeIPAddress);
            activityData.SecondaryDnsIPAddress     = serviceFunction.Channel.GetSecondaryDnsServer(activityData.PrimaryDhcpServerIPAddress, activityData.DHCPScopeIPAddress);
            activityData.ServerHostName            = serviceFunction.Channel.GetHostName(activityData.PrimaryDhcpServerIPAddress, activityData.DHCPScopeIPAddress);
            activityData.DomainName            = serviceFunction.Channel.GetDomainName(activityData.PrimaryDhcpServerIPAddress, activityData.DHCPScopeIPAddress);
            activityData.ServerRouterIPAddress = serviceFunction.Channel.GetRouterAddress(activityData.PrimaryDhcpServerIPAddress, activityData.DHCPScopeIPAddress);
            activityData.ServerDNSSuffix       = serviceFunction.Channel.GetDnsSuffix(activityData.PrimaryDhcpServerIPAddress, activityData.DHCPScopeIPAddress);

            string ipv6Scope = serviceFunction.Channel.GetIPv6Scope(activityData.PrimaryDhcpServerIPAddress);

            if (string.IsNullOrEmpty(ipv6Scope))
            {
                MessageBox.Show(string.Concat("Unable to fetch IPv6 Scope \n\n",
                                              "Check whether DHCP IPv6 Scope is configured on DHCP server."),
                                "IPv6 Scope Not found", MessageBoxButtons.OK, MessageBoxIcon.Error);

                return(new PluginExecutionResult(PluginResult.Failed, "Check whether DHCP IPv6 Scope is configured on DHCP server."));
            }

            activityData.DHCPScopeIPv6Address = serviceFunction.Channel.GetIPv6Scope(activityData.PrimaryDhcpServerIPAddress);

            // Fetch the VLAN details.
            GetVlanDetails(ref activityData);

            // Check if Switch VLAN details are fetched
            if (3 != activityData.VirtualLanDetails.Count)
            {
                MessageBox.Show(string.Concat("Unable to fetch Switch VLAN details\n\n",
                                              "Check whether Printer is connected to Network Switch.\n",
                                              "Switch should be configured with 3 network virtual LAN."),
                                "Network switch not found", MessageBoxButtons.OK, MessageBoxIcon.Error);

                return(new PluginExecutionResult(PluginResult.Failed, "Unable to fetch Switch VLAN details. Check whether Printer is connected to Network Switch. Switch should be configured with 3 network virtual LAN."));
            }

            // Router Details: Address, Id, IPv6 Addresses
            IRouter router = null;

            activityData.RouterAddress = ROUTER_IP_FORMAT.FormatWith(activityData.PrimaryWiredIPv4Address.Substring(0, activityData.PrimaryWiredIPv4Address.LastIndexOf(".", StringComparison.CurrentCultureIgnoreCase)));
            router = RouterFactory.Create(IPAddress.Parse(activityData.RouterAddress), ROUTER_USERNAME, ROUTER_PASSWORD);

            Dictionary <int, IPAddress> routerVlans = router.GetAvailableVirtualLans();

            activityData.RouterVlanId = routerVlans.Where(x => (null != x.Value) && (x.Value.IsInSameSubnet(IPAddress.Parse(activityData.RouterAddress)))).FirstOrDefault().Key;

            RouterVirtualLAN       routerVlan          = router.GetVirtualLanDetails(activityData.RouterVlanId);
            Collection <IPAddress> routerIPv6Addresses = router.GetIPv6Addresses(routerVlan.IPv6Details);

            activityData.RouterIPv6Addresses = new Collection <string>(routerIPv6Addresses.Select(x => x.ToString()).ToList());

            // Add source IP Address
            Utility.AddSourceIPAddress(activityData.PrimaryDhcpServerIPAddress, activityData.LinuxServerIPAddress);

            //create instance of SNMP wrapper
            SnmpWrapper.Instance().Create(activityData.PrimaryWiredIPv4Address);

            //create instance of Telnet wrapper
            TelnetWrapper.Instance().Create(activityData.PrimaryWiredIPv4Address);

            if (!ManageReservation(activityData))
            {
                return(new PluginExecutionResult(PluginResult.Failed, "Printer IP Address Reservation in DHCP Server for both DHCP and BOOTP: Failed"));
            }

            TraceFactory.Logger.Info("The Server Configured Value retrieved from the DHCP Server are as follows:");
            TraceFactory.Logger.Info("MacAddress:{0}, DNSPrimaryIP:{1}, HostName:{2}, RouterIP:{3}, DNSSuffix:{4}".FormatWith(activityData.PrimaryMacAddress, activityData.ServerDNSPrimaryIPAddress,
                                                                                                                              activityData.ServerHostName, activityData.ServerRouterIPAddress, activityData.ServerDNSSuffix));

            // assign the session id to activity id
            activityData.SessionId = executionData.SessionId;

            if (null == _ipConfigTests)
            {
                _ipConfigTests = new IPConfigurationTests(activityData);
            }

            foreach (int testNumber in activityData.SelectedTests)
            {
                try
                {
                    ApplicationFlowControl.Instance.CheckWait(LogPauseState, LogResumeState);
                    _ipConfigTests.RunTest(executionData, testNumber, activityData.PrimaryWiredIPv4Address, (ProductFamilies)Enum.Parse(typeof(ProductFamilies), activityData.ProductFamily));
                }
                catch (Exception generalException)
                {
                    TraceFactory.Logger.Info("Test {0} failed with error: {1}".FormatWith(testNumber, generalException.Message));
                }
            }

            EwsWrapper.Instance().Stop();

            return(new PluginExecutionResult(PluginResult.Passed));
        }
Beispiel #11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TriageBase"/> class.
 /// </summary>
 /// <param name="pluginExecutionData">The plugin execution data.</param>
 protected TriageBase(PluginExecutionData pluginExecutionData)
 {
     _pluginExecutionData = pluginExecutionData;
     _logger = new TriageDataLog(_pluginExecutionData);
 }
Beispiel #12
0
        /// <summary>
        /// Execute the task of the DeviceConfiguration activity.
        /// </summary>
        /// <param name="executionData"></param>
        /// <returns></returns>
        public PluginExecutionResult Execute(PluginExecutionData executionData)
        {
            _executionData = executionData;
            _activityData  = executionData.GetMetadata <DeviceInspectorActivityData>();
            TimeSpan lockTimeout = TimeSpan.FromMinutes(5);
            TimeSpan holdTimeout = TimeSpan.FromMinutes(5);
            ConcurrentDictionary <string, DataPair <string> > verifiedResults = new ConcurrentDictionary <string, DataPair <string> >();

            if (!_executionData.Assets.OfType <IDeviceInfo>().Any())
            {
                return(new PluginExecutionResult(PluginResult.Failed, "There were no assets retrieved.  If this is a count-based run, your reservation in asset inventory may have expired.", "DeviceInfo Asset error"));
            }

            ExecutionServices.SystemTrace.LogDebug("Beginning Update");

            try
            {
                //Parallel.ForEach(_executionData.Assets.OfType<IDeviceInfo>(),asset =>
                foreach (var asset in _executionData.Assets.OfType <IDeviceInfo>())
                {
                    JediDevice device = null;
                    try
                    {
                        try
                        {
                            device = DeviceConstructor.Create(asset) as JediDevice;
                        }
                        catch
                        {
                            device = DeviceFactory.Create(asset.Address) as JediDevice;
                        }

                        // Make sure the device is in a good state
                        var devicePrepManager = DevicePreparationManagerFactory.Create(device);
                        try
                        {
                            devicePrepManager.InitializeDevice(true);
                        }
                        catch (WebInspectorException webInspectorException)
                        {
                            //let's ignore initialise device errors, this might be due to inspection page in use,
                            //since we are not doing any control panel action, this should be ok
                            ExecutionServices.SystemTrace.LogDebug(webInspectorException.Message);
                        }


                        ExecutionServices.SystemTrace.LogDebug(
                            $"Processing {asset.AssetId} on thread {Thread.CurrentThread}");

                        AssetLockToken assetToken = new AssetLockToken(asset, lockTimeout, holdTimeout);

                        ExecutionServices.CriticalSection.Run(assetToken, () =>
                        {
                            ExecutionServices.SystemTrace.LogDebug(
                                $"Performing update on device {asset.AssetId} at address {asset.Address}");
                            var verifiedResult = UpdateDevice(device, asset);
                            verifiedResults.AddOrUpdate(asset.AssetId, verifiedResult, (key, oldvalue) => UpdateDevice(device, asset));
                        });
                    }
                    catch (DeviceCommunicationException deviceCommunicationException)
                    {
                        ExecutionServices.SystemTrace.LogDebug($"Unable to communicate with the device: {deviceCommunicationException.Message}");
                        verifiedResults.AddOrUpdate(asset.AssetId,
                                                    new DataPair <string> {
                            Key = "Device Communication", Value = false
                        },
                                                    (s, pair) => new DataPair <string>()
                        {
                            Key = "Device Communication", Value = false
                        });
                        device?.Dispose();
                    }
                    catch (Exception e)
                    {
                        ExecutionServices.SystemTrace.LogDebug(e);
                        verifiedResults.AddOrUpdate(asset.AssetId,
                                                    new DataPair <string> {
                            Key = "Failed Settings", Value = false
                        },
                                                    (s, pair) => new DataPair <string> {
                            Key = "Failed Settings", Value = false
                        });
                        device?.Dispose();
                    }
                }
            }
            catch
            {
                return(new PluginExecutionResult(PluginResult.Error, "Error during Device Configuration Setup"));
            }

            foreach (var verifiedResult in verifiedResults)
            {
                UpdateStatus($"Device: {verifiedResult.Key} Result: {verifiedResult.Value.Value}, {verifiedResult.Value.Key}");
            }

            if (verifiedResults.Any(x => x.Value.Value == false))
            {
                return(new PluginExecutionResult(PluginResult.Failed));
            }


            return(new PluginExecutionResult(PluginResult.Passed));
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="LinkScanAppsScanManager" /> class.
 /// </summary>
 /// <param name="executionData">The execution data.</param>
 /// <param name="scanOptions">The scan options.</param>
 /// <param name="serverName">Name of the server.</param>
 public LinkScanAppsScanManager(PluginExecutionData executionData, LinkScanOptions scanOptions, LockTimeoutData lockTimeoutData, string serverName)
     : base(executionData, scanOptions, lockTimeoutData, serverName)
 {
     _data = executionData.GetMetadata <LinkScanAppsActivityData>();
 }
Beispiel #14
0
        private bool SetProtocolDefaultValues(string oidName, DataPair <string> itemValue, JediDevice device, AssetInfo assetInfo, string fieldChanged, PluginExecutionData data)
        {
            //i don't plan to use web service ticket so this is dummy to conform with the interface
            Func <WebServiceTicket, WebServiceTicket> change = n =>
            {
                return(n);
            };

            //send the oid Name disguised as endpoint
            return(UpdateField(change, device, itemValue, string.Empty, oidName, assetInfo, fieldChanged, data));
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="CloudConnectorPrintManager" /> class.
 /// </summary>
 /// <param name="executionData">The execution data.</param>
 /// <param name="printOptions">The scan options.</param>
 public KioskCopyManager(PluginExecutionData executionData, KioskCopyOptions copyOptions, LockTimeoutData lockTimeoutData)
     : base(executionData, lockTimeoutData)
 {
     _data             = executionData.GetMetadata <KioskActivityData>();
     _kioskCopyOptions = _data.CopyOptions;
 }
Beispiel #16
0
        public PluginExecutionResult Execute(PluginExecutionData executionData)
        {
            _activityData = executionData.GetMetadata <CertificateInstallerActivityData>();

            PrintDeviceInfo printDeviceInfo = (PrintDeviceInfo)executionData.Assets.First();

            _device = DeviceConstructor.Create(printDeviceInfo);

            try
            {
                string authorization = string.Empty;

                _userAgent = GetUserAgent(_activityData.BrowserType);

                // Installs certificate on Client VM
                if (_activityData.ClientVMCA)
                {
                    ExecutionServices.SystemTrace.LogDebug($"Certificate Path { (object)_activityData.CACertificate}");
                    InstallVMCertificate(_activityData.CACertificate);
                }

                // Check for the printer availability
                if (!PingUntilTimeout(IPAddress.Parse(_device.Address), TimeSpan.FromMinutes(1)))
                {
                    string errorMessage = $"Ping failed with IP Address:{ (object)_device.Address}";
                    ExecutionServices.SystemTrace.LogDebug(errorMessage);
                    _device.Dispose();
                    return(new PluginExecutionResult(PluginResult.Failed, errorMessage));
                }

                if (!string.IsNullOrEmpty(_device.AdminPassword))
                {
                    string credentials    = $"admin:{_device.AdminPassword}";
                    byte[] plainTextBytes = System.Text.Encoding.UTF8.GetBytes(credentials);
                    authorization = "Basic " + Convert.ToBase64String(plainTextBytes);
                }

                // Enterprise Lock on device so that only one dispatcher can reserve at a time.
                // Action action = new Action(() =>
                {
                    //Installs CA certificate on the printer
                    if (_activityData.InstallPrinterCA)
                    {
                        ExecutionServices.CriticalSection.Run(new AssetLockToken(executionData.Assets.First(), new LockTimeoutData(TimeSpan.FromMinutes(1), TimeSpan.FromMinutes(1))), () => InstallCertificate(authorization));
                    }

                    //Deletes CA certificate from the printer
                    if (_activityData.DeletePrinterCA)
                    {
                        ExecutionServices.CriticalSection.Run(new AssetLockToken(executionData.Assets.First(), new LockTimeoutData(TimeSpan.FromMinutes(1), TimeSpan.FromMinutes(1))), () => DeleteCertificate(authorization, _device.Address));
                    }
                }
            }
            catch (Exception exception)
            {
                var failureMessage = $"Activity failed on device {_device.Address} with exception {exception.Message}";
                _device.Dispose();
                return(new PluginExecutionResult(PluginResult.Failed, failureMessage));
            }

            _device.Dispose();
            return(new PluginExecutionResult(PluginResult.Passed));
        }
Beispiel #17
0
 /// <summary>
 /// Initializes a new instance of the <see cref="EmailBuilder" /> class.
 /// </summary>
 /// <param name="userName">The user name.</param>
 /// <param name="executionData">The <see cref="PluginExecutionData" /> containing information about the execution environment.</param>
 public EmailBuilder(string userName, PluginExecutionData executionData)
     : this(userName, executionData?.Environment.UserDnsDomain)
 {
 }
 public EmailScanManager(PluginExecutionData executionData, string serverName)
     : base(executionData, serverName)
 {
     _data       = executionData.GetMetadata <ScanToEmailData>(ConverterProvider.GetMetadataConverters());
     ScanOptions = _data.ScanOptions;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="LinkPrintActivityManager" /> class.
 /// </summary>
 /// <param name="executionData">The execution data.</param>
 /// <param name="linkPrintOptions">The cloud print configuration.</param>
 /// <param name="lockTimeoutData"></param>
 /// <param name="serverName">The server to log with the scan.</param>
 /// <exception cref="ArgumentNullException">
 /// <paramref name="executionData" /> is null.
 /// <para>or</para>
 /// <paramref name="linkPrintOptions" /> is null.
 /// </exception>
 protected LinkPrintActivityManager(PluginExecutionData executionData, LinkPrintOptions linkPrintOptions, LockTimeoutData lockTimeoutData, string serverName)
     : this(executionData, linkPrintOptions, lockTimeoutData)
 {
     _serverName = serverName;
 }
Beispiel #20
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ScanActivityManager" /> class.
 /// </summary>
 /// <param name="executionData">The execution data.</param>
 /// <param name="serverName">The server to log with the scan.</param>
 /// <exception cref="ArgumentNullException">
 /// <paramref name="executionData" /> is null.
 /// <para>or</para>
 /// </exception>
 protected ScanActivityManager(PluginExecutionData executionData, string serverName)
     : this(executionData)
 {
     _serverName = serverName;
 }
Beispiel #21
0
        /// <summary>
        /// Executes this plugin's workflow using the specified <see cref="PluginExecutionData" />.
        /// </summary>
        /// <param name="executionData">The execution data.</param>
        /// <returns>A <see cref="PluginExecutionResult" /> indicating the outcome of the execution.</returns>
        public PluginExecutionResult Execute(PluginExecutionData executionData)
        {
            _executionData     = executionData;
            _performanceLogger = new DeviceWorkflowLogger(_executionData);
            _activityData      = executionData.GetMetadata <USBFirmwarePerformanceActivityData>();

            TimeSpan lockTimeout = TimeSpan.FromMinutes(10);
            TimeSpan holdTimeout = TimeSpan.FromMinutes(60);

            PluginExecutionResult result = new PluginExecutionResult(PluginResult.Failed, "Failed to Start Upgrade");


            ///Dictionary<string, PluginExecutionResult> results = new Dictionary<string, PluginExecutionResult>();
            if (_executionData.Assets.OfType <IDeviceInfo>().Count() == 0)
            {
                return(new PluginExecutionResult(PluginResult.Failed, $"There were no assets retrieved.  If this is a count-based run, your reservation in asset inventory may have expired.", "DeviceInfo Asset error"));
            }

            try
            {
                var assetTokens = _executionData.Assets.OfType <IDeviceInfo>().Select(n => new AssetLockToken(n, lockTimeout, holdTimeout));
                _performanceLogger.RecordEvent(DeviceWorkflowMarker.DeviceLockBegin);
                ExecutionServices.CriticalSection.Run(assetTokens, selectedToken =>
                {
                    _performanceLogger.RecordEvent(DeviceWorkflowMarker.ActivityBegin);

                    IDeviceInfo asset = (selectedToken as AssetLockToken).AssetInfo as IDeviceInfo;
                    IDevice device    = DeviceConstructor.Create(asset);
                    ExecutionServices.DataLogger.Submit(new ActivityExecutionAssetUsageLog(_executionData, asset));

                    ExecutionServices.SystemTrace.LogDebug($"Performing update on device {asset.AssetId} at address {asset.Address}");

                    result = UpgradeFirmware(asset);


                    if (result.Result != PluginResult.Passed)
                    {
                        //the update process failed, just return
                        return;
                    }

                    if (!_activityData.ValidateFlash)
                    {
                        _performanceLogger.RecordExecutionDetail(DeviceWorkflowMarker.FirmwareUpdateEnd, device.GetDeviceInfo().FirmwareRevision);
                        return;
                    }

                    int maxRetries = (int)_activityData.ValidateTimeOut.TotalSeconds / 5;
                    if (Retry.UntilTrue(() => HasDeviceRebooted(device), maxRetries, TimeSpan.FromSeconds(5)))
                    {
                        _performanceLogger.RecordEvent(DeviceWorkflowMarker.DeviceRebootBegin);
                        UpdateStatus("Device has Rebooted. Waiting for device to boot up...");
                    }
                    else
                    {
                        result = new PluginExecutionResult(PluginResult.Failed, $"Device did not reboot after firmware was uploaded. Please check the device for pending jobs and try again.");
                        return;
                    }


                    ExecutionServices.SystemTrace.LogInfo($"FW Update Complete");

                    //Wait for device to finish rebooting or end
                    ExecutionServices.SystemTrace.LogInfo($"Starting Reboot");
                    UpdateStatus("Waiting for device to boot up...");
                    //_performanceLogger.RecordEvent(DeviceWorkflowMarker.DeviceRebootBegin);
                    //We're probably not up and running right away.
                    Thread.Sleep(TimeSpan.FromSeconds(30));


                    ExecutionServices.SystemTrace.LogDebug($"Max Retries: {maxRetries}");
                    int retry             = 0;
                    string fwRevision     = string.Empty;
                    bool controlPanelUp   = false; //Actually webservices, but close enough.
                    bool embeddedServerUp = false;
                    if (Retry.UntilTrue(() => IsDeviceRunning(device, retry++, ref controlPanelUp, ref embeddedServerUp), maxRetries, TimeSpan.FromSeconds(10)))
                    {
                        try
                        {
                            fwRevision = device.GetDeviceInfo().FirmwareRevision;
                            postRevision_textBox.InvokeIfRequired(c => { c.Text = fwRevision; });
                        }
                        catch
                        {
                            fwRevision = string.Empty;
                        }
                        //Validate update passed by comparing starting and ending FW
                        //result = startingFW != fwRevision ? new PluginExecutionResult(PluginResult.Passed, $"Firmware upgraded for device {device.Address}") : new PluginExecutionResult(PluginResult.Failed, "The device firmware upgrade validation failed");
                        result = new PluginExecutionResult(PluginResult.Passed);
                    }
                    else
                    {
                        result = new PluginExecutionResult(PluginResult.Failed,
                                                           $"Device firmware could not be validated for device:{device.Address} within {_activityData.ValidateTimeOut}");
                    }
                    _performanceLogger.RecordEvent(DeviceWorkflowMarker.DeviceRebootEnd);
                    _performanceLogger.RecordEvent(DeviceWorkflowMarker.FirmwareUpdateEnd);

                    ExecutionServices.SystemTrace.LogInfo($"Reboot End");

                    _activityExecutionDetailLog = new ActivityExecutionDetailLog(_executionData, "PostUpgradeFirmware", fwRevision);
                    ExecutionServices.DataLogger.Submit(_activityExecutionDetailLog);

                    //return result;
                });
            }
            catch (Exception e)
            {
                ExecutionServices.SystemTrace.LogDebug(e);
                UpdateStatus(e.Message);
                result = new PluginExecutionResult(PluginResult.Failed, e.Message);
            }
            _performanceLogger.RecordEvent(DeviceWorkflowMarker.ActivityEnd);
            _performanceLogger.RecordEvent(DeviceWorkflowMarker.DeviceLockEnd);
            return(result);
        }
Beispiel #22
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ScanActivityManager" /> class.
 /// </summary>
 /// <param name="executionData">The execution data.</param>
 /// <param name="server">The server to log with the scan.</param>
 /// <exception cref="ArgumentNullException">
 /// <paramref name="executionData" /> is null.
 /// <para>or</para>
 /// </exception>
 protected ScanActivityManager(PluginExecutionData executionData, ServerInfo server)
     : this(executionData)
 {
     _serverName = server?.HostName;
 }
Beispiel #23
0
        public bool SetSyslogServer(DataPair <string> pair, JediDevice device, AssetInfo assetInfo, string fieldChanged, PluginExecutionData data)
        {
            string mainOID = "1.3.6.1.4.1.11.2.4.3.5.5.0";
            //string enableOID = "1.3.6.1.4.1.11.2.4.3.7.26.0";
            Action <string> change = n =>
            {
                //device.Snmp.Set(enableOID, 0);

                var snmpvalue = new HP.DeviceAutomation.SnmpOidValue(mainOID, pair.Key, 64);
                device.Snmp.Set(snmpvalue);
            };

            return(UpdateWithOid(change, device, pair, assetInfo, fieldChanged, data));
        }
Beispiel #24
0
 /// <summary>
 /// Initializes the authenticator that will be used in the run, including setting up the badgebox if needed.
 /// </summary>
 /// <param name="provider">The authentication provider to create</param>
 /// <param name="device">The device that will be used for the run.</param>
 /// <param name="executionData">This is to pass the credentials for authentication</param>
 protected void InitializeAuthenticator(AuthenticationProvider provider, IDevice device, PluginExecutionData executionData)
 {
     Authenticator = AuthenticatorFactory.Create(ScanLog.DeviceId, device, provider, executionData);
     Authenticator.WorkflowLogger = WorkflowLogger;
 }
Beispiel #25
0
        public bool SetProxyList(DataPair <string> pair, JediDevice device, AssetInfo assetInfo, string fieldChanged, PluginExecutionData data)
        {
            string          oid    = "1.3.6.1.4.1.11.2.4.3.18.16.0";
            Action <string> change = n =>
            {
                device.Snmp.Set(oid, pair.Key);
            };

            return(UpdateWithOid(change, device, pair, assetInfo, fieldChanged, data));
        }
        /// <summary>
        /// Executes this plugin's workflow using the specified <see cref="T:HP.ScalableTest.Framework.Plugin.PluginExecutionData" />.
        /// </summary>
        /// <param name="executionData">The execution data.</param>
        /// <returns>A <see cref="T:HP.ScalableTest.Framework.Plugin.PluginExecutionResult" /> indicating the outcome of the execution.</returns>
        public PluginExecutionResult Execute(PluginExecutionData executionData)
        {
            // reset current user as it may have changed since control load.
            _executionData = executionData;
            _currentUser   = _executionData.Credential;
            _activityData  = _executionData.GetMetadata <DirtyDeviceActivityData>(new[] { new DirtyDeviceDataConverter1_1() });

            UpdateExecutionStatus(this, "Starting activity...");

            _currentDevice  = _executionData.Assets.GetRandom <Framework.Assets.IDeviceInfo>();
            _workflowLogger = new DeviceWorkflowLogger(_executionData);

            InitializeControlWithActivityData();

            try
            {
                // Wrap in using to release any connections to the device.  This is critical for Omni operations.
                using (DirtyDeviceManager pluginActivityManager = new DirtyDeviceManager(_currentDevice, _currentUser, _activityData, executionData.Environment))
                {
                    pluginActivityManager.UpdateStatus += (s, e) => UpdateExecutionStatus(s, e);

                    if (_currentDevice == null)
                    {
                        return(new PluginExecutionResult(PluginResult.Error, $"{typeof(IDeviceInfo).Name} retrieved is null.  If this is a count-based run, your reservation in asset inventory may have expired.", "DeviceInfo Asset error"));
                    }
                    else if (_currentDevice.AssetId == null)
                    {
                        return(new PluginExecutionResult(PluginResult.Error, $"{typeof(IDeviceInfo).Name}.AssetId property is null.", "DeviceInfo Asset error"));
                    }
                    else if (_currentDevice.AssetType == null)
                    {
                        return(new PluginExecutionResult(PluginResult.Error, $"{typeof(IDeviceInfo).Name}.AssetType property is null.", "DeviceInfo Asset error"));
                    }
                    else if (pluginActivityManager.Device == null)
                    {
                        return(new PluginExecutionResult(PluginResult.Error, $"{nameof(pluginActivityManager)}.Device property is null.", $"Could not create IDevice (AssetId: {_currentDevice.AssetId})"));
                    }

                    PluginExecutionResult pluginExecutionResult = new PluginExecutionResult(PluginResult.Error, new Exception($"The {typeof(PluginExecutionResult)} was never set by the activity."));
                    try
                    {
                        UpdateExecutionStatus(this, $"Waiting for access to {_currentDevice.AssetId} ({_currentDevice.Address})");
                        var token = new AssetLockToken(_currentDevice, _activityData.LockTimeouts.AcquireTimeout, _activityData.LockTimeouts.HoldTimeout);
                        _workflowLogger.RecordEvent(DeviceWorkflowMarker.DeviceLockBegin);
                        ExecutionServices.CriticalSection.Run(token, () =>
                        {
                            var retryManager      = new PluginRetryManager(executionData, (e) => UpdateExecutionStatus(this, e));
                            pluginExecutionResult = retryManager.Run(() =>
                            {
                                ExecutionServices.DataLogger.Submit(new ActivityExecutionAssetUsageLog(_executionData, _currentDevice.AssetId));

                                try
                                {
                                    pluginActivityManager.ExecuteDirty();
                                    return(new PluginExecutionResult(PluginResult.Passed));
                                }
                                catch (DeviceCommunicationException ex)
                                {
                                    GatherTriageData(ex.ToString(), pluginActivityManager);
                                    return(new PluginExecutionResult(PluginResult.Failed, ex, "Device communication error."));
                                }
                                catch (DeviceInvalidOperationException ex)
                                {
                                    GatherTriageData(ex.ToString(), pluginActivityManager);
                                    return(new PluginExecutionResult(PluginResult.Failed, ex, "Device automation error."));
                                }
                                catch (DeviceWorkflowException ex)
                                {
                                    GatherTriageData(ex.ToString(), pluginActivityManager);
                                    return(new PluginExecutionResult(PluginResult.Failed, ex, "Device workflow error."));
                                }
                                catch (Exception ex)
                                {
                                    GatherTriageData(ex.ToString(), pluginActivityManager);
                                    return(new PluginExecutionResult(PluginResult.Error, new Exception($"The plugin activity threw an unexpected exception: {ex.ToString()}", ex)));
                                }
                            });
                        });
                        _workflowLogger.RecordEvent(DeviceWorkflowMarker.DeviceLockEnd);
                    }
                    catch (AcquireLockTimeoutException ex)
                    {
                        GatherTriageData(ex.ToString(), pluginActivityManager);
                        return(new PluginExecutionResult(PluginResult.Skipped, string.Format("Could not obtain lock on device {0}.", (_currentDevice != null ? _currentDevice.AssetId : "null")), "Device unavailable."));
                    }
                    catch (HoldLockTimeoutException ex)
                    {
                        GatherTriageData(ex.ToString(), pluginActivityManager);
                        return(new PluginExecutionResult(PluginResult.Error, $"Automation did not complete within {_activityData.LockTimeouts.HoldTimeout}.", "Automation timeout exceeded."));
                    }
                    catch (Exception ex)
                    {
                        GatherTriageData(ex.ToString(), pluginActivityManager);
                        return(new PluginExecutionResult(PluginResult.Error, new Exception($"The {typeof(PluginRetryManager).Name} threw an unexpected exception.", ex)));
                    }

                    return(pluginExecutionResult);
                }
            }
            catch (Exception x)
            {
                return(new PluginExecutionResult(PluginResult.Error, x, "Plugin error during activity setup."));
            }
            finally
            {
                UpdateExecutionStatus(this, $"Finished activity.");
            }
        }
Beispiel #27
0
        /// <summary>
        /// Only used for AutoRestartAfterUnrecoverableFirmwareFault
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="changeValue"></param>
        /// <param name="device"></param>
        /// <param name="data"></param>
        /// <param name="urn"></param>
        /// <param name="endpoint"></param>
        /// <param name="assetInfo"></param>
        /// <param name="fieldChanged"></param>
        /// <param name="pluginData"></param>
        /// <returns></returns>
        public bool UpdateField <T>(Func <WebServiceTicket, WebServiceTicket> changeValue, JediDevice device, DataPair <T> data, string urn, string endpoint, AssetInfo assetInfo, string fieldChanged, PluginExecutionData pluginData)
        {
            bool success;

            if (data.Value)
            {
                DeviceConfigResultLog log = new DeviceConfigResultLog(pluginData, assetInfo.AssetId);
                try
                {
                    WebServiceTicket tic = device.WebServices.GetDeviceTicket(endpoint, urn);
                    changeValue(tic);
                    device.WebServices.PutDeviceTicket(endpoint, urn, tic);
                    success = true;
                }
                catch (Exception ex)
                {
                    Logger.LogError($"Failed to set field {fieldChanged}, {ex.Message}");
                    _failedSettings.AppendLine($"Failed to set field {fieldChanged}, {ex.Message}");
                    success = false;
                }
                log.FieldChanged   = fieldChanged;
                log.Result         = success ? "Passed" : "Failed";
                log.Value          = data.Key.ToString();
                log.ControlChanged = @"Web/TroubleShooting";

                ExecutionServices.DataLogger.Submit(log);
            }
            else
            {
                success = true;
            }

            return(success);
        }
 /// <summary>
 /// JetAdvantageLinkMemoryMonitoring
 /// </summary>
 /// <param name="linkUI">Link UI</param>
 /// <param name="targetPackage">Target Android Package name</param>
 /// <param name="pluginExecutionData">PluginExecution Data</param>
 /// <param name="deviceInfo">deviceInfo</param>
 public JetAdvantageLinkMemoryMonitoring(JetAdvantageLinkUI linkUI, string targetPackage, PluginExecutionData pluginExecutionData, IDeviceInfo deviceInfo)
 {
     _linkUI              = linkUI;
     _targetPackage       = targetPackage;
     _pluginExecutionData = pluginExecutionData;
     _deviceInfo          = deviceInfo;
 }
        private bool SetFolderDefaultJobValues(string elementName, DataPair <string> itemValue, JediDevice device, AssetInfo assetInfo, string fieldChanged, PluginExecutionData data)
        {
            string activityUrn = "urn:hp:imaging:con:service:folder:FolderService:DefaultJob";
            string endpoint    = "folder";

            Func <WebServiceTicket, WebServiceTicket> change = n =>
            {
                n.FindElement(elementName).SetValue(itemValue.Key);
                return(n);
            };

            return(UpdateField(change, device, itemValue, activityUrn, endpoint, assetInfo, fieldChanged, data));
        }
Beispiel #30
0
        private bool SetResolution(DataPair <string> pair, JediDevice device, AssetInfo assetInfo, string fieldChanged, PluginExecutionData data)
        {
            string activityUrn = "urn:hp:imaging:con:service:email:EmailService:DefaultJob";
            string endpoint    = "email";

            Func <WebServiceTicket, WebServiceTicket> change = n =>
            {
                string temp = pair.Key.Replace(" ", "");
                n.FindElement("DSImageResolution").SetValue(temp);
                return(n);
            };

            return(UpdateField(change, device, pair, activityUrn, endpoint, assetInfo, fieldChanged, data));
        }