Example #1
0
        /// <summary>
        /// Return the ID of a project giving its name. It's case sensitive
        /// </summary>
        /// <param name="projectName">Name of the GNS3 project which ID you plan to get</param>
        /// <param name="host">IP where the GNS3 server is hosted. "localhost" by default</param>
        /// <param name="port">Port where the server is hosted. 3080 by default</param>
        /// <returns>The ID of the project in case it's found. Null otherwise</returns>
        public static string GetProjectIDByName(string projectName, string host = "localhost", ushort port = 3080)
        {
            string id = null;
            List <Dictionary <string, object> > projects = null;

            try
            {
                projects = GNS3sharp.ExtractDictionary($"http://{host}:{port}/v2/projects", "zoom");
            }
            catch { }
            if (projects != null)
            {
                foreach (Dictionary <string, object> project in projects)
                {
                    if (projectName.Equals(project["name"].ToString()))
                    {
                        id = project["project_id"].ToString();
                        break;
                    }
                }
            }
            return(id);
        }
Example #2
0
 /// <summary>
 /// Constructor for any kind of <c>Node</c>. It must be called from a <c>GNS3sharp</c> object
 /// </summary>
 /// <param name="_consoleHost">IP of the machine where the node is hosted</param>
 /// <param name="_port">Port of the machine where the node is hosted</param>
 /// <param name="_name">Name of the node stablished in the project</param>
 /// <param name="_id">ID the node has implicitly</param>
 /// <param name="_ports">Array of dictionaries that contains information about every network interface</param>
 internal Switch(string _consoleHost, ushort _port, string _name, string _id, Status status, GNS3sharp parent,
                 Dictionary <string, dynamic>[] _ports) :
     base(_consoleHost, _port, _name, _id, status, parent, _ports)
 {
 }