hbugs001 发表于 2025-4-8 19:54:47

EVE-NG API中文文档

<h1>1 EVE-NG API 文档</h1>
<h2>1.1 概述</h2>
<p>EVE-NG API 使用 JSend 格式的 JSON 响应,语法如下:</p>
<pre><code class="language-JSON">{ &quot;code&quot;: 404, &quot;message&quot;: &quot;Requested folder does not exist (60008).&quot;, &quot;status&quot;: &quot;fail&quot; }

</code></pre>
<ul>
<li><code>code</code>: HTTP 响应代码。</li>
<li><code>message</code>: 解释当前情况的简单字符串。</li>
<li><code>status</code>: 解释响应的单个单词。以下是五种状态类型:
<ul>
<li><code>success</code>: 用于 20x HTTP 代码。</li>
<li><code>unauthorized</code>: 用于 400 HTTP 代码,表示用户会话已过期。</li>
<li><code>unauthorized</code>: 用于 401 HTTP 代码,表示用户需要登录。</li>
<li><code>forbidden</code>: 用于 403 HTTP 代码,表示用户权限不足。</li>
<li><code>fail</code>: 用于其他 40x HTTP 代码。</li>
<li><code>error</code>: 用于 50x HTTP 代码。</li>
</ul>
</li>
</ul>
<p>默认的 Web-UI 仅使用 API,因此这是开发新 Web-UI 主题、集成等的关键部分。请注意,每个用户只能从一个位置登录。如果同一用户登录两次,第二次登录将禁用第一次登录。</p>
<p>EVE-NG Pro 使用 SSL 协议。所有示例都需要添加 <code>-k</code>和 <code>https</code>作为协议,因此请根据此文档进行调整。</p>
<p><strong>建议</strong>: 由于 EVE-NG 代码的演变,某些调用的文档可能已过时(支持更多参数)。建议使用 GET 方法获取完整的参数集。使用浏览器的开发者工具(网络选项卡)来监视 API 调用,并通过标头、请求和响应获取最新的 API 信息。</p>
<h2>1.2 认证</h2>
<p>以下 API 请求涉及登录和注销过程。所有其他 API 请求都需要经过身份验证的用户。</p>
<h3>1.2.1 登录</h3>
<p><strong>社区版</strong>:</p>
<pre><code class="language-Bash">curl -s -b /tmp/cookie -c /tmp/cookie -X POST -d '{&quot;username&quot;:&quot;admin&quot;,&quot;password&quot;:&quot;eve&quot;}' http://127.0.0.1/api/auth/login

</code></pre>
<p><strong>Pro 版</strong>:</p>
<pre><code class="language-Bash">curl -k -s -b /tmp/cookie -c /tmp/cookie -X POST -d '{&quot;username&quot;:&quot;admin&quot;,&quot;password&quot;:&quot;eve&quot;,&quot;html5&quot;:&quot;0&quot;}' https://127.0.0.1/api/auth/login

</code></pre>
<p>成功登录后,输出如下:</p>
<pre><code class="language-JSON">{ &quot;code&quot;: 200, &quot;message&quot;: &quot;User logged in (90013).&quot;, &quot;status&quot;: &quot;success&quot; }

</code></pre>
<h3>1.2.2 用户信息</h3>
<pre><code class="language-Bash">curl -s -c /tmp/cookie -b /tmp/cookie -X GET -H 'Content-type: application/json' http://127.0.0.1/api/auth

</code></pre>
<p>经过身份验证的用户可以获取自己的信息:</p>
<pre><code class="language-JSON">{
&quot;code&quot;: 200,
&quot;data&quot;: {
    &quot;email&quot;: &quot;root@localhost&quot;,
    &quot;folder&quot;: &quot;/&quot;,
    &quot;lab&quot;: null,
    &quot;lang&quot;: &quot;en&quot;,
    &quot;name&quot;: &quot;EVE-NG Administrator&quot;,
    &quot;role&quot;: &quot;admin&quot;,
    &quot;tenant&quot;: &quot;0&quot;,
    &quot;username&quot;: &quot;admin&quot;
},
&quot;message&quot;: &quot;User has been loaded (90002).&quot;,
&quot;status&quot;: &quot;success&quot;
}

</code></pre>
<h3>1.2.3 注销</h3>
<pre><code class="language-Bash">curl -s -c /tmp/cookie -b /tmp/cookie -X GET -H 'Content-type: application/json' http://127.0.0.1/api/auth/logout

</code></pre>
<p>所有用户都可以注销,此请求不会失败:</p>
<pre><code class="language-JSON">{ &quot;code&quot;: 200, &quot;message&quot;: &quot;User logged out (90019).&quot;, &quot;status&quot;: &quot;success&quot; }

</code></pre>
<h2>1.3 系统状态</h2>
<pre><code class="language-Bash">curl -s -c /tmp/cookie -b /tmp/cookie -X GET -H 'Content-type: application/json' http://127.0.0.1/api/status

</code></pre>
<p>经过身份验证的用户可以获取系统统计信息:</p>
<pre><code class="language-JSON">{
&quot;code&quot;: 200,
&quot;data&quot;: {
    &quot;cached&quot;: 5,
    &quot;cpu&quot;: 1,
    &quot;disk&quot;: 31,
    &quot;dynamips&quot;: 0,
    &quot;iol&quot;: 0,
    &quot;mem&quot;: 8,
    &quot;qemu&quot;: 0,
    &quot;qemu_version&quot;: &quot;2.4.0&quot;,
    &quot;swap&quot;: 0,
    &quot;version&quot;: &quot;development&quot;
},
&quot;message&quot;: &quot;Fetched system status (60001).&quot;,
&quot;status&quot;: &quot;success&quot;
}

</code></pre>
<h2>1.4 列表节点模板</h2>
<pre><code class="language-Bash">curl -s -c /tmp/cookie -b /tmp/cookie -X GET -H 'Content-type: application/json' http://127.0.0.1/api/list/templates/

</code></pre>
<p>经过身份验证的用户可以列出所有可用的节点模板:</p>
<pre><code class="language-JSON">{
&quot;code&quot;: 200,
&quot;data&quot;: {
    &quot;a10&quot;: &quot;A10 vThunder&quot;,
    &quot;acs&quot;: &quot;Cisco ACS&quot;,
    &quot;asa&quot;: &quot;Cisco ASA&quot;,
    &quot;asav&quot;: &quot;Cisco ASAv&quot;,
    &quot;bigip&quot;: &quot;F5 BIG-IP LTM VE&quot;,
    &quot;brocadevadx&quot;: &quot;Brocade vADX&quot;,
    &quot;c1710&quot;: &quot;Cisco IOS 1710 (Dynamips)&quot;,
    &quot;c3725&quot;: &quot;Cisco IOS 3725 (Dynamips)&quot;,
    &quot;c7200&quot;: &quot;Cisco IOS 7206VXR (Dynamips)&quot;,
    &quot;cda&quot;: &quot;Cisco Context Directory Agent&quot;,
    &quot;cips&quot;: &quot;Cisco IPS&quot;,
    &quot;clearpass&quot;: &quot;Aruba ClearPass&quot;,
    &quot;coeus&quot;: &quot;Cisco Web Security Appliance&quot;,
    &quot;cpsg&quot;: &quot;CheckPoint Security Gateway VE&quot;,
    &quot;csr1000v&quot;: &quot;Cisco CSR 1000V&quot;,
    &quot;cumulus&quot;: &quot;Cumulus VX&quot;,
    &quot;extremexos&quot;: &quot;ExtremeXOS&quot;,
    &quot;fortinet&quot;: &quot;Fortinet FortiGate&quot;,
    &quot;hpvsr&quot;: &quot;HP VSR1000&quot;,
    &quot;iol&quot;: &quot;Cisco IOL&quot;,
    &quot;ise&quot;: &quot;Cisco ISE&quot;,
    &quot;linux&quot;: &quot;Linux&quot;,
    &quot;mikrotik&quot;: &quot;MikroTik RouterOS&quot;,
    &quot;nsvpx&quot;: &quot;Citrix Netscaler&quot;,
    &quot;olive&quot;: &quot;Juniper Olive&quot;,
    &quot;ostinato&quot;: &quot;Ostinato&quot;,
    &quot;paloalto&quot;: &quot;Palo Alto VM-100 Firewall&quot;,
    &quot;sourcefire&quot;: &quot;Cisco Sourcefire&quot;,
    &quot;sterra&quot;: &quot;S-Terra&quot;,
    &quot;timos&quot;: &quot;Alcatel 7750 SR&quot;,
    &quot;titanium&quot;: &quot;Cisco NX-OSv (Titanium)&quot;,
    &quot;ucspe&quot;: &quot;Cisco UCS-PE&quot;,
    &quot;veos&quot;: &quot;Arista vEOS&quot;,
    &quot;vios&quot;: &quot;Cisco vIOS&quot;,
    &quot;viosl2&quot;: &quot;Cisco vIOS L2&quot;,
    &quot;vmx&quot;: &quot;Juniper vMX&quot;,
    &quot;vnam&quot;: &quot;Cisco vNAM&quot;,
    &quot;vsrx&quot;: &quot;Juniper vSRX&quot;,
    &quot;vsrxng&quot;: &quot;Juniper vSRX NextGen&quot;,
    &quot;vwaas&quot;: &quot;Cisco vWAAS&quot;,
    &quot;vwlc&quot;: &quot;Cisco vWLC&quot;,
    &quot;vyos&quot;: &quot;VyOS&quot;,
    &quot;win&quot;: &quot;Windows&quot;,
    &quot;xrv&quot;: &quot;Cisco XRv&quot;
},
&quot;message&quot;: &quot;Successfully listed node templates (60003).&quot;,
&quot;status&quot;: &quot;success&quot;
}

</code></pre>
<p>可以列出单个模板:</p>
<pre><code class="language-Bash">curl -s -c /tmp/cookie -b /tmp/cookie -X GET -H 'Content-type: application/json' http://127.0.0.1/api/list/templates/iol

</code></pre>
<p>所选模板的所有可用图像将包含在输出中:</p>
<pre><code class="language-JSON">{
&quot;code&quot;: 200,
&quot;data&quot;: {
    &quot;description&quot;: &quot;Cisco IOL&quot;,
    &quot;options&quot;: {
      &quot;config&quot;: {
      &quot;list&quot;: { &quot;Saved&quot;: &quot;Saved&quot;, &quot;Unconfigured&quot;: &quot;Unconfigured&quot; },
      &quot;name&quot;: &quot;Startup configuration&quot;,
      &quot;type&quot;: &quot;list&quot;,
      &quot;value&quot;: &quot;Unconfigured&quot;
      },
      &quot;delay&quot;: { &quot;name&quot;: &quot;Delay (s)&quot;, &quot;type&quot;: &quot;input&quot;, &quot;value&quot;: 0 },
      &quot;ethernet&quot;: { &quot;name&quot;: &quot;Ethernet portgroups (4 int each)&quot;, &quot;type&quot;: &quot;input&quot;, &quot;value&quot;: 1 },
      &quot;icon&quot;: {
      &quot;list&quot;: {
          &quot;Desktop.png&quot;: &quot;Desktop&quot;,
          &quot;Firewall.png&quot;: &quot;Firewall&quot;,
          &quot;Frame Relay.png&quot;: &quot;Frame Relay&quot;,
          &quot;HUB.png&quot;: &quot;HUB&quot;,
          &quot;Load Balancer.png&quot;: &quot;Load Balancer&quot;,
          &quot;MPLS.png&quot;: &quot;MPLS&quot;,
          &quot;Network Analyzer.png&quot;: &quot;Network Analyzer&quot;,
          &quot;Router.png&quot;: &quot;Router&quot;,
          &quot;Server.png&quot;: &quot;Server&quot;,
          &quot;Switch L3.png&quot;: &quot;Switch L3&quot;,
          &quot;Switch.png&quot;: &quot;Switch&quot;,
          &quot;WAN Optimizer.png&quot;: &quot;WAN Optimizer&quot;
      },
      &quot;name&quot;: &quot;Icon&quot;,
      &quot;type&quot;: &quot;list&quot;,
      &quot;value&quot;: &quot;Router.png&quot;
      },
      &quot;image&quot;: {
      &quot;list&quot;: {
          &quot;L2-IPBASEK9-M-15.1-20130726.bin&quot;: &quot;L2-IPBASEK9-M-15.1-20130726.bin&quot;,
          &quot;L3-ADVENTERPRISEK9-M-15.4-1T.bin&quot;: &quot;L3-ADVENTERPRISEK9-M-15.4-1T.bin&quot;
      },
      &quot;name&quot;: &quot;Image&quot;,
      &quot;type&quot;: &quot;list&quot;,
      &quot;value&quot;: &quot;L3-ADVENTERPRISEK9-M-15.4-1T.bin&quot;
      },
      &quot;name&quot;: { &quot;name&quot;: &quot;Name/prefix&quot;, &quot;type&quot;: &quot;input&quot;, &quot;value&quot;: &quot;R&quot; },
      &quot;nvram&quot;: { &quot;name&quot;: &quot;NVRAM&quot;, &quot;type&quot;: &quot;input&quot;, &quot;value&quot;: 1024 },
      &quot;ram&quot;: { &quot;name&quot;: &quot;RAM&quot;, &quot;type&quot;: &quot;input&quot;, &quot;value&quot;: 256 },
      &quot;serial&quot;: { &quot;name&quot;: &quot;Serial portgroups (4 int each)&quot;, &quot;type&quot;: &quot;input&quot;, &quot;value&quot;: 1 }
    },
    &quot;type&quot;: &quot;iol&quot;
},
&quot;message&quot;: &quot;Successfully listed node template (60032).&quot;,
&quot;status&quot;: &quot;success&quot;
}

</code></pre>
<h2>1.5 列表网络类型</h2>
<pre><code class="language-Bash">curl -s -c /tmp/cookie -b /tmp/cookie -X GET -H 'Content-type: application/json' http://127.0.0.1/api/list/networks

</code></pre>
<p>经过身份验证的用户可以列出所有可用的网络类型:</p>
<pre><code class="language-JSON">{
&quot;code&quot;: 200,
&quot;data&quot;: {
    &quot;bridge&quot;: &quot;bridge&quot;,
    &quot;ovs&quot;: &quot;ovs&quot;,
    &quot;pnet0&quot;: &quot;pnet0&quot;,
    &quot;pnet1&quot;: &quot;pnet1&quot;,
    &quot;pnet2&quot;: &quot;pnet2&quot;,
    &quot;pnet3&quot;: &quot;pnet3&quot;,
    &quot;pnet4&quot;: &quot;pnet4&quot;,
    &quot;pnet5&quot;: &quot;pnet5&quot;,
    &quot;pnet6&quot;: &quot;pnet6&quot;,
    &quot;pnet7&quot;: &quot;pnet7&quot;,
    &quot;pnet8&quot;: &quot;pnet8&quot;,
    &quot;pnet9&quot;: &quot;pnet9&quot;
},
&quot;message&quot;: &quot;Successfully listed network types (60002).&quot;,
&quot;status&quot;: &quot;success&quot;
}

</code></pre>
<h2>1.6 列表用户角色</h2>
<pre><code class="language-Bash">curl -s -c /tmp/cookie -b /tmp/cookie -X GET -H 'Content-type: application/json' http://127.0.0.1/api/list/roles

</code></pre>
<p>经过身份验证的用户可以列出所有用户角色:</p>
<pre><code class="language-JSON">{
&quot;code&quot;: 200,
&quot;data&quot;: { &quot;admin&quot;: &quot;Administrator&quot;, &quot;editor&quot;: &quot;Editor&quot;, &quot;user&quot;: &quot;User&quot; },
&quot;message&quot;: &quot;Successfully listed user roles (60041).&quot;,
&quot;status&quot;: &quot;success&quot;
}

</code></pre>
<h2>1.7 导航文件夹</h2>
<p>以下 API 请求允许管理文件夹和实验室作为文件。</p>
<h3>1.7.1 列出文件夹内容</h3>
<pre><code class="language-Bash">curl -s -c /tmp/cookie -b /tmp/cookie -X GET -H 'Content-type: application/json' http://127.0.0.1/api/folders/User1

</code></pre>
<p>经过身份验证的用户可以列出文件夹中的内容:</p>
<pre><code class="language-JSON">{
&quot;code&quot;: 200,
&quot;data&quot;: {
    &quot;folders&quot;: [
      { &quot;name&quot;: &quot;..&quot;, &quot;path&quot;: &quot;/&quot; },
      { &quot;name&quot;: &quot;Folder 1&quot;, &quot;path&quot;: &quot;/User1/Folder 1&quot; },
      { &quot;name&quot;: &quot;Folder 2&quot;, &quot;path&quot;: &quot;/User1/Folder 2&quot; },
      { &quot;name&quot;: &quot;Folder 3&quot;, &quot;path&quot;: &quot;/User1/Folder 3&quot; }
    ],
    &quot;labs&quot;: [
      { &quot;file&quot;: &quot;Lab 1.unl&quot;, &quot;path&quot;: &quot;/User1/Lab 1.unl&quot; },
      { &quot;file&quot;: &quot;Lab 2.unl&quot;, &quot;path&quot;: &quot;/User1/Lab 2.unl&quot; },
      { &quot;file&quot;: &quot;Lab 3.unl&quot;, &quot;path&quot;: &quot;/User1/Lab 3.unl&quot; }
    ]
},
&quot;message&quot;: &quot;Successfully listed path (60007).&quot;,
&quot;status&quot;: &quot;success&quot;
}

</code></pre>
<p>文件夹和实验室分别使用不同的数组列出。</p>
<h3>1.7.2 添加新文件夹</h3>
<pre><code class="language-Bash">curl -s -c /tmp/cookie -b /tmp/cookie -X POST -d '{&quot;path&quot;:&quot;/User1/Folder 3&quot;,&quot;name&quot;:&quot;New Folder&quot;}' -H 'Content-type: application/json' http://127.0.0.1/api/folders

</code></pre>
<p>经过身份验证的用户可以在特定路径中添加文件夹:</p>
<pre><code class="language-JSON">{ &quot;code&quot;: 200, &quot;message&quot;: &quot;Folder has been created (60014).&quot;, &quot;status&quot;: &quot;success&quot; }

</code></pre>
<h3>1.7.3 移动/重命名现有文件夹</h3>
<pre><code class="language-Bash">curl -s -c /tmp/cookie -b /tmp/cookie -X PUT -d '{&quot;path&quot;:&quot;/User1/Folder 3/Test Folder&quot;}' -H 'Content-type: application/json' http://127.0.0.1/api/folders/User1/Folder%203/New%20Folder

</code></pre>
<p>经过身份验证的用户可以在特定路径中添加文件夹:</p>
<pre><code class="language-JSON">{ &quot;code&quot;: 200, &quot;message&quot;: &quot;Folder moved (60049).&quot;, &quot;status&quot;: &quot;success&quot; }

</code></pre>
<h3>1.7.4 删除现有文件夹</h3>
<pre><code class="language-Bash">curl -s -c /tmp/cookie -b /tmp/cookie -X DELETE -H 'Content-type: application/json' http://127.0.0.1/api/folders/User1/Folder%203/Test%20Folder

</code></pre>
<p>经过身份验证的用户可以删除现有文件夹:</p>
<pre><code class="language-JSON">{ &quot;code&quot;: 200, &quot;message&quot;: &quot;Folder has been deleted (60012).&quot;, &quot;status&quot;: &quot;success&quot; }

</code></pre>
<h2>1.8 管理用户</h2>
<p>以下 API 请求允许管理 EVE-NG 用户和权限。</p>
<h3>1.8.1 获取用户</h3>
<pre><code class="language-Bash">curl -s -c /tmp/cookie -b /tmp/cookie -X GET -H 'Content-type: application/json' http://127.0.0.1/api/users/

</code></pre>
<p>经过身份验证的用户可以获取所有 EVE-NG 用户:</p>
<pre><code class="language-JSON">{
&quot;code&quot;: 200,
&quot;data&quot;: {
    &quot;admin&quot;: {
      &quot;email&quot;: &quot;root@localhost&quot;,
      &quot;expiration&quot;: &quot;-1&quot;,
      &quot;folder&quot;: &quot;/User1&quot;,
      &quot;ip&quot;: &quot;127.0.0.1&quot;,
      &quot;lab&quot;: null,
      &quot;name&quot;: &quot;UNetLab Administrator&quot;,
      &quot;pexpiration&quot;: &quot;-1&quot;,
      &quot;pod&quot;: &quot;0&quot;,
      &quot;role&quot;: &quot;admin&quot;,
      &quot;session&quot;: &quot;1447319929&quot;,
      &quot;username&quot;: &quot;admin&quot;
    },
    &quot;User1&quot;: {
      &quot;email&quot;: &quot;User1.Lastname@gmail.com&quot;,
      &quot;expiration&quot;: &quot;-1&quot;,
      &quot;folder&quot;: &quot;/Featured/Cisco/Basic&quot;,
      &quot;ip&quot;: &quot;192.168.19.1&quot;,
      &quot;lab&quot;: &quot;/Featured/Cisco/Basic/STP.unl&quot;,
      &quot;name&quot;: &quot;User1 Lastname&quot;,
      &quot;pexpiration&quot;: &quot;-1&quot;,
      &quot;pod&quot;: &quot;1&quot;,
      &quot;role&quot;: &quot;admin&quot;,
      &quot;session&quot;: &quot;1447319925&quot;,
      &quot;username&quot;: &quot;User1&quot;
    }
},
&quot;message&quot;: &quot;Successfully listed users (60040).&quot;,
&quot;status&quot;: &quot;success&quot;
}

</code></pre>
<h3>1.8.2 获取单个用户</h3>
<pre><code class="language-Bash">curl -s -c /tmp/cookie -b /tmp/cookie -X GET -H 'Content-type: application/json' http://127.0.0.1/api/users/admin

</code></pre>
<p>输出如下:</p>
<pre><code class="language-JSON">{
&quot;code&quot;: 200,
&quot;data&quot;: {
    &quot;email&quot;: &quot;root@localhost&quot;,
    &quot;expiration&quot;: &quot;-1&quot;,
    &quot;ip&quot;: &quot;127.0.0.1&quot;,
    &quot;name&quot;: &quot;UNetLab Administrator&quot;,
    &quot;pexpiration&quot;: &quot;-1&quot;,
    &quot;pod&quot;: &quot;0&quot;,
    &quot;role&quot;: &quot;admin&quot;,
    &quot;session&quot;: &quot;1447319929&quot;,
    &quot;username&quot;: &quot;admin&quot;
},
&quot;message&quot;: &quot;Successfully listed users (60040).&quot;,
&quot;status&quot;: &quot;success&quot;
}

</code></pre>
<h3>1.8.3 添加新用户</h3>
<pre><code class="language-Bash">curl -s -c /tmp/cookie -b /tmp/cookie -X POST -d '{&quot;username&quot;:&quot;testuser&quot;,&quot;name&quot;:&quot;Test User&quot;,&quot;email&quot;:&quot;test@unetlab.com&quot;,&quot;password&quot;:&quot;testpassword1&quot;,&quot;role&quot;:&quot;user&quot;,&quot;expiration&quot;:&quot;-1&quot;,&quot;pod&quot;:127,&quot;pexpiration&quot;:&quot;1451520000&quot;}' -H 'Content-type: application/json' http://127.0.0.1/api/users

</code></pre>
<p>经过身份验证的用户可以添加新的 EVE-NG 用户:</p>
<pre><code class="language-JSON">{ &quot;code&quot;: 201, &quot;message&quot;: &quot;User saved (60042).&quot;, &quot;status&quot;: &quot;success&quot; }

</code></pre>
<p><strong>参数</strong>:</p>
<ul>
<li><code>email</code>: 用户的电子邮件地址。</li>
<li><code>expiration</code>: 用户的有效期(UNIX 时间戳),如果永不过期则为 <code>-1</code>。</li>
<li><code>name</code>: 用户的描述,通常是称呼。</li>
<li><code>password</code>(必填): 用户登录时使用的密码。</li>
<li><code>role</code>: 参见“列表用户角色”。</li>
<li><code>username</code>(必填): 用于登录的唯一字母数字字符串。</li>
</ul>
<h3>1.8.4 编辑用户</h3>
<pre><code class="language-Bash">curl -s -c /tmp/cookie -b /tmp/cookie -X PUT -d '{&quot;name&quot;:&quot;New Test User&quot;,&quot;email&quot;:&quot;testuser@unetlab.com&quot;,&quot;password&quot;:&quot;newpassword&quot;,&quot;role&quot;:&quot;user&quot;,&quot;expiration&quot;:&quot;1451520000&quot;,&quot;pod&quot;:127,&quot;pexpiration&quot;:&quot;-1&quot;}' -H 'Content-type: application/json' http://127.0.0.1/api/users/testuser

</code></pre>
<p>经过身份验证的用户可以编辑现有的 EVE-NG 用户:</p>
<pre><code class="language-JSON">{ &quot;code&quot;: 200, &quot;message&quot;: &quot;User saved (60042).&quot;, &quot;status&quot;: &quot;success&quot; }

</code></pre>
<p><strong>参数</strong>:</p>
<ul>
<li><code>email</code>: 用户的电子邮件地址。</li>
<li><code>expiration</code>: 用户的有效期(UNIX 时间戳),如果永不过期则为 <code>-1</code>。</li>
<li><code>name</code>: 用户的描述,通常是称呼。</li>
<li><code>password</code>: 用户登录时使用的密码。</li>
<li><code>role</code>: 参见“列表用户角色”。</li>
</ul>
<h3>1.8.5 删除用户</h3>
<pre><code class="language-Bash">curl -s -c /tmp/cookie -b /tmp/cookie -X DELETE -H 'Content-type: application/json' http://127.0.0.1/api/users/testuser

</code></pre>
<p>经过身份验证的用户可以删除现有的 EVE-NG 用户:</p>
<pre><code class="language-JSON">{ &quot;code&quot;: 201, &quot;message&quot;: &quot;User saved (60042).&quot;, &quot;status&quot;: &quot;success&quot; }

</code></pre>
<h2>1.9 管理实验室</h2>
<p>以下 API 请求允许管理实验室以及实验室内的对象,如节点、网络等。</p>
<h3>1.9.1 获取实验室</h3>
<pre><code class="language-Bash">curl -s -c /tmp/cookie -b /tmp/cookie -X GET -H 'Content-type: application/json' http://127.0.0.1/api/labs/User1/Lab%201.unl

</code></pre>
<p>经过身份验证的用户可以检索实验室:</p>
<pre><code class="language-JSON">{
&quot;code&quot;: 200,
&quot;data&quot;: {
    &quot;author&quot;: &quot;User1 Lastname&quot;,
    &quot;body&quot;: &quot;&quot;,
    &quot;description&quot;: &quot;A new test lab.&quot;,
    &quot;filename&quot;: &quot;Lab 1.unl&quot;,
    &quot;id&quot;: &quot;d34628dd-cc1d-4e52-8f91-4a0673985d87&quot;,
    &quot;name&quot;: &quot;Lab 1&quot;,
    &quot;version&quot;: &quot;1&quot;
},
&quot;message&quot;: &quot;Lab has been loaded (60020).&quot;,
&quot;status&quot;: &quot;success&quot;
}

</code></pre>
<h3>1.9.2 获取实验室中的所有网络</h3>
<pre><code class="language-Bash">curl -s -c /tmp/cookie -b /tmp/cookie -X GET -H 'Content-type: application/json' http://127.0.0.1/api/labs/User1/Lab%201.unl/networks

</code></pre>
<p>经过身份验证的用户可以检索实验室中所有配置的网络:</p>
<pre><code class="language-JSON">{
&quot;code&quot;: 200,
&quot;data&quot;: {
    &quot;1&quot;: { &quot;id&quot;: 1, &quot;left&quot;: 409, &quot;name&quot;: &quot;Net OVS&quot;, &quot;top&quot;: 345, &quot;type&quot;: &quot;ovs&quot; },
    &quot;2&quot;: { &quot;id&quot;: 2, &quot;left&quot;: 583, &quot;name&quot;: &quot;Net2&quot;, &quot;top&quot;: 261, &quot;type&quot;: &quot;bridge&quot; },
    &quot;3&quot;: { &quot;id&quot;: 3, &quot;left&quot;: 256, &quot;name&quot;: &quot;Net3&quot;, &quot;top&quot;: 276, &quot;type&quot;: &quot;bridge&quot; },
    &quot;4&quot;: { &quot;id&quot;: 4, &quot;left&quot;: 583, &quot;name&quot;: &quot;Net4&quot;, &quot;top&quot;: 483, &quot;type&quot;: &quot;bridge&quot; },
    &quot;5&quot;: { &quot;id&quot;: 5, &quot;left&quot;: 409, &quot;name&quot;: &quot;Net5&quot;, &quot;top&quot;: 491, &quot;type&quot;: &quot;bridge&quot; }
},
&quot;message&quot;: &quot;Successfully listed networks (60004).&quot;,
&quot;status&quot;: &quot;success&quot;
}

</code></pre>
<h3>1.9.3 获取实验室中的单个网络</h3>
<pre><code class="language-Bash">curl -s -c /tmp/cookie -b /tmp/cookie -X GET -H 'Content-type: application/json' http://127.0.0.1/api/labs/User1/Lab%201.unl/networks/1

</code></pre>
<p>输出如下:</p>
<pre><code class="language-JSON">{
&quot;code&quot;: 200,
&quot;data&quot;: { &quot;left&quot;: 409, &quot;name&quot;: &quot;Net OVS&quot;, &quot;top&quot;: 345, &quot;type&quot;: &quot;ovs&quot; },
&quot;message&quot;: &quot;Successfully listed network (60005).&quot;,
&quot;status&quot;: &quot;success&quot;
}

</code></pre>
<h3>1.9.4 获取实验室中的所有节点</h3>
<pre><code class="language-Bash">curl -s -c /tmp/cookie -b /tmp/cookie -X GET -H 'Content-type: application/json' http://127.0.0.1/api/labs/User1/Lab%201.unl/nodes

</code></pre>
<p>经过身份验证的用户可以检索实验室中所有配置的节点:</p>
<pre><code class="language-JSON">{
&quot;code&quot;: 200,
&quot;data&quot;: {
    &quot;1&quot;: {
      &quot;console&quot;: &quot;telnet&quot;,
      &quot;cpu&quot;: 1,
      &quot;delay&quot;: 0,
      &quot;ethernet&quot;: 4,
      &quot;icon&quot;: &quot;Router.png&quot;,
      &quot;id&quot;: 1,
      &quot;image&quot;: &quot;vios-adventerprisek9-m-15.4-1.3.0.181&quot;,
      &quot;left&quot;: 358,
      &quot;name&quot;: &quot;R1&quot;,
      &quot;ram&quot;: 512,
      &quot;status&quot;: 0,
      &quot;template&quot;: &quot;vios&quot;,
      &quot;top&quot;: 330,
      &quot;type&quot;: &quot;qemu&quot;,
      &quot;url&quot;: &quot;telnet://127.0.0.1:32769&quot;,
      &quot;uuid&quot;: &quot;ab60e9de-2599-4b67-919a-b769fb6e270d&quot;
    },
    &quot;2&quot;: {
      &quot;console&quot;: &quot;telnet&quot;,
      &quot;cpu&quot;: 1,
      &quot;delay&quot;: 0,
      &quot;ethernet&quot;: 4,
      &quot;icon&quot;: &quot;Router.png&quot;,
      &quot;id&quot;: 2,
      &quot;image&quot;: &quot;vios-adventerprisek9-m-15.4-1.3.0.181&quot;,
      &quot;left&quot;: 501,
      &quot;name&quot;: &quot;R2&quot;,
      &quot;ram&quot;: 512,
      &quot;status&quot;: 0,
      &quot;template&quot;: &quot;vios&quot;,
      &quot;top&quot;: 330,
      &quot;type&quot;: &quot;qemu&quot;,
      &quot;url&quot;: &quot;telnet://127.0.0.1:32770&quot;,
      &quot;uuid&quot;: &quot;206323a6-000b-40bc-a765-9c7e7e5751ee&quot;
    },
    &quot;3&quot;: {
      &quot;console&quot;: &quot;telnet&quot;,
      &quot;delay&quot;: 0,
      &quot;ethernet&quot;: 1,
      &quot;icon&quot;: &quot;Router.png&quot;,
      &quot;id&quot;: 3,
      &quot;image&quot;: &quot;L3-ADVENTERPRISEK9-M-15.4-1T.bin&quot;,
      &quot;left&quot;: 430,
      &quot;name&quot;: &quot;R3&quot;,
      &quot;nvram&quot;: 1024,
      &quot;ram&quot;: 256,
      &quot;serial&quot;: 1,
      &quot;status&quot;: 0,
      &quot;template&quot;: &quot;iol&quot;,
      &quot;top&quot;: 529,
      &quot;type&quot;: &quot;iol&quot;,
      &quot;url&quot;: &quot;telnet://127.0.0.1:32771&quot;
    },
    &quot;4&quot;: {
      &quot;console&quot;: &quot;telnet&quot;,
      &quot;delay&quot;: 0,
      &quot;ethernet&quot;: 1,
      &quot;icon&quot;: &quot;Router.png&quot;,
      &quot;id&quot;: 4,
      &quot;image&quot;: &quot;L3-ADVENTERPRISEK9-M-15.4-1T.bin&quot;,
      &quot;left&quot;: 430,
      &quot;name&quot;: &quot;R4&quot;,
      &quot;nvram&quot;: 1024,
      &quot;ram&quot;: 256,
      &quot;serial&quot;: 1,
      &quot;status&quot;: 0,
      &quot;template&quot;: &quot;iol&quot;,
      &quot;top&quot;: 192,
      &quot;type&quot;: &quot;iol&quot;,
      &quot;url&quot;: &quot;telnet://127.0.0.1:32772&quot;
    }
},
&quot;message&quot;: &quot;Successfully listed nodes (60026).&quot;,
&quot;status&quot;: &quot;success&quot;
}

</code></pre>
<h3>1.9.5 获取实验室中的单个节点</h3>
<pre><code class="language-Bash">curl -s -c /tmp/cookie -b /tmp/cookie -X GET -H 'Content-type: application/json' http://127.0.0.1/api/labs/User1/Lab%201.unl/nodes/1

</code></pre>
<p>输出如下:</p>
<pre><code class="language-JSON">{
&quot;code&quot;: 200,
&quot;data&quot;: {
    &quot;config&quot;: &quot;Unconfigured&quot;,
    &quot;console&quot;: &quot;telnet&quot;,
    &quot;cpu&quot;: 1,
    &quot;delay&quot;: 0,
    &quot;ethernet&quot;: 4,
    &quot;icon&quot;: &quot;Router.png&quot;,
    &quot;image&quot;: &quot;vios-adventerprisek9-m-15.4-1.3.0.181&quot;,
    &quot;left&quot;: 358,
    &quot;name&quot;: &quot;R1&quot;,
    &quot;ram&quot;: 512,
    &quot;status&quot;: 0,
    &quot;template&quot;: &quot;vios&quot;,
    &quot;top&quot;: 330,
    &quot;type&quot;: &quot;qemu&quot;,
    &quot;url&quot;: &quot;telnet://127.0.0.1:32769&quot;,
    &quot;uuid&quot;: &quot;ab60e9de-2599-4b67-919a-b769fb6e270d&quot;
},
&quot;message&quot;: &quot;Successfully listed node (60025).&quot;,
&quot;status&quot;: &quot;success&quot;
}

</code></pre>
<h3>1.9.6 启动实验室中的所有节点</h3>
<pre><code class="language-Bash">curl -s -c /tmp/cookie -b /tmp/cookie -X GET -H 'Content-type: application/json' http://127.0.0.1/api/labs/User1/Lab%201.unl/nodes/start

</code></pre>
<p>经过身份验证的用户可以启动实验室中所有配置的节点:</p>
<pre><code class="language-JSON">{ &quot;code&quot;: 400, &quot;message&quot;: &quot;Failed to start node (12).&quot;, &quot;status&quot;: &quot;fail&quot; }

</code></pre>
<h3>1.9.7 启动实验室中的单个节点</h3>
<pre><code class="language-Bash">curl -s -c /tmp/cookie -b /tmp/cookie -X GET -H 'Content-type: application/json' http://127.0.0.1/api/labs/User1/Lab%201.unl/nodes/1/start

</code></pre>
<p>输出如下:</p>
<pre><code class="language-JSON">{ &quot;code&quot;: 200, &quot;message&quot;: &quot;Node started (80049).&quot;, &quot;status&quot;: &quot;success&quot; }

</code></pre>
<h3>1.9.8 停止实验室中的所有节点</h3>
<pre><code class="language-Bash">curl -s -c /tmp/cookie -b /tmp/cookie -X GET -H 'Content-type: application/json' http://127.0.0.1/api/labs/User1/Lab%201.unl/nodes/stop

</code></pre>
<p>经过身份验证的用户可以停止实验室中所有配置的节点:</p>
<pre><code class="language-JSON">{ &quot;code&quot;: 200, &quot;message&quot;: &quot;Nodes stopped (80050).&quot;, &quot;status&quot;: &quot;success&quot; }

</code></pre>
<h3>1.9.9 停止实验室中的单个节点</h3>
<pre><code class="language-Bash">curl -s -c /tmp/cookie -b /tmp/cookie -X GET -H 'Content-type: application/json' http://127.0.0.1/api/labs/User1/Lab%201.unl/nodes/1/stop

</code></pre>
<p>输出如下:</p>
<pre><code class="language-JSON">{ &quot;code&quot;: 200, &quot;message&quot;: &quot;Node stopped (80051).&quot;, &quot;status&quot;: &quot;success&quot; }

</code></pre>
<h3>1.9.10 擦除实验室中的所有节点</h3>
<pre><code class="language-Bash">curl -s -c /tmp/cookie -b /tmp/cookie -X GET -H 'Content-type: application/json' http://127.0.0.1/api/labs/User1/Lab%201.unl/nodes/wipe

</code></pre>
<p>经过身份验证的用户可以擦除实验室中所有配置的节点:</p>
<pre><code class="language-JSON">{ &quot;code&quot;: 200, &quot;message&quot;: &quot;Nodes cleared (80052).&quot;, &quot;status&quot;: &quot;success&quot; }

</code></pre>
<p>擦除意味着删除所有用户配置,包括启动配置、VLAN 等。下次启动时将从选定的映像重建节点</p>
<h3>1.9.11 擦除实验室中的单个节点</h3>
<pre><code class="language-Bash">curl -s -c /tmp/cookie -b /tmp/cookie -X GET -H 'Content-type: application/json' http://127.0.0.1/api/labs/User1/Lab%201.unl/nodes/1/wipe

</code></pre>
<p>输出如下:</p>
<pre><code class="language-JSON">{ &quot;code&quot;: 200, &quot;message&quot;: &quot;Node cleared (80053).&quot;, &quot;status&quot;: &quot;success&quot; }

</code></pre>
<h3>1.9.12 导出实验室中的所有节点配置</h3>
<pre><code class="language-Bash">curl -s -c /tmp/cookie -b /tmp/cookie -X GET -H 'Content-type: application/json' http://127.0.0.1/api/labs/User1/Lab%201.unl/nodes/export

</code></pre>
<p>经过身份验证的用户可以导出实验室中所有配置的节点:</p>
<pre><code class="language-JSON">{ &quot;code&quot;: 200, &quot;message&quot;: &quot;Nodes exported (80057).&quot;, &quot;status&quot;: &quot;success&quot; }

</code></pre>
<p>导出意味着将启动配置保存到实验室文件中。擦除节点后重新启动将加载之前导出的启动配置。</p>
<h3>1.9.13 导出实验室中的单个节点配置</h3>
<pre><code class="language-Bash">curl -s -c /tmp/cookie -b /tmp/cookie -X GET -H 'Content-type: application/json' http://127.0.0.1/api/labs/User1/Lab%201.unl/nodes/1/export

</code></pre>
<p>输出如下:</p>
<pre><code class="language-JSON">{ &quot;code&quot;: 200, &quot;message&quot;: &quot;Node exported (80058).&quot;, &quot;status&quot;: &quot;success&quot; }

</code></pre>
<h3>1.9.14 获取节点的配置接口</h3>
<pre><code class="language-Bash">curl -s -c /tmp/cookie -b /tmp/cookie -X GET -H 'Content-type: application/json' http://127.0.0.1/api/labs/User1/Lab%201.unl/nodes/1/interfaces

</code></pre>
<p>经过身份验证的用户可以检索节点的所有配置接口:</p>
<pre><code class="language-JSON">{
&quot;code&quot;: 200,
&quot;data&quot;: {
    &quot;ethernet&quot;: [
      { &quot;name&quot;: &quot;Gi0/0&quot;, &quot;network_id&quot;: 1 },
      { &quot;name&quot;: &quot;Gi0/1&quot;, &quot;network_id&quot;: 3 },
      { &quot;name&quot;: &quot;Gi0/2&quot;, &quot;network_id&quot;: 5 },
      { &quot;name&quot;: &quot;Gi0/3&quot;, &quot;network_id&quot;: 0 }
    ],
    &quot;serial&quot;: []
},
&quot;message&quot;: &quot;Successfully listed node interfaces (60030).&quot;,
&quot;status&quot;: &quot;success&quot;
}

</code></pre>
<h3>1.9.15 获取实验室拓扑</h3>
<pre><code class="language-Bash">curl -s -c /tmp/cookie -b /tmp/cookie -X GET -H 'Content-type: application/json' http://127.0.0.1/api/labs/User1/Lab%201.unl/topology

</code></pre>
<p>经过身份验证的用户可以获取实验室拓扑:</p>
<pre><code class="language-JSON">{
&quot;code&quot;: 200,
&quot;data&quot;: [
    {
      &quot;destination&quot;: &quot;network1&quot;,
      &quot;destination_label&quot;: &quot;&quot;,
      &quot;destination_type&quot;: &quot;network&quot;,
      &quot;source&quot;: &quot;node1&quot;,
      &quot;source_label&quot;: &quot;Gi0/0&quot;,
      &quot;source_type&quot;: &quot;node&quot;,
      &quot;type&quot;: &quot;ethernet&quot;
    },
    {
      &quot;destination&quot;: &quot;network1&quot;,
      &quot;destination_label&quot;: &quot;&quot;,
      &quot;destination_type&quot;: &quot;network&quot;,
      &quot;source&quot;: &quot;node2&quot;,
      &quot;source_label&quot;: &quot;Gi0/0&quot;,
      &quot;source_type&quot;: &quot;node&quot;,
      &quot;type&quot;: &quot;ethernet&quot;
    },
    {
      &quot;destination&quot;: &quot;network1&quot;,
      &quot;destination_label&quot;: &quot;&quot;,
      &quot;destination_type&quot;: &quot;network&quot;,
      &quot;source&quot;: &quot;node3&quot;,
      &quot;source_label&quot;: &quot;e0/0&quot;,
      &quot;source_type&quot;: &quot;node&quot;,
      &quot;type&quot;: &quot;ethernet&quot;
    },
    {
      &quot;destination&quot;: &quot;node1&quot;,
      &quot;destination_label&quot;: &quot;Gi0/1&quot;,
      &quot;destination_type&quot;: &quot;node&quot;,
      &quot;source&quot;: &quot;node3&quot;,
      &quot;source_label&quot;: &quot;e0/1&quot;,
      &quot;source_type&quot;: &quot;node&quot;,
      &quot;type&quot;: &quot;ethernet&quot;
    },
    {
      &quot;destination&quot;: &quot;node1&quot;,
      &quot;destination_label&quot;: &quot;Gi0/2&quot;,
      &quot;destination_type&quot;: &quot;node&quot;,
      &quot;source&quot;: &quot;node3&quot;,
      &quot;source_label&quot;: &quot;e0/2&quot;,
      &quot;source_type&quot;: &quot;node&quot;,
      &quot;type&quot;: &quot;ethernet&quot;
    },
    {
      &quot;destination&quot;: &quot;network1&quot;,
      &quot;destination_label&quot;: &quot;&quot;,
      &quot;destination_type&quot;: &quot;network&quot;,
      &quot;source&quot;: &quot;node4&quot;,
      &quot;source_label&quot;: &quot;e0/0&quot;,
      &quot;source_type&quot;: &quot;node&quot;,
      &quot;type&quot;: &quot;ethernet&quot;
    },
    {
      &quot;destination&quot;: &quot;node2&quot;,
      &quot;destination_label&quot;: &quot;Gi0/1&quot;,
      &quot;destination_type&quot;: &quot;node&quot;,
      &quot;source&quot;: &quot;node4&quot;,
      &quot;source_label&quot;: &quot;e0/1&quot;,
      &quot;source_type&quot;: &quot;node&quot;,
      &quot;type&quot;: &quot;ethernet&quot;
    },
    {
      &quot;destination&quot;: &quot;node2&quot;,
      &quot;destination_label&quot;: &quot;Gi0/2&quot;,
      &quot;destination_type&quot;: &quot;node&quot;,
      &quot;source&quot;: &quot;node4&quot;,
      &quot;source_label&quot;: &quot;e0/2&quot;,
      &quot;source_type&quot;: &quot;node&quot;,
      &quot;type&quot;: &quot;ethernet&quot;
    }
],
&quot;message&quot;: &quot;Topology loaded&quot;,
&quot;status&quot;: &quot;success&quot;
}

</code></pre>
<h3>1.9.16 获取实验室中的所有图片</h3>
<pre><code class="language-Bash">curl -s -c /tmp/cookie -b /tmp/cookie -X GET -H 'Content-type: application/json' http://127.0.0.1/api/labs/User1/Lab%201.unl/pictures

</code></pre>
<p>经过身份验证的用户可以获取实验室中所有配置的图片:</p>
<pre><code class="language-JSON">{
&quot;code&quot;: 200,
&quot;data&quot;: { &quot;1&quot;: { &quot;height&quot;: 201, &quot;id&quot;: 1, &quot;name&quot;: &quot;RR Logo&quot;, &quot;type&quot;: &quot;image/png&quot;, &quot;width&quot;: 410 } },
&quot;message&quot;: &quot;Successfully listed pictures (60028).&quot;,
&quot;status&quot;: &quot;success&quot;
}

</code></pre>
<h3>1.9.17 获取实验室中的单个图片</h3>
<pre><code class="language-Bash">curl -s -c /tmp/cookie -b /tmp/cookie -X GET -H 'Content-type: application/json' http://127.0.0.1/api/labs/User1/Lab%201.unl/pictures/1

</code></pre>
<p>输出如下:</p>
<pre><code class="language-JSON">{
&quot;code&quot;: 200,
&quot;data&quot;: {
    &quot;height&quot;: 201,
    &quot;id&quot;: &quot;1&quot;,
    &quot;map&quot;: &quot;&lt;area shape='circle' coords='248,66,30' href='telnet://:'&gt;\n&quot;,
    &quot;name&quot;: &quot;RR Logo&quot;,
    &quot;type&quot;: &quot;image/png&quot;,
    &quot;width&quot;: 410
},
&quot;message&quot;: &quot;Picture loaded&quot;,
&quot;status&quot;: &quot;success&quot;
}

</code></pre>
<h3>1.9.18 创建新实验室</h3>
<pre><code class="language-Bash">curl -s -c /tmp/cookie -b /tmp/cookie -X POST -d '{&quot;path&quot;:&quot;/User1/Folder 3&quot;,&quot;name&quot;:&quot;New Lab&quot;,&quot;version&quot;:&quot;1&quot;,&quot;author&quot;:&quot;User1 Lastname&quot;,&quot;description&quot;:&quot;A new demo lab&quot;,&quot;body&quot;:&quot;Lab usage and guide&quot;}' -H 'Content-type: application/json' http://127.0.0.1/api/labs

</code></pre>
<p>经过身份验证的用户可以创建新实验室:</p>
<pre><code class="language-JSON">{ &quot;code&quot;: 200, &quot;message&quot;: &quot;Lab has been created (60019).&quot;, &quot;status&quot;: &quot;success&quot; }

</code></pre>
<h3>1.9.19 将现有实验室移动到不同文件夹</h3>
<pre><code class="language-Bash">curl -s -c /tmp/cookie -b /tmp/cookie -X PUT -d '{&quot;path&quot;:&quot;/User1/Folder 2&quot;}' -H 'Content-type: application/json' http://127.0.0.1/api/labs/User1/Folder%203/New%20Lab.unl/move

</code></pre>
<p>输出如下:</p>
<pre><code class="language-JSON">{ &quot;code&quot;: 200, &quot;message&quot;: &quot;Lab moved (60035).&quot;, &quot;status&quot;: &quot;success&quot; }

</code></pre>
<h3>1.9.20 编辑现有实验室</h3>
<pre><code class="language-Bash">curl -s -c /tmp/cookie -b /tmp/cookie -X PUT -d '{&quot;name&quot;:&quot;Different Lab&quot;,&quot;version&quot;:&quot;2&quot;,&quot;author&quot;:&quot;AD&quot;,&quot;description&quot;:&quot;A different demo lab&quot;}' -H 'Content-type: application/json' http://127.0.0.1/api/labs/User1/Folder%202/New%20Lab.unl

</code></pre>
<p>经过身份验证的用户可以编辑现有实验室:</p>
<pre><code class="language-JSON">{ &quot;code&quot;: 200, &quot;message&quot;: &quot;Lab has been saved (60023).&quot;, &quot;status&quot;: &quot;success&quot; }

</code></pre>
<h3>1.9.21 删除现有实验室</h3>
<pre><code class="language-Bash">curl -s -c /tmp/cookie -b /tmp/cookie -X DELETE -H 'Content-type: application/json' http://127.0.0.1/api/labs/User1/Folder%202/Different%20Lab.unl

</code></pre>
<p>经过身份验证的用户可以删除实验室:</p>
<pre><code class="language-JSON">{ &quot;code&quot;: 200, &quot;message&quot;: &quot;Lab has been deleted (60022).&quot;, &quot;status&quot;: &quot;success&quot; }

</code></pre>
<h3>1.9.22 添加新网络到实验室</h3>
<pre><code class="language-Bash">curl -s -c /tmp/cookie -b /tmp/cookie -X POST -d '{&quot;type&quot;:&quot;bridge&quot;,&quot;name&quot;:&quot;Core Network&quot;,&quot;left&quot;:&quot;35%&quot;,&quot;top&quot;:&quot;25%&quot;}' -H 'Content-type: application/json' http://127.0.0.1/api/labs/User1/Folder%202/Different%20Lab.unl/networks

</code></pre>
<p>经过身份验证的用户可以向现有实验室添加网络:</p>
<pre><code class="language-JSON">{ &quot;code&quot;: 201, &quot;message&quot;: &quot;Network has been added to the lab (60006).&quot;, &quot;status&quot;: &quot;success&quot; }

</code></pre>
<p><strong>参数</strong>:</p>
<ul>
<li><code>left</code>: 左边距,以百分比表示(例如 <code>35%</code>),默认值是 <code>30%</code>到 <code>70%</code>之间的随机值。</li>
<li><code>name</code>: 网络名称(例如 <code>Core Network</code>),默认值是 <code>NetX</code>(<code>X = network_id</code>)。</li>
<li><code>top</code>: 上边距,以百分比表示(例如 <code>25%</code>),默认值是 <code>30%</code>到 <code>70%</code>之间的随机值。</li>
<li><code>type</code>(必填): 参见“列表网络类型”。</li>
</ul>
<h3>1.9.23 添加新节点到实验室</h3>
<pre><code class="language-Bash">curl -s -c /tmp/cookie -b /tmp/cookie -X POST -d '{&quot;type&quot;:&quot;qemu&quot;,&quot;template&quot;:&quot;vios&quot;,&quot;config&quot;:&quot;Unconfigured&quot;,&quot;delay&quot;:0,&quot;icon&quot;:&quot;Router.png&quot;,&quot;image&quot;:&quot;vios-adventerprisek9-m-15.5.3M&quot;,&quot;name&quot;:&quot;Core Router 1&quot;,&quot;left&quot;:&quot;35%&quot;,&quot;top&quot;:&quot;25%&quot;,&quot;ram&quot;:&quot;1024&quot;,&quot;console&quot;:&quot;telnet&quot;,&quot;cpu&quot;:1,&quot;ethernet&quot;:2,&quot;uuid&quot;:&quot;641a4800-1b19-427c-ae87-4a8ee90b7790&quot;}' -H 'Content-type: application/json' http://127.0.0.1/api/labs/User1/Folder%202/Different%20Lab.unl/nodes

</code></pre>
<p>经过身份验证的用户可以向现有实验室添加节点:</p>
<pre><code class="language-JSON">{ &quot;code&quot;: 201, &quot;message&quot;: &quot;Lab has been saved (60023).&quot;, &quot;status&quot;: &quot;success&quot; }

</code></pre>
<p><strong>参数</strong>:</p>
<ul>
<li><code>config</code>: 可以是 <code>Unconfigured</code>或 <code>Saved</code>,默认是 <code>Unconfigured</code>。</li>
<li><code>delay</code>: 启动节点前的等待时间(秒),默认是 <code>0</code>。</li>
<li><code>icon</code>: 用于显示节点的图标(位于 <code>/opt/unetlab/html/images/icons/</code>),默认是 <code>Router.png</code>。</li>
<li><code>image</code>: 用于启动节点的镜像,默认是“列表节点模板”中包含的最新镜像。</li>
<li><code>left</code>: 左边距,以百分比表示(例如 <code>35%</code>),默认值是 <code>30%</code>到 <code>70%</code>之间的随机值。</li>
<li><code>name</code>: 节点名称(例如 <code>Core1</code>),默认值是 <code>NodeX</code>(<code>X = node_id</code>)。</li>
<li><code>ram</code>: 节点配置的 RAM 大小(MB),默认是 <code>1024</code>。</li>
<li><code>template</code>(必填): 参见“列表节点模板”。</li>
<li><code>top</code>: 上边距,以百分比表示(例如 <code>25%</code>),默认值是 <code>30%</code>到 <code>70%</code>之间的随机值。</li>
<li><code>type</code>(必填): 可以是 <code>iol</code>、<code>dynamips</code>或 <code>qemu</code>。</li>
</ul>
<p><strong>IOL 节点参数</strong>:</p>
<ul>
<li><code>ethernet</code>: 以太网端口组的数量(每个端口组配置四个接口),默认是 <code>2</code>。</li>
<li><code>nvram</code>: NVRAM 的大小(KB),默认是 <code>1024</code>。</li>
<li><code>serial</code>: 串行端口组的数量(每个端口组配置四个接口),默认是 <code>2</code>。</li>
</ul>
<p><strong>Dynamips 节点参数</strong>:</p>
<ul>
<li><code>idlepc</code>: 用于 Dynamips 优化的值(例如 <code>0x80369ac4</code>),默认是 <code>0x0</code>(无优化)。</li>
<li><code>nvram</code>: NVRAM 的大小(KB),默认是 <code>1024</code>。</li>
<li><code>slot+</code>: 配置在特定插槽中的模块(例如 <code>slot1=NM-1FE-TX</code>)。</li>
</ul>
<p><strong>QEMU 节点参数</strong>:</p>
<ul>
<li><code>console</code>: 可以是 <code>telnet</code>或 <code>vnc</code>,默认是 <code>telnet</code>。</li>
<li><code>cpu</code>: 配置的 CPU 数量,默认是 <code>1</code>。</li>
<li><code>ethernet</code>: 以太网接口的数量,默认是 4。</li>
<li><code>uuid</code>: 配置的 UUID,默认是随机 UUID(例如 <code>641a4800-1b19-427c-ae87-4a8ee90b7790</code>)。</li>
</ul>
<hr />
<h2>1.10 总结</h2>
<p>EVE-NG API 提供了丰富的功能,允许用户通过编程方式管理实验室、节点、网络、用户等。通过使用 API,可以实现自动化操作、集成到其他系统或开发自定义 Web-UI 主题。</p>
<p><strong>注意事项</strong>:</p>
<ol>
<li>EVE-NG Pro 使用 SSL 协议,所有请求需要使用 <code>https</code>和 <code>-k</code>参数。</li>
<li>由于 EVE-NG 代码的不断更新,某些 API 文档可能已过时。建议使用浏览器的开发者工具监控 API 调用,以获取最新的参数和功能。</li>
<li>每个用户只能从一个位置登录,重复登录会禁用之前的会话。</li>
</ol>
<p>通过合理利用 EVE-NG API,可以极大地提高实验室管理的效率和灵活性。</p>

Guangran 发表于 2025-4-8 20:07:37

<p>有了Markdown以后友好好多了。</p>

lizhouppts 发表于 7 天前

<p>谢谢楼主分享!!!</p>
页: [1]
查看完整版本: EVE-NG API中文文档