Ejemplo n.º 1
0
        /// <summary>
        ///
        /// <param name="swytch" />
        /// <param name="vrid" />
        /// <param name="realIps" />
        /// <param name="isHighSpec" />
        /// </summary>
        public LoadBalancer SetInitialParams(Swytch swytch, long vrid, System.Collections.Generic.List <string> realIps, bool isHighSpec = false)
        {
            object annot = this.RawAnnotation;

            this.Vrid = vrid;
            Util.SetByPath(annot, "Switch.ID", swytch._Id());
            if (swytch.Ipv4Nets != null && 0 < swytch.Ipv4Nets.Count)
            {
                Ipv4Net net = swytch.Ipv4Nets[System.Convert.ToInt32(0)];
                this.DefaultRoute = ((string)(net.DefaultRoute));
                this.MaskLen      = System.Convert.ToInt64(net.MaskLen);
            }
            else
            {
                this.DefaultRoute = ((string)(swytch.UserDefaultRoute));
                this.MaskLen      = System.Convert.ToInt64(swytch.UserMaskLen);
            }
            System.Collections.Generic.List <object> servers = new System.Collections.Generic.List <object> {
            };
            for (int __it1 = 0; __it1 < (realIps as System.Collections.IList).Count; __it1++)
            {
                var ip = realIps[__it1];
                (servers as System.Collections.IList).Add(new System.Collections.Generic.Dictionary <string, object> {
                    { "IPAddress", ip }
                });
            }
            Util.SetByPath(annot, "Servers", servers);
            this.PlanId = isHighSpec ? 2 : 1;
            return(this);
        }
Ejemplo n.º 2
0
        /// <summary>このルータ+スイッチにスタティックルートを追加します。
        ///
        /// <param name="maskLen" />
        /// <param name="nextHop" />
        /// <returns>追加されたIPv4ネットワーク</returns>
        /// </summary>
        public Ipv4Net AddStaticRoute(long maskLen, string nextHop)
        {
            Ipv4Net ret = this.Get_router().AddStaticRoute(maskLen, nextHop);

            this.Reload();
            return(ret);
        }
Ejemplo n.º 3
0
 /// <summary>このルータ+スイッチからスタティックルートを削除します。
 ///
 /// <param name="ipv4Net" />
 /// <returns>this</returns>
 /// </summary>
 public Router RemoveStaticRoute(Ipv4Net ipv4Net)
 {
     this._Client.Request("DELETE", this._ApiPath() + "/" + Util.UrlEncode(this._Id()) + "/subnet/" + ipv4Net._Id());
     this.Reload();
     return(this);
 }
Ejemplo n.º 4
0
 /// <summary>(This method is generated in Translator_default#buildImpl)
 ///
 /// <param name="r" />
 /// </summary>
 internal override void ApiDeserializeImpl(object r)
 {
     this.IsNew = r == null;
     if (this.IsNew)
     {
         r = new System.Collections.Generic.Dictionary <string, object> {
         };
     }
     this.IsIncomplete = false;
     if (Util.ExistsPath(r, "ID"))
     {
         this.M_id = Util.GetByPath(r, "ID") == null ? ((string)(null)) : "" + Util.GetByPath(r, "ID");
     }
     else
     {
         this.M_id         = null;
         this.IsIncomplete = true;
     }
     this.N_id = false;
     if (Util.ExistsPath(r, "Name"))
     {
         this.M_name = Util.GetByPath(r, "Name") == null ? ((string)(null)) : "" + Util.GetByPath(r, "Name");
     }
     else
     {
         this.M_name       = null;
         this.IsIncomplete = true;
     }
     this.N_name = false;
     if (Util.ExistsPath(r, "Description"))
     {
         this.M_description = Util.GetByPath(r, "Description") == null ? ((string)(null)) : "" + Util.GetByPath(r, "Description");
     }
     else
     {
         this.M_description = null;
         this.IsIncomplete  = true;
     }
     this.N_description = false;
     if (Util.ExistsPath(r, "Tags"))
     {
         if (Util.GetByPath(r, "Tags") == null)
         {
             this.M_tags = new System.Collections.Generic.List <string> {
             };
         }
         else
         {
             this.M_tags = new System.Collections.Generic.List <string> {
             };
             for (int __it1 = 0; __it1 < (((System.Collections.Generic.List <object>)(Util.GetByPath(r, "Tags"))) as System.Collections.IList).Count; __it1++)
             {
                 var    t  = ((System.Collections.Generic.List <object>)(Util.GetByPath(r, "Tags")))[__it1];
                 string v1 = null;
                 v1 = t == null ? ((string)(null)) : "" + t;
                 (this.M_tags as System.Collections.IList).Add(v1);
             }
         }
     }
     else
     {
         this.M_tags       = null;
         this.IsIncomplete = true;
     }
     this.N_tags = false;
     if (Util.ExistsPath(r, "Icon"))
     {
         this.M_icon = Util.GetByPath(r, "Icon") == null ? null : new Icon(this._Client, Util.GetByPath(r, "Icon"));
     }
     else
     {
         this.M_icon       = null;
         this.IsIncomplete = true;
     }
     this.N_icon = false;
     if (Util.ExistsPath(r, "UserSubnet.DefaultRoute"))
     {
         this.M_userDefaultRoute = Util.GetByPath(r, "UserSubnet.DefaultRoute") == null ? ((string)(null)) : "" + Util.GetByPath(r, "UserSubnet.DefaultRoute");
     }
     else
     {
         this.M_userDefaultRoute = null;
         this.IsIncomplete       = true;
     }
     this.N_userDefaultRoute = false;
     if (Util.ExistsPath(r, "UserSubnet.NetworkMaskLen"))
     {
         this.M_userMaskLen = Util.GetByPath(r, "UserSubnet.NetworkMaskLen") == null?System.Convert.ToInt64(null) : (long)System.Convert.ToInt64("" + "" + Util.GetByPath(r, "UserSubnet.NetworkMaskLen"));
     }
     else
     {
         this.M_userMaskLen = null;
         this.IsIncomplete  = true;
     }
     this.N_userMaskLen = false;
     if (Util.ExistsPath(r, "Internet"))
     {
         this.M_router = Util.GetByPath(r, "Internet") == null ? null : new Router(this._Client, Util.GetByPath(r, "Internet"));
     }
     else
     {
         this.M_router     = null;
         this.IsIncomplete = true;
     }
     this.N_router = false;
     if (Util.ExistsPath(r, "Bridge"))
     {
         this.M_bridge = Util.GetByPath(r, "Bridge") == null ? null : new Bridge(this._Client, Util.GetByPath(r, "Bridge"));
     }
     else
     {
         this.M_bridge     = null;
         this.IsIncomplete = true;
     }
     this.N_bridge = false;
     if (Util.ExistsPath(r, "Subnets"))
     {
         if (Util.GetByPath(r, "Subnets") == null)
         {
             this.M_ipv4Nets = new System.Collections.Generic.List <Ipv4Net> {
             };
         }
         else
         {
             this.M_ipv4Nets = new System.Collections.Generic.List <Ipv4Net> {
             };
             for (int __it2 = 0; __it2 < (((System.Collections.Generic.List <object>)(Util.GetByPath(r, "Subnets"))) as System.Collections.IList).Count; __it2++)
             {
                 var     t  = ((System.Collections.Generic.List <object>)(Util.GetByPath(r, "Subnets")))[__it2];
                 Ipv4Net v2 = null;
                 v2 = t == null ? null : new Ipv4Net(this._Client, t);
                 (this.M_ipv4Nets as System.Collections.IList).Add(v2);
             }
         }
     }
     else
     {
         this.M_ipv4Nets   = null;
         this.IsIncomplete = true;
     }
     this.N_ipv4Nets = false;
     if (Util.ExistsPath(r, "IPv6Nets"))
     {
         if (Util.GetByPath(r, "IPv6Nets") == null)
         {
             this.M_ipv6Nets = new System.Collections.Generic.List <Ipv6Net> {
             };
         }
         else
         {
             this.M_ipv6Nets = new System.Collections.Generic.List <Ipv6Net> {
             };
             for (int __it3 = 0; __it3 < (((System.Collections.Generic.List <object>)(Util.GetByPath(r, "IPv6Nets"))) as System.Collections.IList).Count; __it3++)
             {
                 var     t  = ((System.Collections.Generic.List <object>)(Util.GetByPath(r, "IPv6Nets")))[__it3];
                 Ipv6Net v3 = null;
                 v3 = t == null ? null : new Ipv6Net(this._Client, t);
                 (this.M_ipv6Nets as System.Collections.IList).Add(v3);
             }
         }
     }
     else
     {
         this.M_ipv6Nets   = null;
         this.IsIncomplete = true;
     }
     this.N_ipv6Nets = false;
 }
Ejemplo n.º 5
0
 /// <summary>このルータ+スイッチからスタティックルートを削除します。
 ///
 /// <param name="ipv4Net" />
 /// <returns>this</returns>
 /// </summary>
 public Swytch RemoveStaticRoute(Ipv4Net ipv4Net)
 {
     this.Get_router().RemoveStaticRoute(ipv4Net);
     this.Reload();
     return(this);
 }