savuka1
6 Indium

ASL script question

Hi,

I would like to make multiple queries for data using ASL and was wondering how I do this ASL.

Example:

I would like to extract all routers and then all cards associtaed with each of the routers.

Thanks in advance
James
0 Kudos
45 Replies
8 Krypton

Re: ASL script question

Hi James,

Example of asl script:

START {
.. eol
}
do {
foreach router (getInstances("Router")) {
routerObj = object(router);
print("Router : ".routerObj->Name);
cardObj = routerObj->getCards();
if (!cardObj->isNull()) {
print("Card : ".cardObj->Name);
}
}
}
0 Kudos
savuka1
6 Indium

Re: ASL script question

Hi Hemul

I get the floowing error

ASL-ERROR_OBJECT-Tried to perform a repository operation on a non-object

I think it is todo with some routers not haveing cards, but looking at the code you would think that the if statement should handle that.

Any ideas

Kind Regards
James
0 Kudos
8 Krypton

Re: ASL script question

Sorry Boss, not tested.

Fixed Code:

START {
.. eol
}
do {
foreach router (getInstances("Router")) {
routerObj = object(router);
if (!routerObj->isNull()) {
print("Router : ".routerObj->Name);
cardList = list();
cardList = routerObj->getCards();
foreach card (cardList) {
cardObj = object(card);
if (!cardObj->isNull()) {
print("Card : ".cardObj->Name);
}
}
}
}
}
0 Kudos
savuka1
6 Indium

Re: ASL script question

Hi Hemul,

Thanks, worked like a charm

How much do I owe you ;-)

James
0 Kudos
8 Krypton

Re: ASL script question

Hi James,

Only a few points of happiness on this forum :-)
Do u have ICQ, Skype etc ... ???
0 Kudos
savuka1
6 Indium

Re: ASL script question

Hi Hemul,

Only skype at home , not allow to use it at work

username is welljam

my email address is james.wells@zxxx.com

I have added a few more checks to the code.

####################################

START {
.. eol
}
do {
foreach router (getInstances("Router"))
{
routerObj = object(router);
if (!routerObj->isNull())
{
RouterStatus = (routerObj->IsUnmanagedOrUnresponsive);
if ( RouterStatus != FALSE )
{
print("Router : ".routerObj->Name." IsUnManaged : ".routerObj->IsUnmanagedOrUnresponsive);
}
cardList = list();
cardList = routerObj->getCards();
foreach card (cardList)
{
cardObj = object(card);
if (!cardObj->isNull())
{
Cardstatus = (cardObj->Status);
if ( Cardstatus != "OK" )
{
print("Card : ".cardObj->Name." Status : ".cardObj->Status);
}
}
}
}
}
stop();
}


####################################

I had another question, is it possible to go through a list like routers and switches and not just routers and I also used a stop(); in my code , is this nessasary ?

Kind Regards
James

0 Kudos
8 Krypton

Re: ASL script question

Hi James,

Sure, you should use ICIM_UnitaryCumputerSystem insted router class, for example:



foreach dev (getInstances(ICIM_UnitaryComputerSystem)) {
devObj = object(dev);
if (devObj->Type == Router || devObj->Type == Switch) {
print(devObj->Name);
}
}

Why do you need stop action ?
0 Kudos
8 Krypton

Re: ASL script question

Hi James,

Sure, you should use ICIM_UnitaryCumputerSystem insted router class, for example:


foreach dev (getInstances(ICIM_UnitaryComputerSystem)) {
          devObj = object(dev);
          if (devObj->Type == Router || devObj->Type == Switch) {
                         print(devObj->Name);
          }
}


Why do you need stop action ?
0 Kudos
savuka1
6 Indium

Re: ASL script question

Hi Hemul

Not sure, why do you use a stop statement in ASL, is there a valid purpose, its just I have seen it used on the EMC support site in some examples.

Kind Regards
James
0 Kudos