コード例 #1
0
        /// <summary>
        /// Method to modify the NetworkResourcePool
        /// </summary>
        /// <param name="dvSwitchName"></param>
        /// <param name="nrpName"></param>
        /// <param name="noOfShares"></param>
        /// <param name="level"></param>
        /// <param name="prioritytag"></param>
        /// <param name="hostLimit"></param>
        private void ModifyNetworkResourcePool(string dvSwitchName, string nrpName,
                                               int noOfShares, string level, string prioritytag,
                                               string hostLimit)
        {
            ManagedObjectReference dvsMor = cb._svcUtil.getEntityByName("VmwareDistributedVirtualSwitch", dvSwitchName);

            DVSNetworkResourcePool[] nrpList = null;
            if (dvsMor != null)
            {
                string[]        type       = new string[] { "networkResourcePool" };
                ObjectContent[] objContent = cb.getServiceUtil().GetObjectProperties(null, dvsMor, type);
                if (objContent != null)
                {
                    nrpList = (DVSNetworkResourcePool[])objContent[0].propSet[0].val;
                }
                if (nrpList != null)
                {
                    String configVersion = null;
                    String nrpKey        = null;
                    foreach (DVSNetworkResourcePool dvsNrp in nrpList)
                    {
                        if (dvsNrp.name.Equals(nrpName))
                        {
                            nrpKey        = dvsNrp.key;
                            configVersion = dvsNrp.configVersion;
                            break;
                        }
                    }
                    if (nrpKey == null)
                    {
                        throw new Exception("NetworkResource Pool " + nrpName
                                            + " Not Found");
                    }

                    DVSNetworkResourcePoolConfigSpec networkRPconfigSpec =
                        new DVSNetworkResourcePoolConfigSpec();
                    DVSNetworkResourcePoolAllocationInfo allocationInfo =
                        new DVSNetworkResourcePoolAllocationInfo();
                    if (level != null)
                    {
                        SharesInfo shares = new SharesInfo();
                        if (noOfShares != -1)
                        {
                            shares.level  = SharesLevel.custom;
                            shares.shares = noOfShares;
                        }
                        else
                        {
                            if (level.Equals(SharesLevel.high))
                            {
                                shares.level = SharesLevel.high;
                            }
                            else if (level.Equals(SharesLevel.low))
                            {
                                shares.level = SharesLevel.low;
                            }
                            else if (level.Equals(SharesLevel.normal))
                            {
                                shares.level = SharesLevel.normal;
                            }
                        }
                        allocationInfo.shares = shares;
                    }

                    if (hostLimit != null)
                    {
                        allocationInfo.limit = long.Parse(hostLimit);
                    }
                    if (prioritytag != null)
                    {
                        allocationInfo.priorityTag = int.Parse(prioritytag);
                    }
                    networkRPconfigSpec.configVersion  = configVersion;
                    networkRPconfigSpec.key            = nrpKey;
                    networkRPconfigSpec.allocationInfo = allocationInfo;
                    DVSNetworkResourcePoolConfigSpec[] configSpec = new
                                                                    DVSNetworkResourcePoolConfigSpec[] { networkRPconfigSpec };
                    cb._connection._service.UpdateNetworkResourcePool(dvsMor, configSpec);
                    Console.WriteLine("Susccessfully modified Network Resource Pool :" + nrpName);
                }
                else
                {
                    Console.WriteLine("No NetworkResourcePool found for DVS Switch "
                                      + dvSwitchName);
                    return;
                }
            }

            else
            {
                throw new Exception("DVS Switch " + dvSwitchName + " Not Found");
            }
        }
コード例 #2
0
        /// <summary>
        /// Method to modify the NetworkResourcePool
        /// </summary>
        /// <param name="dvSwitchName"></param>
        /// <param name="nrpName"></param>
        /// <param name="noOfShares"></param>
        /// <param name="level"></param>
        /// <param name="prioritytag"></param>
        /// <param name="hostLimit"></param>
        private void ModifyNetworkResourcePool(string dvSwitchName, string nrpName,
                                             int noOfShares, string level, string prioritytag,
                                              string hostLimit)
        {
            ManagedObjectReference dvsMor = cb._svcUtil.getEntityByName("VmwareDistributedVirtualSwitch", dvSwitchName);
            DVSNetworkResourcePool[] nrpList = null;
            if (dvsMor != null)
            {
                string[] type = new string[] { "networkResourcePool" };
                ObjectContent[] objContent = cb.getServiceUtil().GetObjectProperties(null, dvsMor, type);
                if (objContent != null)
                {
                    nrpList = (DVSNetworkResourcePool[])objContent[0].propSet[0].val;
                }
                if (nrpList != null)
                {
                    String configVersion = null;
                    String nrpKey = null;
                    foreach (DVSNetworkResourcePool dvsNrp in nrpList)
                    {
                        if (dvsNrp.name.Equals(nrpName))
                        {
                            nrpKey = dvsNrp.key;
                            configVersion = dvsNrp.configVersion;
                            break;
                        }
                    }
                    if (nrpKey == null)
                    {
                        throw new Exception("NetworkResource Pool " + nrpName
                              + " Not Found");
                    }

                    DVSNetworkResourcePoolConfigSpec networkRPconfigSpec =
                        new DVSNetworkResourcePoolConfigSpec();
                    DVSNetworkResourcePoolAllocationInfo allocationInfo =
                                    new DVSNetworkResourcePoolAllocationInfo();
                    if (level != null)
                    {
                        SharesInfo shares = new SharesInfo();
                        if (noOfShares != -1)
                        {
                            shares.level = SharesLevel.custom;
                            shares.shares = noOfShares;
                        }
                        else
                        {
                            if (level.Equals(SharesLevel.high))
                            { shares.level = SharesLevel.high; }
                            else if (level.Equals(SharesLevel.low))
                            { shares.level = SharesLevel.low; }
                            else if (level.Equals(SharesLevel.normal))
                            { shares.level = SharesLevel.normal; }
                        }
                        allocationInfo.shares = shares;
                    }

                    if (hostLimit != null)
                    {
                        allocationInfo.limit = long.Parse(hostLimit);
                    }
                    if (prioritytag != null)
                    {
                        allocationInfo.priorityTag = int.Parse(prioritytag);
                    }
                    networkRPconfigSpec.configVersion = configVersion;
                    networkRPconfigSpec.key = nrpKey;
                    networkRPconfigSpec.allocationInfo = allocationInfo;
                    DVSNetworkResourcePoolConfigSpec[] configSpec = new
                        DVSNetworkResourcePoolConfigSpec[] { networkRPconfigSpec };
                    cb._connection._service.UpdateNetworkResourcePool(dvsMor, configSpec);
                    Console.WriteLine("Susccessfully modified Network Resource Pool :" + nrpName);
                }
                else
                {
                    Console.WriteLine("No NetworkResourcePool found for DVS Switch "
                          + dvSwitchName);
                    return;
                }
            }

            else
            {
                throw new Exception("DVS Switch " + dvSwitchName + " Not Found");
            }
        }
コード例 #3
0
        /// <summary>
        /// Method to add a resource Pool
        /// </summary>
        /// <param name="dvSwitchName">string</param>
        /// <param name="nrpName">string</param>
        /// <param name="nrpDesc">string</param>
        /// <param name="noOfShares">int</param>
        /// <param name="level">string</param>
        /// <param name="prioritytag">string</param>
        /// <param name="hostLimit">string</param>
        private void AddNetworkResourcePool(string dvSwitchName, string nrpName,
                                            string nrpDesc, int noOfShares, string level,
                                            string prioritytag, string hostLimit)
        {
            ManagedObjectReference dvsMor = cb._svcUtil.getEntityByName("VmwareDistributedVirtualSwitch", dvSwitchName);

            if (dvsMor != null)
            {
                DVSNetworkResourcePoolConfigSpec     networkRPconfigSpec = new DVSNetworkResourcePoolConfigSpec();
                DVSNetworkResourcePoolAllocationInfo allocationInfo      =
                    new DVSNetworkResourcePoolAllocationInfo();
                if (level != null)
                {
                    SharesInfo shares = new SharesInfo();
                    if (noOfShares != -1)
                    {
                        shares.level  = SharesLevel.custom;
                        shares.shares = noOfShares;
                    }
                    else
                    {
                        if (level.Equals(SharesLevel.high))
                        {
                            shares.level = SharesLevel.high;
                        }
                        else if (level.Equals(SharesLevel.low))
                        {
                            shares.level = SharesLevel.low;
                        }
                        else if (level.Equals(SharesLevel.normal))
                        {
                            shares.level = SharesLevel.normal;
                        }
                    }
                    allocationInfo.shares = shares;
                }

                if (hostLimit != null)
                {
                    allocationInfo.limit = long.Parse(hostLimit);
                }
                if (prioritytag != null)
                {
                    allocationInfo.priorityTag = int.Parse(prioritytag);
                }
                networkRPconfigSpec.configVersion = "0";
                if (nrpDesc != null)
                {
                    networkRPconfigSpec.description = nrpDesc;
                }
                else
                {
                    networkRPconfigSpec.description = nrpName;
                }
                networkRPconfigSpec.name           = nrpName;
                networkRPconfigSpec.allocationInfo = allocationInfo;
                networkRPconfigSpec.key            = "";
                DVSNetworkResourcePoolConfigSpec[] networkRPconfigSpecs = new DVSNetworkResourcePoolConfigSpec[] { networkRPconfigSpec };
                cb.getConnection().Service.AddNetworkResourcePool(dvsMor, networkRPconfigSpecs);
                Console.WriteLine("Susccessfully added Network Resource Pool :" + nrpName);
            }
            else
            {
                throw new Exception("DVS Switch " + dvSwitchName + " Not Found");
            }
        }
コード例 #4
0
        /// <summary>
        /// Method to add a resource Pool
        /// </summary>
        /// <param name="dvSwitchName">string</param>
        /// <param name="nrpName">string</param>
        /// <param name="nrpDesc">string</param>
        /// <param name="noOfShares">int</param>
        /// <param name="level">string</param>
        /// <param name="prioritytag">string</param>
        /// <param name="hostLimit">string</param>
        private void AddNetworkResourcePool(string dvSwitchName, string nrpName,
                                           string nrpDesc, int noOfShares, string level,
                                           string prioritytag, string hostLimit)
        {
            ManagedObjectReference dvsMor = cb._svcUtil.getEntityByName("VmwareDistributedVirtualSwitch", dvSwitchName);
            if (dvsMor != null)
            {
                DVSNetworkResourcePoolConfigSpec networkRPconfigSpec = new DVSNetworkResourcePoolConfigSpec();
                DVSNetworkResourcePoolAllocationInfo allocationInfo =
                                   new DVSNetworkResourcePoolAllocationInfo();
                if (level != null)
                {
                    SharesInfo shares = new SharesInfo();
                    if (noOfShares != -1)
                    {
                        shares.level = SharesLevel.custom;
                        shares.shares = noOfShares;
                    }
                    else
                    {
                        if (level.Equals(SharesLevel.high))
                        { shares.level = SharesLevel.high; }
                        else if (level.Equals(SharesLevel.low))
                        { shares.level = SharesLevel.low; }
                        else if (level.Equals(SharesLevel.normal))
                        { shares.level = SharesLevel.normal; }
                    }
                    allocationInfo.shares = shares;
                }

                if (hostLimit != null)
                {
                    allocationInfo.limit = long.Parse(hostLimit);
                }
                if (prioritytag != null)
                {
                    allocationInfo.priorityTag = int.Parse(prioritytag);
                }
                networkRPconfigSpec.configVersion = "0";
                if (nrpDesc != null)
                {
                    networkRPconfigSpec.description = nrpDesc;
                }
                else
                {
                    networkRPconfigSpec.description = nrpName;
                }
                networkRPconfigSpec.name = nrpName;
                networkRPconfigSpec.allocationInfo = allocationInfo;
                networkRPconfigSpec.key = "";
                DVSNetworkResourcePoolConfigSpec[] networkRPconfigSpecs = new DVSNetworkResourcePoolConfigSpec[] { networkRPconfigSpec };
                cb.getConnection().Service.AddNetworkResourcePool(dvsMor, networkRPconfigSpecs);
                Console.WriteLine("Susccessfully added Network Resource Pool :" + nrpName);
            }
            else
            {
                throw new Exception("DVS Switch " + dvSwitchName + " Not Found");
            }
        }