云服务器内容精选

  • 调用API更换弹性公网IP 解绑弹性公网IP。 请在管理控制台或者调用查询云手机服务器详情接口,查询服务器的EIP的ip地址(例如 122.9.102.xxx)。 在弹性公网IP的管理控制台或者调用全量查询弹性公网IP列表接口,通过ip地址查询EIP的id。 调用解绑弹性公网IP的解绑弹性公网IP接口进行解绑。 调用示例如下: curl -i -k -X POST https://{Endpoint}/v3/{project_id}/eip/publicips/{eip_id}/disassociate-instance -H "Content-Type: application/json" -H "X-Auth-Token: ${token}" 绑定弹性公网IP。 严格来讲弹性公网IP实际是绑定到port的,存在空闲port的机器可以进行绑定操作。 根据第1步的指导查询到要绑定的弹性公网IP的id,这个弹性公网IP需要是未绑定状态。 根据CPH的server_id调用查询端口列表接口,查询出服务器的所有port。 调用示例如下: curl -i -k -X GET https://{Endpoint}/v1/{project_id}/ports?instance_id={cph_server_id} -H "Content-Type: application/json" -H "X-Auth-Token: ${token}" 根据port_id调用查询EIP列表接口查询弹性公网IP,可以一次传入一个或多个port_id进行查询,如果哪个port查不到弹性公网IP,则说明它可以绑定弹性公网IP。 调用示例如下: curl -i -k -X GET https://{Endpoint}/v1/{project_id}/publicips?port_id={port_id1}\&port_id={port_id2}\&port_id={port_id3} -H "Content-Type: application/json" -H "X-Auth-Token: ${token}" 对于没有绑定弹性公网IP的port,可以调用绑定弹性公网IP接口,绑定弹性公网IP。 调用示例如下: curl -i -k -X POST https://{Endpoint}/v3/{project_id}/eip/publicips/{eip_id}/associate-instance -H "Content-Type: application/json" -H "X-Auth-Token: ${token}" -d '{"publicip":{"associate_instance_id":"{port_id}","associate_instance_type":"PORT"}}'