コード例 #1
0
        /// <summary>
        /// Creates a new entry in a GSLB Region pool
        /// </summary>
        /// <param name="zone">The zone to add the entry to</param>
        /// <param name="fqdn">The fqdn to add the entry to</param> 
        /// <param name="address">The IPv4 address of this Node IP</param>
        /// <param name="region">The region to create the pool entry for</param>
        /// <param name="label">A descriptive string describing this IP (may be string.empty)</param>
        /// <param name="weight">A number from 1-15 describing how often this record should be served. Higher means more</param>
        /// <param name="mode">Sets the behavior of this particular record. always - always serve this IP address, obey - Serve this address based upon its monitoring status, remove - Serve this address based upon its monitoring status. However, if it goes down, don't automatically bring it back up when monitoring reports it up, no - Never serve this IP address</param>
        /// <returns>The GSLBRegionPoolEntry that is created or null if failed</returns>
        public net.dynect.api2.GSLBRegionPoolEntry CreateGSLBRegionPoolEntry(string zone, string fqdn, GSLBRegionOption region, string address, string label, IPWeight weight, IPServeMode mode)
        {
            if (sessionData == null)
                return null;

            net.dynect.api2.GSLBRegionPoolEntry retVal = null;
            try
            {
                net.dynect.api2.CreateGSLBRegionPoolEntryRequestType request = new DynSoapWrapper.net.dynect.api2.CreateGSLBRegionPoolEntryRequestType();
                request.token = sessionData.token;
                request.fault_incompat = 1;
                request.fault_incompatSpecified = true;
                request.zone = zone;
                request.fqdn = fqdn;
                request.address = address;
                request.label = label;
                request.region_code = GSLBRegionToString(region);
                if (weight != IPWeight.NONE)
                    request.weight = (int)weight;
                else
                    request.weight = 1;
                request.serve_mode = mode.ToString();
                net.dynect.api2.CreateGSLBRegionPoolEntryResponseType response = dynectWsdl.CreateGSLBRegionPoolEntry(request);

                retVal = response.data;
            }
            catch (Exception ex)
            {
                ;// TODO: Do your custom error handling here....
            }

            return retVal;
        }
コード例 #2
0
        public static string GSLBRegionToString(GSLBRegionOption r)
        {
            switch (r)
            {
                case GSLBRegionOption.USWEST:
                        return "US West";
                case GSLBRegionOption.USCENTRAL:
                        return "US Central";
                case GSLBRegionOption.USEAST:
                        return "US East";
                case GSLBRegionOption.EUWEST:
                        return "EU West";
                case GSLBRegionOption.EUCENTRAL:
                        return "EU Central";
                case GSLBRegionOption.EUEAST:
                        return "EU East";
                case GSLBRegionOption.ASIA:
                        return "Asia";
                case GSLBRegionOption.GLOBAL:
                       return "global";
            }

            return "global";
        }
コード例 #3
0
        /// <summary>
        /// Add or create a Region array to send to the GSLB service 
        /// </summary>
        /// <param name="currenetGSLBRegionArray">The LoadBalanceAddress array to add the LoadBalanceAddress to or null to start a new array</param>
        /// <param name="poolGSLBAddresses">The pool of ip addresses for the added region</param>
        /// <param name="region">GSLB region location</param>
        /// <param name="serveCount">How many records will be returned in each DNS response or -1 to not specify</param>
        /// <param name="failoverMode">Dynect default is 'global': ip - Failover to a particular IP, cname - Failover to a particular CNAME, global - Failover to the global IP address pool</param>
        /// <param name="failoverData">If failover_mode is 'ip', this should be an IPv4 address, If failover_mode is 'cname', this should be a CNAME, If failover_mode is 'global' this should be null or empty</param>
        /// <returns>An array of GSLBRegions to pass to update or create</returns>
        public net.dynect.api2.GSLBRegion[] AddGSLBRegion(net.dynect.api2.GSLBRegion[] currenetGSLBRegionArray, net.dynect.api2.GSLBAddress[] poolGSLBAddresses,
            GSLBRegionOption region, int serveCount, FailoverMode failoverMode, string failoverData)
        {
            net.dynect.api2.GSLBRegion[] retVal = null;
            int index = 0;
            if (currenetGSLBRegionArray == null)
            {
                retVal = new DynSoapWrapper.net.dynect.api2.GSLBRegion[1];
            }
            else
            {
                retVal = new DynSoapWrapper.net.dynect.api2.GSLBRegion[currenetGSLBRegionArray.Length + 1];
                for (index = 0; index < currenetGSLBRegionArray.Length; index++)
                {
                    retVal[index] = currenetGSLBRegionArray[index];
                }
            }

            retVal[index] = new DynSoapWrapper.net.dynect.api2.GSLBRegion();
            retVal[index].failover_data = failoverMode == FailoverMode.global ? string.Empty : failoverData;
            retVal[index].failover_mode = failoverMode.ToString();
            retVal[index].region_code = GSLBRegionToString(region);
            if (serveCount > 0)
            {
                retVal[index].serve_count = serveCount;
                retVal[index].serve_countSpecified = true;
            }
            else
            {
                retVal[index].serve_countSpecified = false;
            }

            retVal[index].pool = poolGSLBAddresses;

            return retVal;
        }
コード例 #4
0
        /// <summary>
        /// Gets all entries from a GSLB service pool
        /// </summary>
        /// <param name="zone">The zone to get the entry from</param>
        /// <param name="fqdn">The fqdn to get the entry from</param> 
        /// <param name="region">The region to get the entry from</param> 
        /// <returns>Array of GSLBRegionPoolEntry objects</returns>
        public net.dynect.api2.GSLBRegionPoolEntry[] GetGSLBRegionPoolEntries(string zone, string fqdn, GSLBRegionOption region)
        {
            if (sessionData == null)
                return null;

            net.dynect.api2.GSLBRegionPoolEntry[] retVal = null;
            try
            {
                net.dynect.api2.GetGSLBRegionPoolEntriesRequestType request = new DynSoapWrapper.net.dynect.api2.GetGSLBRegionPoolEntriesRequestType();
                request.token = sessionData.token;
                request.fault_incompat = 1;
                request.fault_incompatSpecified = true;
                request.zone = zone;
                request.fqdn = fqdn;
                request.region_code = GSLBRegionToString(region);
                net.dynect.api2.GetGSLBRegionPoolEntriesResponseType response = dynectWsdl.GetGSLBRegionPoolEntries(request);

                retVal = response.data;
            }
            catch (Exception ex)
            {
                ;// TODO: Do your custom error handling here....
            }

            return retVal;
        }