BMC Atrium Discovery Community Forum

forgot password?
   
 
object has no attribute ‘get’
Posted: 08 March 2010 08:19 AM   [ Ignore ]  
RankRankRankRank
Guru
Total Posts:  318
Joined:  2009-10-29

Why do I get “Error while executing a rule—AttributeError: ‘NoneType’ object has no attribute ‘get’” when executing the below. The error triggers on cluster_name

cluster_cmd := discovery.fileGet(host"/%install_root%/config/server.cnf");
    if 
cluster_cmd <> "" then
    log
.debug("Found server.cnf file"); //Try to extract cluster and alias name
        
cluster_name := regex.extract(cluster_cmd.contentregex'cacheName=(\S+)'raw'\1');
        if 
not cluster_name then
        log
.debug("This is no cluster");
        else
        
log.debug("Cluster identified as %cluster_name%");
        
cluster_name := cluster_name;
            
cluster_alias := regex.extract(cluster_cmd.contentregex'aliasList=(\S+)'raw'\1');
            if 
cluster_alias <> "" then
            cluster_alias 
:= cluster_alias;
            
end if;
        
end if;
    
end if; 

I guess it is triggered because the cacheName attribute is not found in the file, but how do I remedy this? If the attribute exists, the code works.

 Signature 

Monitor what matters, model what is monitored

Profile
 
 
Posted: 08 March 2010 08:51 AM   [ Ignore ]   [ # 1 ]  
RankRankRankRank
Guru
Total Posts:  318
Joined:  2009-10-29
Petrus Johansson - 08 March 2010 08:19 AM

Why do I get “Error while executing a rule—AttributeError: ‘NoneType’ object has no attribute ‘get’” when executing the below. The error triggers on cluster_name

cluster_cmd := discovery.fileGet(host"/%install_root%/config/server.cnf");
    if 
cluster_cmd <> "" then
    log
.debug("Found server.cnf file"); //Try to extract cluster and alias name
        
cluster_name := regex.extract(cluster_cmd.contentregex'cacheName=(\S+)'raw'\1');
        if 
not cluster_name then
        log
.debug("This is no cluster");
        else
        
log.debug("Cluster identified as %cluster_name%");
        
cluster_name := cluster_name;
            
cluster_alias := regex.extract(cluster_cmd.contentregex'aliasList=(\S+)'raw'\1');
            if 
cluster_alias <> "" then
            cluster_alias 
:= cluster_alias;
            
end if;
        
end if;
    
end if; 

I guess it is triggered because the cacheName attribute is not found in the file, but how do I remedy this? If the attribute exists, the code works.

Sorry for responding to my own post… But discard this post… The server.cnf file was corrupt :)

 Signature 

Monitor what matters, model what is monitored

Profile
 
 
Posted: 09 March 2010 02:44 PM   [ Ignore ]   [ # 2 ]  
ADDM I Certified
RankRankRankRank
Guru
Total Posts:  123
Joined:  2008-03-19

Nevertheless, you might consider to add something like this:


cluster_cmd := discovery.fileGet(host, “/%install_root%/config/server.cnf”);
if not cluster_cmd then stop;
else <your code>
end if;

Your code doesn’t verify that cluster_cmd actually exists

 Signature 

“with a hip hop the hippie to the hippie
the hip hip a hop a you dont stop the rockin
to the bang bang boogie say up jump the boogie
to the rhythm of the boogie the beat”

Profile
 
 
Posted: 17 March 2010 06:39 PM   [ Ignore ]   [ # 3 ]  
BMC ADDM Staff
RankRankRankRank
Administrator
Total Posts:  286
Joined:  2008-02-01

Actually,

The only line in the code which wasn’t correct was:

if cluster_cmd "" then 

It should be:

if cluster_cmd and cluster_cmd.content then 

discovery.fileGet() returns a node, not a string

Profile