当前位置:服务支持 >  技术文档 >  如何通过api获取abaqus许可证信息?

如何通过api获取abaqus许可证信息?

阅读数 1
点赞 0
article_banner
通过 Abaqus 脚本接口获取许可证信息

一、前置说明

Abaqus 的许可体系基于 FlexNet,许可证状态查询并非通过 Abaqus/CAE 的 Python 脚本 API 直接提供,而是借助 Abaqus 附带的许可工具(如 lmutil lmstat)或厂商提供的许可配置工具(如 DS License Server, DSLS)来获取。若使用 DSLS,可通过其命令行工具查询;若使用 FlexNet,则使用 lmutil。Abaqus 脚本环境(abaqus python)可调用这些外部命令并解析输出,从而实现“API 化”获取许可信息。

二、使用 FlexNet 时的推荐做法

确认许可服务器与端口:许可文件(如 simulialm.lic)中通常包含形如 SERVER this_host 27011 的行;若未固定 VENDOR 端口,供应商守护进程 ABAQUSLM 会动态分配端口,可能被防火墙拦截。建议在许可文件中为 VENDOR 指定固定端口,例如:

SERVER 行:SERVER this_host 333ab21b

VENDOR 行:VENDOR ABAQUSLM port=

保存后重启许可服务,并在防火墙中放行 27011/TCP(lmgrd) 与 27012/TCP(ABAQUSLM)。

在 Abaqus 脚本中调用 lmstat 并解析结果(跨平台 Python 示例):import subprocess

import sys

from datetime import datetime

def parse_lmstat(output: str):

info = {"features": [], "users": [], "server": None, "port": None}

cur = {}

for line in output.splitlines():

line = line.strip()

if not line or line.startswith("----"):

continue

if line.startswith("License server status:"):

info["server"] = line.split()[-1]

elif line.startswith("Users of"):

Users of cae: (Total of 5 licenses issued; Total of 2 in use)

toks = line.split()

feat = toks[2].rstrip(":")

issued = int(toks[6].rstrip(";"))

in_use = int(toks[-3])

info["features"].append({"feature": feat, "issued": issued, "in_use": in_use})

elif "start" in line and "expires" in line and "key" in line:

Users of cae: (Total of 5 licenses issued; Total of 2 in use)

user@host (v2022) (start 10/01 09:00) (end 12/31 23:59) 1 licenses

如何通过api获取abaqus许可证信息?

toks = line.split()

user_host = toks[0]

ver = toks[2].strip("()")

start = " ".join(toks[4:6])

end = " ".join(toks[7:9])

used = int(toks[-2])

info["users"].append({

"feature": cur.get("feature"),

"user_host": user_host,

"version": ver,

"start": start,

"end": end,

"used": used

})

elif line.startswith(" "):

缩进行,通常是用户行,需要结合上一行的 feature

cur = {"feature": info["features"][-1]["feature"]} if info["features"] else {}

return info

def get_flexnet_licenses(port_host: str = "27011@server"):

"""

通过 lmutil lmstat 获取 FlexNet 许可状态

:param port_host: 例如 "27011@server" 或 "27000@server"

"""

cmd = ["lmutil", "lmstat", "-a", "-c", port_host]

try:

proc = subprocess.run(cmd, check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, timeout=30)

return parse_lmstat(proc.stdout)

except subprocess.CalledProcessError as e:

print("lmstat 执行失败:", e.stderr, file=sys.stderr)

return None

except subprocess.TimeoutExpired:

print("lmstat 超时", file=sys.stderr)

return None

if __name__ == "__main__":

lic = get_flexnet_licenses("27011@your_server")

if lic:

print("Server:", lic["server"])

print("Features:", lic["features"])

print("Users:", lic["users"])

上述流程与命令(如 lmutil lmstat -a -c 27000@server)是 FlexNet 的标准用法;在脚本中调用即可将结果结构化输出,便于集成到监控或报表系统。

三、使用 DSLS 时的推荐做法

若环境采用 DS License Server(DSLS),可使用其命令行工具(如 dsls)查询许可状态,并在 Abaqus 脚本中调用。典型步骤:

在命令行确认工具可用:dsls -?(查看查询子命令与用法)

在 Abaqus 脚本中调用并解析输出(示例思路):import subprocess

import json, sys

def get_dsls_licenses():

try:

proc = subprocess.run(

["dsls", "-json", "status"], 具体子命令以实际版本为准

check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True

)

return json.loads(proc.stdout)

except Exception as e:

print("DSLS 查询失败:", e, file=sys.stderr)

return None

if __name__ == "__main__":

lic = get_dsls_licenses()

print(lic)

注意:DSLS 的子命令与输出格式会随版本变化,请以本机安装的帮助信息为准,必要时将输出转换为统一的 JSON 结构以便后续处理。

四、常见问题与排查要点

无法连接许可服务或报错(如 FlexNet error: -15,10032):通常意味着 lmgrd 未启动、使用了错误的 port@host、许可文件路径不对,或 ABAQUSLM 的动态端口被防火墙阻断。优先检查服务是否运行,确认 port@host 与许可文件一致,并在防火墙中放行 lmgrd 端口 与 ABAQUSLM 端口;必要时在许可文件中为 VENDOR 指定固定端口并重启服务。

客户端提示 No socket connection to license server manager 或 -7,96:多为许可服务未启动或网络/防火墙阻断。可在 Windows 的 Abaqus Licensing 管理器中执行 Stop Server → Start Server,或按前述方法固定端口并放行防火墙后重试。

相关文章
QR Code
微信扫一扫,欢迎咨询~

联系我们
武汉格发信息技术有限公司
湖北省武汉市经开区科技园西路6号103孵化器
电话:155-2731-8020 座机:027-59821821
邮件:tanzw@gofarlic.com
Copyright © 2023 Gofarsoft Co.,Ltd. 保留所有权利
遇到许可问题?该如何解决!?
评估许可证实际采购量? 
不清楚软件许可证使用数据? 
收到软件厂商律师函!?  
想要少购买点许可证,节省费用? 
收到软件厂商侵权通告!?  
有正版license,但许可证不够用,需要新购? 
联系方式 155-2731-8020
预留信息,一起解决您的问题
* 姓名:
* 手机:

* 公司名称:

姓名不为空

手机不正确

公司不为空