Skip to content

Commit

Permalink
dev: cibconfig: add get_property_w_default to CibFactory
Browse files Browse the repository at this point in the history
  • Loading branch information
krig committed Feb 9, 2016
1 parent 164aa48 commit c3917e8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
15 changes: 14 additions & 1 deletion modules/cibconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from . import orderedset
from . import cibstatus
from . import crm_gv
from .ra import get_ra, get_properties_list, get_pe_meta
from .ra import get_ra, get_properties_list, get_pe_meta, get_properties_meta
from .msg import common_warn, common_err, common_debug, common_info, err_buf
from .msg import common_error, constraint_norefobj_err, cib_parse_err, no_object_err
from .msg import missing_obj_err, common_warning, update_err, unsupported_err, empty_cib_err
Expand Down Expand Up @@ -2951,6 +2951,19 @@ def get_property(self, property):
'''
return self._get_attr_value("property", property)

def get_property_w_default(self, prop):
'''
Get the value of the given property. If it is
not set, return the default value.
'''
v = self.get_property(prop)
if v is None:
try:
v = get_properties_meta().param_default(prop)
except:
pass
return v

def get_op_default(self, attr):
'''
Get the value of the attribute from op_defaults.
Expand Down
7 changes: 1 addition & 6 deletions modules/ui_configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,12 +324,7 @@ def print_value(v):
else:
print v
for p in properties:
v = cib_factory.get_property(p)
if v is None:
try:
v = ra.get_properties_meta().param_default(p)
except:
pass
v = cib_factory.get_property_w_default(p)
if v is not None:
print_value(v)
elif truth:
Expand Down

0 comments on commit c3917e8

Please sign in to comment.