public static void Main(string[] args)
        {
            // This first part is to simply setup the connection to the Cimom
            string progName = System.AppDomain.CurrentDomain.FriendlyName;
            if (args.Length != 4)
            {
                Console.WriteLine("Usage: " + progName + " <server name> <username> <password> <namespace>");
                return;
            }
            string host = args[0];
            string user = args[1];
            string pwd = args[2];
            string defaultNamespace = args[3];

            // This is the line that defines our wbem client. No connection is made
            // to the Cimom until a call is made.
            WbemClient client = new WbemClient(host, user, pwd, defaultNamespace);

            // Connect to the cimom and request the CIM_Capabilities class
            Console.Write("Enumerating Instance Names of Class: CIM_Capabilities... ");
            CimInstanceNameList items = client.EnumerateInstanceNames("CIM_Capabilities");
            Console.WriteLine("Done.\n");

            // Display the Instance Names that were retrieved
            Console.WriteLine("Instance Names");
            Console.WriteLine("--------------");
            foreach (CimInstanceName curItem in items)
            {
                Console.WriteLine(curItem);
            }
        }
        public static void Main(string[] args)
        {
            // This first part is to simply setup the connection to the Cimom
            string progName = System.AppDomain.CurrentDomain.FriendlyName;
            if (args.Length != 4)
            {
                Console.WriteLine("Usage: " + progName + " <server name> <username> <password> <namespace>");
                return;
            }
            string host = args[0];
            string user = args[1];
            string pwd = args[2];
            string defaultNamespace = args[3];

            // This is the line that defines our wbem client. No connection is made
            // to the Cimom until a call is made.
            WbemClient client = new WbemClient(host, user, pwd, defaultNamespace);

            // Connect to the cimom and create the CIM_Dummy class
            Console.Write("Creating Class: CIM_Dummy... ");

            CimClass myClass = new CimClass("CIM_Dummy");
            myClass.Properties.Add(new CimProperty("Prop1",CimType.BOOLEAN));
            myClass.Properties.Add(new CimProperty("Prop2",CimType.SINT32));

            client.CreateClass(myClass);

            Console.WriteLine("Done.\n");
        }
Esempio n. 3
0
        public static void Main(string[] args)
        {
            // This first part is to simply setup the connection to the Cimom
            string progName = System.AppDomain.CurrentDomain.FriendlyName;
            if (args.Length != 4)
            {
                Console.WriteLine("Usage: " + progName + " <server name> <username> <password> <namespace>");
                return;
            }
            string host = args[0];
            string user = args[1];
            string pwd = args[2];
            string defaultNamespace = args[3];

            // This is the line that defines our wbem client. No connection is made
            // to the Cimom until a call is made.
            WbemClient client = new WbemClient(host, user, pwd, defaultNamespace);

            GetClassOpSettings gcos = new GetClassOpSettings("CIM_NFS");
            EnumerateClassNamesOpSettings ecnos = new EnumerateClassNamesOpSettings();

            GetClassOpSettings gcos2 = new GetClassOpSettings("CIM_Component");

            BatchRequest batch = new BatchRequest("root/cimv2");
            batch.Add(gcos);
            batch.Add(ecnos);
            batch.Add(gcos2);

            BatchResponse response = client.ExecuteBatchRequest(batch);
        }
Esempio n. 4
0
        private void button1_Click(object sender, EventArgs e)
        {
            if ( (uxTxtBox_Hostname.Text == string.Empty) ||
                 (uxTxtBox_Username.Text == string.Empty) ||
                 (uxTxtBox_Password.Text == string.Empty) )
            {
                MessageBox.Show("Hostname, Username and Password must be set to view the namespaces");
            }
            else
            {
            //                try
                {
                    WbemClient tmpWC = new WbemClient(uxTxtBox_Hostname.Text, uxTxtBox_Username.Text, uxTxtBox_Password.Text, "Interop");
                    NamespaceForm nsForm = new NamespaceForm(tmpWC.EnumerateNamespaces());

                    if (nsForm.ShowDialog() == DialogResult.OK)
                    {
                        uxTxtBox_Namespace.Text = nsForm.SelectedNamespace;
                    }
                }
                //catch (Exception ex)
                //{
                //    MessageBox.Show(ex.Message);
                //}
            }
        }
        public static void Main(string[] args)
        {
            // This first part is to simply setup the connection to the Cimom
            string progName = System.AppDomain.CurrentDomain.FriendlyName;
            if (args.Length != 4)
            {
                Console.WriteLine("Usage: " + progName + " <server name> <username> <password> <namespace>");
                return;
            }
            string host = args[0];
            string user = args[1];
            string pwd = args[2];
            string defaultNamespace = args[3];

            // This is the line that defines our wbem client. No connection is made
            // to the Cimom until a call is made.
            WbemClient client = new WbemClient(host, user, pwd, defaultNamespace);

            // Connect to the cimom and enumerate classes in the namespace
            Console.Write("Enumerating Classes... ");
            CimClassList items = client.EnumerateClasses();
            Console.WriteLine("Done.\n");

            // Display the results
            Console.WriteLine("Classes in Namespace");
            Console.WriteLine("--------------------");
            foreach (CimClass curItem in items)
            {
                Console.WriteLine(curItem.ClassName);
            }
        }
        public static void Main(string[] args)
        {
            // This first part is to simply setup the connection to the Cimom
            string progName = System.AppDomain.CurrentDomain.FriendlyName;
            if (args.Length != 4)
            {
                Console.WriteLine("Usage: " + progName + " <server name> <username> <password> <namespace>");
                return;
            }
            string host = args[0];
            string user = args[1];
            string pwd = args[2];
            string defaultNamespace = args[3];

            // This is the line that defines our wbem client. No connection is made
            // to the Cimom until a call is made.
            WbemClient client = new WbemClient(host, user, pwd, defaultNamespace);

            GetClassOpSettings settings = new GetClassOpSettings("CIM_NFS");
            settings.LocalOnly = false;

            CimClass mclass = client.GetClass(settings);

            CimInstance newInstance = new CimInstance("CIM_NFS");

            client.CreateInstance(newInstance);
        }
Esempio n. 7
0
        public void CtorTest()
        {
            WbemClient c = new WbemClient("localhost","root","password","smash");

            Assert.IsTrue(c.IsSecure);
            Assert.AreEqual(c.Port,5989);

            c = new WbemClient("localhost",new NetworkCredential("user","password"),"root/cimv2");
        }
Esempio n. 8
0
        private static WbemClient readConfig()
        {
            StreamReader reader = new StreamReader("wbemsharptests.conf");
            string line = reader.ReadLine();
            string [] args = line.Split(' ');

            WbemClient client = new WbemClient(args[0],args[1],args[2],args[3]);

            return client;
        }
        public static void Main(string[] args)
        {
            // This first part is to simply setup the connection to the Cimom
            string progName = System.AppDomain.CurrentDomain.FriendlyName;
            if (args.Length != 4)
            {
                Console.WriteLine("Usage: " + progName + " <server name> <username> <password> <namespace>");
                return;
            }
            string host = args[0];
            string user = args[1];
            string pwd = args[2];
            string defaultNamespace = args[3];

            // This is the line that defines our wbem client. No connection is made
            // to the Cimom until a call is made.
            WbemClient client = new WbemClient(host, user, pwd, defaultNamespace);
        }
Esempio n. 10
0
        public Form1(AuthForm authFrm, Dictionary<string, Dictionary<string, string>> iniSettings)
        {
            mainWbemClient = authFrm.Client;
            ini = iniSettings;

            InitializeComponent();

            // These are used to store the Xml while the XmlVisualizers are not showing
            Wbem.Net.CimomRequest.OnCimomRequest += this.CimomRequestHandler;
            Wbem.Net.CimomResponse.OnCimomResponse += this.CimomResponseHandler;

            CimDataTypeForm.SharedImages = this.imageList1;
            ImageUtils.ImageList = this.imageList1;

            //uxtabControl.SelectedIndex = 1;

            DisplayList(authFrm.ClassList);
        }
Esempio n. 11
0
 public void TearDown()
 {
     client = null;
 }
Esempio n. 12
0
 public void Setup()
 {
     Console.WriteLine("Test setup");
     client = WbemSharpTests.TestClient;
 }
Esempio n. 13
0
        private bool Login()
        {
            if (uxChkBx_UseCustomPort.Checked)
            {
                mainWbemClient = new WbemClient(uxTxtBox_Hostname.Text, (int)uxNumUpDn_Port.Value,
                                                uxTxtBox_Username.Text, uxTxtBox_Password.Text,
                                                uxTxtBox_Namespace.Text);
            }
            else
            {
                mainWbemClient = new WbemClient(uxTxtBox_Hostname.Text, uxTxtBox_Username.Text,
                                                uxTxtBox_Password.Text, uxTxtBox_Namespace.Text);
            }

            mainWbemClient.IsSecure = uxChkBx_UseSSL.Checked;

            try
            {
                // Login and get the data
                //classList = mainWbemClient.EnumerateClassHierarchy();

                CimName className = null;

                EnumerateClassesOpSettings ec = new EnumerateClassesOpSettings(className);
                ec.DeepInheritance = true;
                ec.IncludeClassOrigin = false;
                ec.IncludeQualifiers = false;
                ec.LocalOnly = true;

                CimClassList classList2 = mainWbemClient.EnumerateClasses(ec);
                Dictionary<CimName, CimTreeNode> TreeDictionary = new Dictionary<CimName, CimTreeNode>();

                if (className == null)
                {
                    className = mainWbemClient.DefaultNamespace;
                }

                TreeDictionary.Add(className, new CimTreeNode(className));
                classList = TreeDictionary[className];

                //int cnt = 0;
                //string newClassName = "";

                for (int i = 0; i < classList2.Count; i++)
                {

                    String CurClassName = classList2[i].ClassName.ToString();

                    //if (CurClassName != "CIM_Fan" && CurClassName != "CIM_PowerSupply")
                    if (CurClassName == "CIM_Fan" ||
                        CurClassName == "CIM_PowerSupply" ||
                        CurClassName == "CIM_Processor" ||
                        CurClassName == "CIM_NumericSensor" ||
                        CurClassName == "CIM_NetworkPort")
                    {

                        ec = new EnumerateClassesOpSettings(CurClassName);
                        ec.DeepInheritance = true;
                        ec.IncludeClassOrigin = false;
                        ec.IncludeQualifiers = false;
                        ec.LocalOnly = true;

                        CimClassList classList3 = mainWbemClient.EnumerateClasses(ec);

                        CimClass curClass = classList2[i];
                        CimClass Class1 = mainWbemClient.GetClass(curClass.ClassName);
                        Wbem.CimTreeNode Node1 = new CimTreeNode(Class1.ClassName); //mainWbemClient.EnumerateClassHierarchy(Class1.ClassName);

                        //for (int j = 0; j < classList3.Count; j++)
                        //{
                        CimClass curClass2 = classList3[0];
                        CimClass Class2 = mainWbemClient.GetClass(curClass2.ClassName);
                        //Wbem.CimTreeNode Node2 = mainWbemClient.EnumerateClassHierarchy(Class2.ClassName);
                        //Dictionary<CimName, CimTreeNode> TreeDictionary2 = new Dictionary<CimName, CimTreeNode>();
                        //TreeDictionary2.Add(Class2.ClassName, new CimTreeNode(Class2.ClassName));
                        Wbem.CimTreeNode Node2 = new CimTreeNode(Class2.ClassName); //TreeDictionary2[Class2.ClassName];
                        //Node2.Name = Class2.ClassName;

                        // get the instances
                        Wbem.CimInstanceList ChildrenList = mainWbemClient.EnumerateInstances(curClass2.ClassName);
                        for (int k = 0; k < ChildrenList.Count; k++)
                        {
                            CimInstance CurInstance = ChildrenList[k];
                            CimInstance Instance1 = mainWbemClient.GetInstance(CurInstance.InstanceName);
                            Wbem.CimTreeNode Node3 = new CimTreeNode(CurInstance.Properties["Caption"].Value);
                            Node2.Children.Add(Node3);
                        }

                        Node1.Children.Add(Node2);
                        //    String CurClassName2 = classList3[j].ClassName.ToString();
                        //    EnumerateClassesOpSettings ec2 = new EnumerateClassesOpSettings(CurClassName);
                        //    ec2.DeepInheritance = true;
                        //    ec2.IncludeClassOrigin = false;
                        //    ec2.IncludeQualifiers = false;
                        //    ec2.LocalOnly = true;
                        //    CimClassList classList4 = mainWbemClient.EnumerateClasses(ec2);

                        //    for (int k = 0; k < classList4.Count; k++)
                        //    {
                        //        CimClass curClass3 = classList4[k];
                        //        CimClass Class3 = mainWbemClient.GetClass(curClass3.ClassName);
                        //        Wbem.CimTreeNode Node3 = mainWbemClient.EnumerateClassHierarchy(Class3.ClassName);
                        //        Node2.Children.Add(Node3);
                        //    }

                        //}

                        classList.Children.Add(Node1);
                    }

                    //cnt += 1;
                    //newClassName = cnt.ToString() + "_" + curClass.ClassName;

                    //CimTreeNode curNode = new CimTreeNode(newClassName);

                    //hash.Add(newClassName, curNode);

                    //if (curClass.SuperClass != string.Empty)
                    //{
                    //    if (!hash.ContainsKey(curClass.SuperClass))
                    //    {
                    //        hash.Add(curClass.SuperClass, new CimTreeNode(curClass.SuperClass));
                    //    }
                    //    hash[curClass.SuperClass].Children.Add(curNode);
                    //}
                    //else
                    //{
                    //    hash[className].Children.Add(curNode);
                    //}
                }

                //CimClass Class1 = mainWbemClient.GetClass("CIM_Fan");
                //Wbem.CimTreeNode Node1 = mainWbemClient.EnumerateClassHierarchy(Class1.ClassName);
                //classList.Children.Add(Node1);

                //CimClass Class2 = mainWbemClient.GetClass("OMC_Fan");
                //Wbem.CimTreeNode Node2 = mainWbemClient.EnumerateClassHierarchy(Class2.ClassName);

                ////Class1 = mainWbemClient.GetClass("Fan 6");
                //Wbem.CimInstanceList ChildrenList = mainWbemClient.EnumerateInstances(Class1.ClassName);
                ////classList.Children.Add(Node1);
                ////Wbem.CimTreeNodeList
                //for (int i=0; i < ChildrenList.Count; ++i)
                //{
                //    Wbem.CimTreeNode Item = new Wbem.CimTreeNode();
                //    //Wbem.CimInstanceName
                //    Item.Name = ChildrenList[i].ClassName;
                //    Node2.Children[0].Children.Add(Item);
                //}
                ////for each item in ChildrenList ChildrenList[i];
                ////{
                ////Wbem.CimTreeNodeList
                ////}

                ////Node2.Children[0].Children.Add()

                //classList.Children.Add(Node2);

                //mainWbemClient.Login();
                return true;
            }
            catch (Exception ex)
            {
                mainWbemClient = null;
                MessageBox.Show(ex.Message, "Invalid login");
                return false;
            }
        }
Esempio n. 14
0
 private void changeLoginToolStripMenuItem_Click(object sender, EventArgs e)
 {
     AuthForm newAuth = new AuthForm(ini["[Auth]"]);
     DialogResult result = newAuth.ShowDialog();
     if (result == DialogResult.OK)
     {
         mainWbemClient = newAuth.Client;
         DisplayList(newAuth.ClassList);
     }
     newAuth.Close();
 }
Esempio n. 15
0
        private void changeNamespaceToolStripMenuItem_Click(object sender, EventArgs e)
        {
            NamespaceForm nsForm = new NamespaceForm(mainWbemClient.EnumerateNamespaces());

            if (nsForm.ShowDialog() == DialogResult.OK)
            {
                WbemClient oldwc = mainWbemClient;
                mainWbemClient = new WbemClient(mainWbemClient.Hostname,
                                                mainWbemClient.Username,
                                                mainWbemClient.Password,
                                                nsForm.SelectedNamespace);

                try
                {
                    ResetListViews();

                    DisplayList(mainWbemClient.EnumerateClassHierarchy());
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Invalid login");
                    mainWbemClient = oldwc;
                }
            }
        }