LUALoriotPro WEB site

LoriotPro scripting documentation
Extensions for LUA language

Table of contents Search function

Print the current page Mail this  link UTUBE Channel version française

lpav.InsertObject - Insert a new graphical object from a directory objet

LoriotPro has extended the LUA sripting language by providing its own LUA libraries. The new functions provided are dedicated to the creation of monitoring and SNMP automation application.

Syntax 

result = lpav.InsertObject(type, name, x, y, UID);

Description

Insert a new graphical object in the Active View that is linked to a directory object . The inserted object become the default object.

Parameters

type - The type of object defined in the file loriotinit.lua. LoriotPro will choose the icon that fit with this type.

--lpav object type define --lpav_InsertObject

LPAV_OBJ_WORLD =0;
LPAV_OBJ_COUNTRY =1;
LPAV_OBJ_ORGANIZATION =2;
LPAV_OBJ_ORGANIZATION_UNIT = 3;
LPAV_OBJ_NETWORK =4;
LPAV_OBJ_HOST_1 =6;
LPAV_OBJ_ROUTER =7;
LPAV_OBJ_SHORTCUT_1 =8;
LPAV_OBJ_SHORTCUT_2 =9;
LPAV_OBJ_MRTG =10;
LPAV_OBJ_PLUGIN =11;
LPAV_OBJ_BADPLUGIN = 12;
LPAV_OBJ_LORIOTPRO = 13;
LPAV_OBJ_HOST_2_ROUTER = 15;
LPAV_OBJ_HOST_3_SWITCH =16;
LPAV_OBJ_HOST_4 = 17;
LPAV_OBJ_HOST_5 = 18;
LPAV_OBJ_HOST_6 = 19;
LPAV_OBJ_VIEWPLUGIN =20
LPAV_OBJ_HOST_SERVER = 27;
LPAV_OBJ_HOST_IMPRIMANTE =28;
LPAV_OBJ_HOST_PHONE =29;
LPAV_OBJ_RECT = 30; LPAV_OBJ_CIRCLE = 31; LPAV_OBJ_FILL_RECT = 32; LPAV_OBJ_FILL_CIRCLE = 33; LPAV_OBJ_H_LINE = 34; LPAV_OBJ_V_LINE = 35; LPAV_OBJ_DIR_EMF = 36; LPAV_OBJ_TEXT = 37; LPAV_OBJ_FILL_TEXT = 38; LPAV_OBJ_FULL_RECT = 39; LPAV_OBJ_FULL_CIRCLE = 40; LPAV_OBJ_H45_LINE = 41;
LPAV_OBJ_V45_LINE = 42;
LPAV_OBJ_FULL_TEXT = 43;
LPAV_OBJ_BASIC_SHAPE = 44;
LPAV_OBJ_ANALOGIC_METER_01 = 45;
LPAV_OBJ_HOST_HUB = 46;
LPAV_OBJ_CONNECTOR =144;

name - The name assigned to this graphical object

x - The X position of the object, the number of pixel from the right border of the Active View display area

y - The Y position of the object, the number of pixel from the top border the Active View display area

UID - The directory UID that will be linked to this object. Depending of the object type and of the UID, specific options can be added automatically.

Return Values

result =1 if the object is correctly inserted either return nil

Example

A very powerful example that import the complete Internetwork Map in the Active View. It will also be use as example for the API lpav.


dofile(lp.GetPath().."/config/script/loriotinit.lua");
lpav.DeleteAllSelected();


--lpav.InsertObject(LPAV_OBJ_ORGANIZATION,"toiptest",10,10,4784914268657025847);
--lpav.InsertObject(LPAV_OBJ_HOST_1,"name",20,40,4784914431865783096);
lpav.SetGlobalOption(LPAV_G_MAX_X,3000);
lpav.SetGlobalOption(LPAV_G_MAX_Y,3000);
lpav.SetGlobalOption(LPAV_G_ZOOMAUTO,0);

net,mask=lp.GetFirstNetwork();
i=1;
if i==1 then
while net~=nil do
lp.Trace(net..mask);
if (lp.GetNetworkInformation(net,mask,"a")) then
--lp.Trace(a.name..net..mask);
--if (a.nb_router>0) then lpav.InsertObject(LPAV_OBJ_NETWORK,a.name,a.x,a.y,a.UID) end
if (a.nb_host>0) then lpav.InsertObject(LPAV_OBJ_NETWORK,net,a.x,a.y,a.UID) end
lpav.InsertObject(LPAV_OBJ_NETWORK,net,a.x,a.y,a.UID);
end
net,mask=lp.GetNextNetwork(net,mask);
end
end

lpav.RefreshMap();

router=lp.GetFirstRouter();
while router~=nil do
--lp.Trace("router >"..net);
if lp.GetRouterInformation(router,"a") ==1 then
--lp.Trace("router >"..a.name..router.." "..a.x.." "..a.y);
lpav.InsertObject(LPAV_OBJ_ROUTER,a.name, a.x,a.y,a.UID);
lpav.GetInformation("b1");
ip=lp.GetFirstIP();
while ip~=nil do
lp.GetIPInformation(ip,"aa");
if aa.groupref==lp.atoip(router) then
--lp.Trace("Found router");
net,mask=lp.GetNetworkFromIP(ip);
if net~=nil then
--lp.Trace("Found network");
lp.GetNetworkInformation(net,mask,"aaa");
--lp.Trace("pass GetNetworkInformation");
co=lpav.FindFromAssociedUID(aaa.UID);
if co~=nil then
lpav.GetInformation("b2");
--lp.Trace("pass GetInformation");
c3=lpav.InsertObject(LPAV_OBJ_V_LINE,"connector",1,1,"0");
--lp.Trace("Insert Connector >"..b2.UID.." "..b1.UID);
lpav.SetOption(LPAV_STATUS ,10);
lpav.SetOption(LPAV_OBJECTTYPE ,LPAV_OBJ_CONNECTOR);
lpav.SetOption(LPAV_MAPTYPE ,LPAV_OBJ_CONNECTOR);
lpav.SetOption(LPAV_CONNECTOR_AUTO_ALIGN ,"1");
lpav.SetOption( LPAV_CONNECTED_TO1 ,b2.UID);
lpav.SetOption( LPAV_CONNECTED_TO2 ,b1.UID);
--lp.Trace("SetOption");
end
end
end
ip=lp.GetNextIP(ip);
end
end
lpav.RefreshMap();
router=lp.GetNextRouter(router);
end
lpav.RefreshMap();
lpav.Save(lp.GetPath().."/config/active-view/v.cmp");
--lpav.ClearAllSelected();
--lpav.DeleteAll();


 



www.loriotpro.com