#NEWLINE# def gbp_policy_cfg_upd_all( self , cfgobj , name_uuid , attr ) : #NEWLINE# #INDENT# "\n        --cfgobj== policy-*(where *=action;classifer,rule,ruleset,targetgroup,\n                   target\n        --name_uuid == UUID or name_string\n        --attr == MUST be a dict, where key: attribute_name, while val:\n                  attribute's value(new value to update)\n        Updates Policy Objects' editable attributes\n        " #NEWLINE# cfgobj_dict = { #NEWLINE# #INDENT# 'action' : 'policy-action' , #NEWLINE# 'classifier' : 'policy-classifier' , #NEWLINE# 'rule' : 'policy-rule' , #NEWLINE# 'ruleset' : 'policy-rule-set' , #NEWLINE# 'group' : 'policy-target-group' , #NEWLINE# 'target' : 'policy-target' , #NEWLINE# 'l2p' : 'l2policy' , #NEWLINE# 'l3p' : 'l3policy' , #NEWLINE# 'nsp' : 'network-service-policy' , #NEWLINE# 'extseg' : 'external-segment' , #NEWLINE# 'extpol' : 'external-policy' , #NEWLINE# 'natpool' : 'nat-pool' , #NEWLINE# #UNINDENT# } #NEWLINE# if ( cfgobj != '' ) : #NEWLINE# #INDENT# if ( cfgobj not in cfgobj_dict ) : #NEWLINE# #INDENT# raise KeyError #NEWLINE# #UNINDENT# #UNINDENT# if ( ( name_uuid == '' ) or ( not isinstance ( attr , dict ) ) ) : #NEWLINE# #INDENT# _log . info ( 'Function Usage: gbp_policy_cfg_upd_all \'rule\' "abc"\n                      {attr:attr_val}\n\n                      --cmd_val == 0:delete; 1:create; 2:update\n\n                      -- name_uuid == UUID or name_string\n' ) #NEWLINE# return 0 #NEWLINE# #UNINDENT# cmd = ( ( 'gbp %s-update ' % cfgobj_dict [ cfgobj ] ) + str ( name_uuid ) ) #NEWLINE# for ( arg , value ) in attr . iteritems ( ) : #NEWLINE# #INDENT# if ( '_' in arg ) : #NEWLINE# #INDENT# arg = string . replace ( arg , '_' , '-' ) #NEWLINE# #UNINDENT# cmd = ( ( cmd + ' --' ) + ( '%s %s' % ( arg , value ) ) ) #NEWLINE# #UNINDENT# _log . info ( cmd ) #NEWLINE# cmd_out = commands . getoutput ( cmd ) #NEWLINE# if ( self . cmd_error_check ( cmd_out ) == 0 ) : #NEWLINE# #INDENT# return 0 #NEWLINE# #UNINDENT# return 1