Forum Discussion

Alex__Applebaum's avatar
Aug 14, 2012

LTConfig::Field::get_values question

Am trying to set values for syslog config. I can get get/set_value methods to work but would like to set multiple values and am having trouble with get/set_values. Tried several different things but am not getting any values returned for get_values. Am missing something stupid.

 

In [297]: b.LTConfig.Field.get_value.params

 

Out[297]:

 

[(class_instance_key, u'LTConfig.ClassInstanceKey'),

 

(field_instance_name, u'string')]

 

 

In [298]: syslog_instance = b.LTConfig.Class.typefactory.create('LTConfig.ClassInstanceKey')

 

 

In [299]: syslog_instance

 

Out[299]:

 

(LTConfig.ClassInstanceKey){

 

container = None

 

container_class = None

 

class_name = None

 

name = None

 

}

 

 

In [300]: syslog_instance.class_name = "syslog"

 

 

In [301]: syslog_instance.name = "syslog"

 

 

In [302]: b.LTConfig.Field.get_value(class_instance_key = syslog_instance, field_instance_name = 'include')

 

Out[302]: destination loghost { udp(10.20.5.11 port (514)); udp(10.20.4.167 port (514)); };

 

 

In [303]:

 

 

In [303]: b.LTConfig.Field.get_values.params

 

Out[303]:

 

[(class_instance_keys, u'LTConfig.ClassInstanceKeySequence'),

 

(field_instance_names, u'Common.StringSequenceSequence')]

 

 

In [304]: class_instance_key_seq = b.LTConfig.Class.typefactory.create('LTConfig.ClassInstanceKeySequence')

 

 

In [305]: class_instance_key_seq

 

Out[305]:

 

(LTConfig.ClassInstanceKeySequence){

 

_arrayType = ""

 

_offset = ""

 

_id = ""

 

_href=""

 

_arrayType = ""

 

}

 

 

In [306]: class_instance_key_seq.item = [ syslog_instance ]

 

 

In [307]: class_instance_key_seq

 

Out[307]:

 

(LTConfig.ClassInstanceKeySequence){

 

_arrayType = ""

 

_offset = ""

 

_id = ""

 

_href=""

 

item[] =

 

(LTConfig.ClassInstanceKey){

 

container = None

 

container_class = None

 

class_name = "syslog"

 

name = "syslog"

 

},

 

}

 

 

In [308]: field_instance_names_seq = b.LTConfig.Class.typefactory.create('Common.StringSequenceSequence')

 

 

In [309]: field_instance_names_seq

 

Out[309]:

 

(Common.StringSequenceSequence){

 

_arrayType = ""

 

_offset = ""

 

_id = ""

 

_href=""

 

_arrayType = ""

 

}

 

 

In [310]: field_instance_names_seq.item = [ 'include' ]

 

 

In [311]: field_instance_names_seq

 

Out[311]:

 

(Common.StringSequenceSequence){

 

_arrayType = ""

 

_offset = ""

 

_id = ""

 

_href=""

 

item[] =

 

"include",

 

}

 

 

In [312]: b.LTConfig.Field.get_values(class_instance_keys = class_instance_key_seq, field_instance_names = field_instance_names_seq )

 

Out[312]: [[]]

 

 

Note: I don't get an error but don't get any return values. Much less when trying to get multiple fields,

 

 

ex.

 

field_instance_names_seq.item = [ 'include', 'authpriv_from' ]

 

 

Tried various other structures like

 

 

get_values(class_instance_keys = [ syslog_instance ] , field_instance_names = [['include']] )

 

 

to no avail.

 

 

Also Note, there is not an exact one-to-one mapping between output of get_list and tmsh fields (ex. in syntax = authpriv_from vs. auth-priv-from as well as no "remote-servers" field in iControl) Not quite sure why that is ???

 

 

ex.

 

In [325]: b.LTConfig.Field.get_list(class_names = ['syslog'])

 

 

Out[325]: [[authpriv_from, authpriv_to, console_log, cron_from, cron_to, daemon_from, daemon_to, description, include, iso_date, kern_from, kern_to, local6_from, local6_to, mail_from, mail_to, messages_from, messages_to, userlog_from, userlog_to]] In [326]:

 

 

vs. tmsh

 

 

[root@demo:Active] config tmsh list sys syslog all-properties

 

sys syslog {

 

auth-priv-from emerg auth-priv-to emerg cron-from warning cron-to emerg daemon-from notice daemon-to emerg include "destination loghost { udp(10.20.5.11 port (514)); udp(10.20.4.167 port (514)); };" kern-from notice kern-to emerg mail-from notice mail-to emerg messages-from notice messages-to warning remote-servers none user-log-from notice user-log-to emerg

 

}

 

 

6 Replies

  • This looks to me like Python which is foreign to me. Anyone with PyControl knowledge that can shed any insight here. One of these days I'll have to brush up on Python...

     

  • Yeah, must be something specific to python or pycontrol I'm not getting as powershell works just fine.

     

     

    PS C:\Users\user> $LTField.get_values( ($syslog_class_instance) , (,('authpriv_from','authpriv_to','include')) )

     

    notice

     

    emerg

     

    destination loghost { udp(10.20.5.11 port (514)); udp(10.20.4.167 port (514)); };
  • Ahhh Duhhh. Was something stupid as suspected. After doing it in perl and powershell just fine and looking at the xml going across the wire, finally figured it out. I just had to double wrap that python object (can't just feed it an array syntax like perl/powershell, etc.).

     

     

    Perl:

     

    $soapResponse = $Field->get_values(

     

    SOAP::Data->name( class_instance_keys => [ $class_instance_key ] ),

     

    SOAP::Data->name( field_instance_names => [ [@fields] ] )

     

    );

     

     

     

    Python:

     

    In [13]: field_instance_names_seq = b.LTConfig.Class.typefactory.create('Common.StringSequence')

     

     

    In [14]: field_instance_names_seq.item = ['include']

     

     

    In [15]: field_instance_names_seq_seq = b.LTConfig.Class.typefactory.create('Common.StringSequenceSequence')

     

     

    In [17]: field_instance_names_seq_seq

     

    Out[17]:

     

    (Common.StringSequenceSequence){

     

    _arrayType = ""

     

    _offset = ""

     

    _id = ""

     

    _href = ""

     

    _arrayType = ""

     

    }

     

     

    In [18]: field_instance_names_seq_seq.item = field_instance_names_seq

     

     

    In [19]: field_instance_names_seq_seq

     

    Out[19]:

     

    (Common.StringSequenceSequence){

     

    _arrayType = ""

     

    _offset = ""

     

    _id = ""

     

    _href = ""

     

    item =

     

    (Common.StringSequence){

     

    _arrayType = ""

     

    _offset = ""

     

    _id = ""

     

    _href = ""

     

    item[] =

     

    "include",

     

    }

     

    }

     

     

    In [20]: b.LTConfig.Field.get_values(class_instance_keys = class_instance_key_seq, field_instance_names = field_instance_names_seq_seq )

     

    Out[20]: [[destination loghost { udp(10.20.5.11 port (514)); udp(10.20.4.167 port (514)); };]]

     

     

     

    In [21]: field_instance_names_seq.item = ['include','authpriv_from','authpriv_to']

     

     

    In [22]: field_instance_names_seq_seq

     

    Out[22]:

     

    (Common.StringSequenceSequence){

     

    _arrayType = ""

     

    _offset = ""

     

    _id = ""

     

    _href = ""

     

    item =

     

    (Common.StringSequence){

     

    _arrayType = ""

     

    _offset = ""

     

    _id = ""

     

    _href = ""

     

    item[] =

     

    "include",

     

    "authpriv_from",

     

    "authpriv_to",

     

    }

     

    }

     

     

    In [23]: b.LTConfig.Field.get_values(class_instance_keys = class_instance_key_seq, field_instance_name

     

    Out[23]:

     

    [[destination loghost { udp(10.20.5.11 port (514)); udp(10.20.4.167 port (514)); };,

     

    notice,

     

    emerg]]

     

     

    In [24]:

     

  • You may want to isolate this LTConfig code from other parts of your application so it is easy to switch out. We have gotten requests for canned (specific) interfaces for some of the items now supported via LTConfig. We are evaluating whether it is actually worth spending heaps of effort to make an internal bridge that would make the old LTConfig access work if and when we do this.

     

     

    While thinking about this, I posted a query some months ago asking who was using LTConfig, and got either no response or minimal response (can't remember) -- that suggested the answer would be people would welcome a canned interface and we'd disappoint pretty much no one if we simply discontinued the LTConfig access ("killed" or "deprecated immediately") rather than following our normal deprecation policy. LTConfig has always been a little less conceptually secure in terms of changes than the rest of iControl, since it is a window to stuff behind iControl internally, yes, like the rest of iControl, but in this case we get run-time failures if the stuff changes behind iControl rather than compile-time. iControl has a very extensive regression test suite, but I don't off the top of my head remember how extensive our checking of the LTConfig classes is.
    • John_Gruber_432's avatar
      John_Gruber_432
      Historic F5 Account
      So 15 months later... is there a canned interface to set the syslog servers yet?