在CMDB中有2个核心概念:
实体
关系
为了灵活管理多个实体,对实体引入了实体组的概念。
-- 建立 顶点 Group
CREATE CLASS Group EXTENDS V;
-- 建立 顶点 Enity
CREATE CLASS Enity EXTENDS V;
--- 建立 边 Relation
CREATE CLASS Relation EXTENDS E;
-- 建立名为“运维资产”的实体组
CREATE VERTEX Group SET name="运维资产";
-- 建立名为“物理机”的实体
CREATE VERTEX Enity SET name="物理机";
-- 建立名为“机架”的实体
CREATE VERTEX Enity SET name="机架";
-- 建立关系 Contain
CREATE CLASS Contain EXTENDS Relation;
-- 建立关系 Lay
CREATE CLASS Lay EXTENDS Relation;
-- 建立关系 RelayOn
CREATE CLASS RelayOn EXTENDS Relation;
-- # contain, lay 直接基于Relation,看起来行不通。
-- CREATE EDGE Relation SET name="属于";
-- CREATE EDGE Relation SET name="放置在";
CREATE EDGE Contain FROM (select from Group where name='运维资产' ) TO ( select from Enity where name='物理机' );
CREATE EDGE Contain FROM (select from Group where name='运维资产' ) TO ( select from Enity where name='机架' );
CREATE EDGE Lay FROM (select from Enity where name='物理机' ) TO ( select from Enity where name='机架' );
-- A实体 和 A实体 无法建立关系。
CREATE EDGE RelayOn FROM (select from Enity where name='物理机' ) TO ( select from Enity where name='物理机' );
-- 实体A 和 实体B 之间可以有多种关系;
CREATE EDGE RelayOn FROM (select from Enity where name='物理机' ) TO ( select from Enity where name='机架' );
image.png
-- 可以建立两个 名为“物理机”的实体A,然后就可以建立关系
CREATE VERTEX Enity SET name="物理机";
CREATE EDGE RelayOn FROM (select from Enity where name='物理机' ) TO ( select from Enity where name='物理机' );
image.png
扩展阅读:
==== 抽象
CREATE CLASS Group EXTENDS V;
CREATE CLASS Enity EXTENDS V;
CREATE CLASS Relation EXTENDS E;
CREATE CLASS Rack EXTENDS Enity;
CREATE CLASS PhysicalMachine EXTENDS Enity;
CREATE CLASS Contain EXTENDS Relation;
CREATE CLASS Lay EXTENDS Relation;
CREATE EDGE Lover FROM (select from Preson where name='小朱') TO (select from Preson where name='小刘');
----
-- CREATE CLASS Relay EXTENDS E;
-- CREATE CLASS Contain EXTENDS E;
CREATE VERTEX Group SET name="运维资产";
CREATE VERTEX Enity SET name="物理机";
CREATE VERTEX Enity SET name="机架";
CREATE VERTEX Relation SET name="属于";
CREATE VERTEX Relation SET name="放置在";
网友评论