-
Notifications
You must be signed in to change notification settings - Fork 128
Added cookbook support #21
base: master
Are you sure you want to change the base?
Changes from 1 commit
2d00b6d
7cf353e
734e886
5270648
a98b9a4
6851acb
169599c
5886b36
5e12451
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| from chef.base import ChefObject, ChefAPI | ||
| from chef.exceptions import ChefServerNotFoundError | ||
|
|
||
| class Cookbook(ChefObject): | ||
| """ | ||
| A Chef Cookbook object. | ||
| """ | ||
|
|
||
| url = '/cookbooks' | ||
|
|
||
| attributes = { | ||
| 'definitions': list, | ||
| 'name': str, | ||
| 'attributetes': list, | ||
| 'files': list, | ||
| 'json_class': str, | ||
| 'providers': list, | ||
| 'metadata': dict, | ||
| 'libraries': list, | ||
| 'templates': list, | ||
| 'resources': list, | ||
| 'cookbook_name': str, | ||
| 'version': str, | ||
| 'recipes': list, | ||
| 'root_files': list, | ||
| 'chef_type': str | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Needs trailing comma. |
||
| } | ||
|
|
||
|
|
||
| @staticmethod | ||
| def versions(name, api=None): | ||
| """ | ||
| Get a list of versions for the named cookbook | ||
| """ | ||
| api = api or ChefAPI.get_global() | ||
| url = "{0}/{1}".format(Cookbook.url, name) | ||
| try: | ||
| data = api[url] | ||
| except ChefServerNotFoundError: | ||
| return list() | ||
| return list([ rev['version'] for rev in data[name]['versions'] ]) | ||
|
|
||
|
|
||
| def __getitem__(self, attr): | ||
|
||
| return self.__dict__[attr] | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to get moved to a classmethod.