Example #1
0
 def perform(self, cm):
     node = chef.Node(self.node_id, api=cm.chefapi)
     dotted_attr = \
         attribute if isinstance(self.attribute, str) \
         else '.'.join(self.attribute) if hasattr(self.attribute, '__iter__') \
         else util.f_raise(TypeError(
             'Unknown attribute specification: {0}'.format(self.attribute)))
     try:
         return node.attributes.get_dotted(dotted_attr)
     except KeyError:
         raise KeyError('Unresolved node attribute: %s', dotted_attr)
Example #2
0
 def get_node_attribute(self, node_id, attribute):
     node = chef.Node(node_id, api=self.chefapi)
     dotted_attr = \
         attribute if isinstance(attribute, basestring) \
         else '.'.join(attribute) if hasattr(attribute, '__iter__') \
         else util.f_raise(TypeError(
             'Unknown attribute specification: {0}'.format(attribute)))
     try:
         return node.attributes.get_dotted(dotted_attr)
     except KeyError:
         raise KeyError('Unresolved node attribute: %s', dotted_attr)
Example #3
0
 def test_f_raise(self):
     with self.assertRaises(Exception):
        util.f_raise(Exception())
Example #4
0
 def test_f_raise(self):
     with self.assertRaises(Exception):
         util.f_raise(Exception())