コード例 #1
0
        public VirtualDisk(long diskSize, BusType busType, BusSubType busSubType)
            : base(new RASD_Type())
        {
            cimString           cimString1       = new cimString();
            List <XmlAttribute> xmlAttributeList = new List <XmlAttribute>();
            XmlDocument         xmlDocument      = new XmlDocument();

            if (busType.Value().Equals(BusType.IDE.Value()))
            {
                XmlAttribute attribute = xmlDocument.CreateAttribute("vcloud", nameof(busType), "http://www.vmware.com/vcloud/v1.5");
                attribute.Value = "5";
                xmlAttributeList.Add(attribute);
            }
            else
            {
                XmlAttribute attribute1 = xmlDocument.CreateAttribute("vcloud", nameof(busSubType), "http://www.vmware.com/vcloud/v1.5");
                attribute1.Value = busSubType.Value();
                XmlAttribute attribute2 = xmlDocument.CreateAttribute("vcloud", nameof(busType), "http://www.vmware.com/vcloud/v1.5");
                attribute2.Value = "6";
                xmlAttributeList.Add(attribute1);
                xmlAttributeList.Add(attribute2);
            }
            XmlAttribute attribute3 = xmlDocument.CreateAttribute("vcloud", "capacity", "http://www.vmware.com/vcloud/v1.5");

            attribute3.Value = diskSize.ToString();
            xmlAttributeList.Add(attribute3);
            if (cimString1.AnyAttr == null)
            {
                cimString1.AnyAttr = xmlAttributeList.ToArray();
            }
            else
            {
                List <XmlAttribute> list = ((IEnumerable <XmlAttribute>)cimString1.AnyAttr).ToList <XmlAttribute>();
                list.AddRange((IEnumerable <XmlAttribute>)xmlAttributeList);
                cimString1.AnyAttr = list.ToArray();
            }
            cimString cimString2 = new cimString();

            cimString2.Value = "";
            cimString cimString3 = new cimString();

            cimString3.Value = "";
            ResourceType1 resourceType1 = new ResourceType1();

            resourceType1.Value = "17";
            RASD_Type itemResource = this.GetItemResource();

            itemResource.ElementName  = cimString2;
            itemResource.InstanceID   = cimString3;
            itemResource.ResourceType = resourceType1;
            itemResource.HostResource = new cimString[1]
            {
                cimString1
            };
        }
コード例 #2
0
 internal string GetCimStringAttributeValue(cimString cimStrings, string attributeName)
 {
     if (cimStrings.AnyAttr != null)
     {
         foreach (XmlAttribute xmlAttribute in cimStrings.AnyAttr)
         {
             if (xmlAttribute.LocalName.Equals(attributeName))
             {
                 return(xmlAttribute.Value);
             }
         }
     }
     return((string)null);
 }
コード例 #3
0
        private void Init(
            int nicId,
            bool isConnected,
            string networkName,
            bool isPrimaryNetworkConnection,
            IpAddressAllocationModeType ipAddressingMode,
            string ipAddress,
            NetworkAdapterType adapterType)
        {
            cimString cimString1 = new cimString();

            cimString1.Value = networkName;
            List <XmlAttribute> xmlAttributeList = new List <XmlAttribute>();
            XmlDocument         xmlDocument      = new XmlDocument();
            XmlAttribute        attribute1       = xmlDocument.CreateAttribute("vcloud", nameof(ipAddress), "http://www.vmware.com/vcloud/v1.5");

            attribute1.Value = ipAddress;
            XmlAttribute attribute2 = xmlDocument.CreateAttribute("vcloud", "primaryNetworkConnection", "http://www.vmware.com/vcloud/v1.5");

            attribute2.Value = isPrimaryNetworkConnection.ToString();
            XmlAttribute attribute3 = xmlDocument.CreateAttribute("vcloud", nameof(ipAddressingMode), "http://www.vmware.com/vcloud/v1.5");

            attribute3.Value = ipAddressingMode.Value();
            xmlAttributeList.Add(attribute1);
            xmlAttributeList.Add(attribute2);
            xmlAttributeList.Add(attribute3);
            if (cimString1.AnyAttr == null)
            {
                cimString1.AnyAttr = xmlAttributeList.ToArray();
            }
            else
            {
                List <XmlAttribute> list = ((IEnumerable <XmlAttribute>)cimString1.AnyAttr).ToList <XmlAttribute>();
                list.AddRange((IEnumerable <XmlAttribute>)xmlAttributeList);
                cimString1.AnyAttr = list.ToArray();
            }
            cimString cimString2 = new cimString();

            cimString2.Value = "";
            cimString cimString3 = new cimString();

            cimString3.Value = "";
            cimString cimString4 = new cimString();

            cimString4.Value = nicId.ToString();
            cimBoolean cimBoolean = new cimBoolean();

            cimBoolean.Value = isConnected;
            ResourceType1 resourceType1 = new ResourceType1();

            resourceType1.Value = "10";
            cimString cimString5 = new cimString();

            cimString5.Value = adapterType.Value();
            RASD_Type itemResource = this.GetItemResource();

            itemResource.ElementName         = cimString2;
            itemResource.InstanceID          = cimString3;
            itemResource.ResourceType        = resourceType1;
            itemResource.ResourceSubType     = cimString5;
            itemResource.AddressOnParent     = cimString4;
            itemResource.AutomaticAllocation = cimBoolean;
            itemResource.Connection          = new cimString[1]
            {
                cimString1
            };
        }