features: implement get() method
This commit is contained in:
parent
c07c57bfef
commit
64f7eecf58
@ -67,6 +67,15 @@ class Features(object):
|
|||||||
|
|
||||||
_NO_DEFAULT = object()
|
_NO_DEFAULT = object()
|
||||||
|
|
||||||
|
def get(self, item, default=_NO_DEFAULT):
|
||||||
|
'''Get a feature, return default value if missing.'''
|
||||||
|
try:
|
||||||
|
return self[item]
|
||||||
|
except KeyError:
|
||||||
|
if default is self._NO_DEFAULT:
|
||||||
|
raise
|
||||||
|
return default
|
||||||
|
|
||||||
def check_with_template(self, feature, default=_NO_DEFAULT):
|
def check_with_template(self, feature, default=_NO_DEFAULT):
|
||||||
''' Check if the vm's template has the specified feature. '''
|
''' Check if the vm's template has the specified feature. '''
|
||||||
try:
|
try:
|
||||||
|
Loading…
Reference in New Issue
Block a user