Ejemplo n.º 1
0
 public VirtualNetworkCard(
     int nicId,
     bool isConnected,
     string networkName,
     bool isPrimaryNetworkConnection,
     IpAddressAllocationModeType ipAddressingMode,
     string ipAddress)
     : base(new RASD_Type())
 {
     this.Init(nicId, isConnected, networkName, isPrimaryNetworkConnection, ipAddressingMode, ipAddress, NetworkAdapterType.E1000);
 }
Ejemplo n.º 2
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
            };
        }