deadwood 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. data/COPYING +19 -0
  2. data/README.md +19 -0
  3. data/Rakefile +65 -0
  4. data/examples/deadwood-config.yml +5 -0
  5. data/lib/deadwood.rb +45 -0
  6. data/lib/deadwood/active_resource_oauth_client.rb +74 -0
  7. data/lib/deadwood/model/activation_key.rb +24 -0
  8. data/lib/deadwood/model/base.rb +82 -0
  9. data/lib/deadwood/model/changeset.rb +28 -0
  10. data/lib/deadwood/model/consumer.rb +18 -0
  11. data/lib/deadwood/model/crl.rb +18 -0
  12. data/lib/deadwood/model/entitlement.rb +18 -0
  13. data/lib/deadwood/model/environment.rb +40 -0
  14. data/lib/deadwood/model/errata.rb +18 -0
  15. data/lib/deadwood/model/gpg_key.rb +37 -0
  16. data/lib/deadwood/model/organization.rb +21 -0
  17. data/lib/deadwood/model/pool.rb +18 -0
  18. data/lib/deadwood/model/product.rb +33 -0
  19. data/lib/deadwood/model/provider.rb +24 -0
  20. data/lib/deadwood/model/repository.rb +18 -0
  21. data/lib/deadwood/model/role.rb +38 -0
  22. data/lib/deadwood/model/status.rb +18 -0
  23. data/lib/deadwood/model/subscription.rb +18 -0
  24. data/lib/deadwood/model/system.rb +24 -0
  25. data/lib/deadwood/model/system_group.rb +33 -0
  26. data/lib/deadwood/model/task.rb +18 -0
  27. data/lib/deadwood/model/template.rb +24 -0
  28. data/lib/deadwood/model/user.rb +28 -0
  29. data/lib/deadwood/model/version.rb +18 -0
  30. data/rake/rpmtask.rb +126 -0
  31. data/spec/models/activation_key_spec.rb +35 -0
  32. data/spec/models/base_spec.rb +30 -0
  33. data/spec/models/changeset_spec.rb +38 -0
  34. data/spec/models/crl_spec.rb +25 -0
  35. data/spec/models/environment_spec.rb +54 -0
  36. data/spec/models/gpg_key_spec.rb +30 -0
  37. data/spec/models/organization_spec.rb +75 -0
  38. data/spec/models/product_spec.rb +38 -0
  39. data/spec/models/provider_spec.rb +72 -0
  40. data/spec/models/repository_spec.rb +36 -0
  41. data/spec/models/role_spec.rb +57 -0
  42. data/spec/models/system_group_spec.rb +31 -0
  43. data/spec/models/task_spec.rb +26 -0
  44. data/spec/models/template_spec.rb +37 -0
  45. data/spec/models/user_spec.rb +53 -0
  46. data/spec/spec_helper.rb +50 -0
  47. data/spec/vcr/cassettes/create_activation_key.yml +255 -0
  48. data/spec/vcr/cassettes/create_changeset.yml +257 -0
  49. data/spec/vcr/cassettes/create_find_all_environment.yml +130 -0
  50. data/spec/vcr/cassettes/create_find_single_environment.yml +130 -0
  51. data/spec/vcr/cassettes/create_gpg_key.yml +173 -0
  52. data/spec/vcr/cassettes/create_provider_for_default_org.yml +171 -0
  53. data/spec/vcr/cassettes/create_repository.yml +261 -0
  54. data/spec/vcr/cassettes/create_role.yml +130 -0
  55. data/spec/vcr/cassettes/create_system.yml +171 -0
  56. data/spec/vcr/cassettes/create_template.yml +253 -0
  57. data/spec/vcr/cassettes/create_user.yml +130 -0
  58. data/spec/vcr/cassettes/create_user_role.yml +263 -0
  59. data/spec/vcr/cassettes/find_ACME_Corporation.yml +44 -0
  60. data/spec/vcr/cassettes/find_admin.yml +44 -0
  61. data/spec/vcr/cassettes/find_crl.yml +62 -0
  62. data/spec/vcr/cassettes/find_template.yml +44 -0
  63. data/spec/vcr/cassettes/find_users.yml +44 -0
  64. data/spec/vcr/cassettes/organization_1_exists.yml +85 -0
  65. data/spec/vcr/cassettes/organization_create.yml +128 -0
  66. data/spec/vcr/cassettes/organization_default_exists.yml +44 -0
  67. data/spec/vcr/cassettes/organization_exists.yml +44 -0
  68. data/spec/vcr/cassettes/organization_update.yml +130 -0
  69. data/spec/vcr/cassettes/provider_1_exists.yml +44 -0
  70. data/spec/vcr/cassettes/providers_all_exists.yml +44 -0
  71. data/spec/vcr/cassettes/read_products.yml +257 -0
  72. data/spec/vcr/cassettes/update_environment_name_description.yml +216 -0
  73. data/spec/vcr/cassettes/update_provider_for_org.yml +175 -0
  74. data/spec/vcr/cassettes/update_role.yml +175 -0
  75. data/spec/vcr/cassettes/update_user.yml +130 -0
  76. data/spec/vcr_setup.rb +46 -0
  77. metadata +242 -0
@@ -0,0 +1,18 @@
1
+ # Copyright (c) 2012 Chris Alfonso
2
+ # # Permission is hereby granted, free of charge, to any person obtaining a copy
3
+ # of this software and associated documentation files (the "Software"), to deal
4
+ # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
5
+ # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions:
6
+ # # The above copyright notice and this permission notice shall be included in
7
+ # all copies or substantial portions of the Software. #
8
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
9
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
10
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
11
+ # THE SOFTWARE.
12
+
13
+ module Deadwood
14
+ module Katello
15
+ class Errata < Base
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,37 @@
1
+ # Copyright (c) 2012 Chris Alfonso
2
+ # # Permission is hereby granted, free of charge, to any person obtaining a copy
3
+ # of this software and associated documentation files (the "Software"), to deal
4
+ # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
5
+ # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions:
6
+ # # The above copyright notice and this permission notice shall be included in
7
+ # all copies or substantial portions of the Software. #
8
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
9
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
10
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
11
+ # THE SOFTWARE.
12
+
13
+ module Deadwood
14
+ module Katello
15
+ class GpgKey < Base
16
+ def collection_path(prefix_options = {}, query_options = nil)
17
+ prefix_options, query_options = split_options(prefix_options) if query_options.nil?
18
+ query_options.merge!(self.attributes)
19
+ org_id = self.organization_id
20
+ attributes.delete(:organization_id)
21
+ "#{self.class.prefix(prefix_options)}organizations/#{org_id}/#{self.class.collection_name}#{query_string(query_options)}"
22
+ end
23
+
24
+ def element_path(id = self.id, prefix_options = {}, query_options = nil)
25
+ prefix_options, query_options = split_options(prefix_options) if query_options.nil?
26
+ # Remove the attributes that aren't allowed to be updated
27
+ attributes.delete(:organization_id)
28
+ attributes.delete(:products)
29
+ attributes.delete(:updated_at)
30
+ attributes.delete(:created_at)
31
+ attributes.delete(:repositories)
32
+ "#{self.class.prefix(prefix_options)}#{self.class.collection_name}/#{self.id}#{query_string(query_options)}"
33
+ end
34
+
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,21 @@
1
+ # Copyright (c) 2012 Chris Alfonso
2
+ # # Permission is hereby granted, free of charge, to any person obtaining a copy
3
+ # of this software and associated documentation files (the "Software"), to deal
4
+ # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
5
+ # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions:
6
+ # # The above copyright notice and this permission notice shall be included in
7
+ # all copies or substantial portions of the Software. #
8
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
9
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
10
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
11
+ # THE SOFTWARE.
12
+
13
+ module Deadwood
14
+ module Katello
15
+ class Organization < Base
16
+ def element_path(id, prefix_options = {}, query_options = nil)
17
+ "#{self.class.prefix(prefix_options)}#{self.class.collection_name}/#{self.name}"
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,18 @@
1
+ # Copyright (c) 2012 Chris Alfonso
2
+ # # Permission is hereby granted, free of charge, to any person obtaining a copy
3
+ # of this software and associated documentation files (the "Software"), to deal
4
+ # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
5
+ # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions:
6
+ # # The above copyright notice and this permission notice shall be included in
7
+ # all copies or substantial portions of the Software. #
8
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
9
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
10
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
11
+ # THE SOFTWARE.
12
+
13
+ module Deadwood
14
+ module Katello
15
+ class Pool < Base
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,33 @@
1
+ # Copyright (c) 2012 Chris Alfonso
2
+ # # Permission is hereby granted, free of charge, to any person obtaining a copy
3
+ # of this software and associated documentation files (the "Software"), to deal
4
+ # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
5
+ # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions:
6
+ # # The above copyright notice and this permission notice shall be included in
7
+ # all copies or substantial portions of the Software. #
8
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
9
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
10
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
11
+ # THE SOFTWARE.
12
+
13
+ module Deadwood
14
+ module Katello
15
+ class Product < Base
16
+ def collection_path(prefix_options = {}, query_options = nil)
17
+ prefix_options, query_options = split_options(prefix_options) if query_options.nil?
18
+ query_options.merge!(self.attributes)
19
+ provider_id = self.provider_id
20
+ attributes.delete(:provider_id)
21
+ "#{self.class.prefix(prefix_options)}providers/#{provider_id}/product_create#{query_string(query_options)}"
22
+ end
23
+
24
+ def element_path(id = self.id, prefix_options = {}, query_options = nil)
25
+ prefix_options, query_options = split_options(prefix_options) if query_options.nil?
26
+ org_id = self.organization_id
27
+ # Remove the attributes that aren't allowed to be updated
28
+ attributes.delete(:organization_id)
29
+ "#{self.class.prefix(prefix_options)}organizations/#{org_id}/#{self.class.collection_name}/#{self.id}#{query_string(query_options)}"
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,24 @@
1
+ # Copyright (c) 2012 Chris Alfonso
2
+ # # Permission is hereby granted, free of charge, to any person obtaining a copy
3
+ # of this software and associated documentation files (the "Software"), to deal
4
+ # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
5
+ # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions:
6
+ # # The above copyright notice and this permission notice shall be included in
7
+ # all copies or substantial portions of the Software. #
8
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
9
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
10
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
11
+ # THE SOFTWARE.
12
+
13
+ module Deadwood
14
+ module Katello
15
+ class Provider < Base
16
+ def collection_path(prefix_options = {}, query_options = nil)
17
+ prefix_options, query_options = split_options(prefix_options) if query_options.nil?
18
+ query_options.merge!(self.attributes)
19
+ attributes.delete(:organization_id)
20
+ "#{self.class.prefix(prefix_options)}#{self.class.collection_name}#{query_string(query_options)}"
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,18 @@
1
+ # Copyright (c) 2012 Chris Alfonso
2
+ # # Permission is hereby granted, free of charge, to any person obtaining a copy
3
+ # of this software and associated documentation files (the "Software"), to deal
4
+ # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
5
+ # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions:
6
+ # # The above copyright notice and this permission notice shall be included in
7
+ # all copies or substantial portions of the Software. #
8
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
9
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
10
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
11
+ # THE SOFTWARE.
12
+
13
+ module Deadwood
14
+ module Katello
15
+ class Repository < Base
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,38 @@
1
+ # Copyright (c) 2012 Chris Alfonso
2
+ # # Permission is hereby granted, free of charge, to any person obtaining a copy
3
+ # of this software and associated documentation files (the "Software"), to deal
4
+ # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
5
+ # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions:
6
+ # # The above copyright notice and this permission notice shall be included in
7
+ # all copies or substantial portions of the Software. #
8
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
9
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
10
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
11
+ # THE SOFTWARE.
12
+
13
+ module Deadwood
14
+ module Katello
15
+ class Role < Base
16
+ def collection_path(prefix_options = {}, query_options = nil)
17
+ prefix_options, query_options = split_options(prefix_options) if query_options.nil?
18
+ query_options.merge!(self.attributes)
19
+ if self.attributes.include?(:user_id)
20
+ user_id = self.user_id
21
+ self.attributes.delete(:user_id)
22
+ "#{self.class.prefix(prefix_options)}users/#{user_id}/#{self.class.collection_name}#{query_string(query_options)}"
23
+ else
24
+ "#{self.class.prefix(prefix_options)}#{self.class.collection_name}#{query_string(query_options)}"
25
+ end
26
+ end
27
+
28
+ def element_path(id = self.id, prefix_options = {}, query_options = nil)
29
+ prefix_options, query_options = split_options(prefix_options) if query_options.nil?
30
+ # Remove the attributes that aren't allowed to be updated
31
+ attributes.delete(:updated_at)
32
+ attributes.delete(:created_at)
33
+ attributes.delete(:locked)
34
+ "#{self.class.prefix(prefix_options)}#{self.class.collection_name}/#{self.id}#{query_string(query_options)}"
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,18 @@
1
+ # Copyright (c) 2012 Chris Alfonso
2
+ # # Permission is hereby granted, free of charge, to any person obtaining a copy
3
+ # of this software and associated documentation files (the "Software"), to deal
4
+ # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
5
+ # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions:
6
+ # # The above copyright notice and this permission notice shall be included in
7
+ # all copies or substantial portions of the Software. #
8
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
9
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
10
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
11
+ # THE SOFTWARE.
12
+
13
+ module Deadwood
14
+ module Katello
15
+ class Status < Base
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,18 @@
1
+ # Copyright (c) 2012 Chris Alfonso
2
+ # # Permission is hereby granted, free of charge, to any person obtaining a copy
3
+ # of this software and associated documentation files (the "Software"), to deal
4
+ # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
5
+ # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions:
6
+ # # The above copyright notice and this permission notice shall be included in
7
+ # all copies or substantial portions of the Software. #
8
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
9
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
10
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
11
+ # THE SOFTWARE.
12
+
13
+ module Deadwood
14
+ module Katello
15
+ class Subscription < Base
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,24 @@
1
+ # Copyright (c) 2012 Chris Alfonso
2
+ # # Permission is hereby granted, free of charge, to any person obtaining a copy
3
+ # of this software and associated documentation files (the "Software"), to deal
4
+ # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
5
+ # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions:
6
+ # # The above copyright notice and this permission notice shall be included in
7
+ # all copies or substantial portions of the Software. #
8
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
9
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
10
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
11
+ # THE SOFTWARE.
12
+
13
+ module Deadwood
14
+ module Katello
15
+ class System < Base
16
+ def collection_path(prefix_options = {}, query_options = nil)
17
+ prefix_options, query_options = split_options(prefix_options) if query_options.nil?
18
+ query_options.merge!(self.attributes)
19
+ self.attributes().delete(:environment_id)
20
+ "#{self.class.prefix(prefix_options)}#{self.class.collection_name}#{query_string(query_options)}"
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,33 @@
1
+ # Copyright (c) 2012 Chris Alfonso
2
+ # # Permission is hereby granted, free of charge, to any person obtaining a copy
3
+ # of this software and associated documentation files (the "Software"), to deal
4
+ # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
5
+ # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions:
6
+ # # The above copyright notice and this permission notice shall be included in
7
+ # all copies or substantial portions of the Software. #
8
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
9
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
10
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
11
+ # THE SOFTWARE.
12
+
13
+ module Deadwood
14
+ module Katello
15
+ class SystemGroup < Base
16
+ def collection_path(prefix_options = {}, query_options = nil)
17
+ prefix_options, query_options = split_options(prefix_options) if query_options.nil?
18
+ query_options.merge!(self.attributes)
19
+ org_id = self.organization_id
20
+ self.attributes().delete(:organization_id)
21
+ "#{self.class.prefix(prefix_options)}organizations/#{org_id}/#{self.class.collection_name}#{query_string(query_options)}"
22
+ end
23
+
24
+ def element_path(id = self.id, prefix_options = {}, query_options = nil)
25
+ prefix_options, query_options = split_options(prefix_options) if query_options.nil?
26
+ org_id = self.organization_id
27
+ # Remove the attributes that aren't allowed to be updated
28
+ attributes.delete(:organization_id)
29
+ "#{self.class.prefix(prefix_options)}organizations/#{org_id}/#{self.class.collection_name}/#{self.id}#{query_string(query_options)}"
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,18 @@
1
+ # Copyright (c) 2012 Chris Alfonso
2
+ # # Permission is hereby granted, free of charge, to any person obtaining a copy
3
+ # of this software and associated documentation files (the "Software"), to deal
4
+ # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
5
+ # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions:
6
+ # # The above copyright notice and this permission notice shall be included in
7
+ # all copies or substantial portions of the Software. #
8
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
9
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
10
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
11
+ # THE SOFTWARE.
12
+
13
+ module Deadwood
14
+ module Katello
15
+ class Task < Base
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,24 @@
1
+ # Copyright (c) 2012 Chris Alfonso
2
+ # # Permission is hereby granted, free of charge, to any person obtaining a copy
3
+ # of this software and associated documentation files (the "Software"), to deal
4
+ # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
5
+ # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions:
6
+ # # The above copyright notice and this permission notice shall be included in
7
+ # all copies or substantial portions of the Software. #
8
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
9
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
10
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
11
+ # THE SOFTWARE.
12
+
13
+ module Deadwood
14
+ module Katello
15
+ class Template < Base
16
+ def collection_path(prefix_options = {}, query_options = nil)
17
+ prefix_options, query_options = split_options(prefix_options) if query_options.nil?
18
+ query_options.merge!(self.attributes)
19
+ self.attributes().delete(:environment_id)
20
+ "#{self.class.prefix(prefix_options)}#{self.class.collection_name}#{query_string(query_options)}"
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,28 @@
1
+ # Copyright (c) 2012 Chris Alfonso
2
+ # # Permission is hereby granted, free of charge, to any person obtaining a copy
3
+ # of this software and associated documentation files (the "Software"), to deal
4
+ # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
5
+ # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions:
6
+ # # The above copyright notice and this permission notice shall be included in
7
+ # all copies or substantial portions of the Software. #
8
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
9
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
10
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
11
+ # THE SOFTWARE.
12
+
13
+ module Deadwood
14
+ module Katello
15
+ class User < Base
16
+ def collection_path(prefix_options = {}, query_options = nil)
17
+ prefix_options, query_options = split_options(prefix_options) if query_options.nil?
18
+ query_options.merge!(self.attributes)
19
+ self.attributes.clear
20
+ "#{self.class.prefix(prefix_options)}#{self.class.collection_name}#{query_string(query_options)}"
21
+ end
22
+
23
+ def encode(options={})
24
+ self.attributes.empty? ? nil : send("to_#{self.class.format.extension}", options)
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,18 @@
1
+ # Copyright (c) 2012 Chris Alfonso
2
+ # # Permission is hereby granted, free of charge, to any person obtaining a copy
3
+ # of this software and associated documentation files (the "Software"), to deal
4
+ # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
5
+ # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions:
6
+ # # The above copyright notice and this permission notice shall be included in
7
+ # all copies or substantial portions of the Software. #
8
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
9
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
10
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
11
+ # THE SOFTWARE.
12
+
13
+ module Deadwood
14
+ module Katello
15
+ class Version < Base
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,126 @@
1
+ # Copyright 2011 Red Hat, Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ # Define a package task library to aid in the definition of RPM
16
+ # packages.
17
+
18
+ require 'rubygems'
19
+ require 'rake'
20
+ require 'rake/packagetask'
21
+
22
+ require 'rbconfig' # used to get system arch
23
+
24
+ module Rake
25
+
26
+ # Create a package based upon a RPM spec.
27
+ # RPM packages, can be produced by this task.
28
+ class RpmTask < PackageTask
29
+ # filename for output RPM spec
30
+ attr_accessor :rpm_spec
31
+
32
+ # RPM build dir
33
+ attr_accessor :topdir
34
+
35
+ # Include extra_release information in the rpm
36
+ attr_accessor :include_extra_release
37
+
38
+ def initialize(rpm_spec, args = {})
39
+ init(rpm_spec,args)
40
+ yield self if block_given?
41
+ define if block_given?
42
+ end
43
+
44
+ def init(rpm_spec,args)
45
+ @rpm_spec = rpm_spec
46
+
47
+ if args[:suffix]
48
+ rpm_spec_in = @rpm_spec + args[:suffix]
49
+ @include_extra_release = eval `grep -q '^[[:space:]]*Release:[[:space:]]*0' #{rpm_spec_in} && echo true || echo false`
50
+
51
+ git_head = `git log -1 --pretty=format:%h`
52
+ extra_release = @include_extra_release ? ("." + Time.now.strftime("%Y%m%d%H%M%S").gsub(/\s/, '') + "git" + "#{git_head}") : ''
53
+
54
+ if args[:pkg_version]
55
+ pkg_version = args[:pkg_version]
56
+ `sed -e "s|@VERSION@|#{pkg_version}|;s|^\\(Release:[^%]*\\)|\\1#{extra_release}|" #{rpm_spec_in} > #{@rpm_spec}`
57
+ else
58
+ `sed -e "s|^\\(Release:[^%]*\\)|\\1#{extra_release}|" #{rpm_spec_in} > #{@rpm_spec}`
59
+ end
60
+ end
61
+
62
+ # parse this out of the rpmbuild macros,
63
+ # not ideal but better than hardcoding this
64
+ File.open('/etc/rpm/macros.dist', "r") { |f|
65
+ f.read.scan(/%dist\s*\.(.*)\n/)
66
+ @distro = $1
67
+ }
68
+
69
+ # Parse rpm name / version out of spec
70
+ # FIXME hacky way to do this for now
71
+ # (would be nice to implement a full blown rpm spec parser for ruby)
72
+ File.open(rpm_spec, "r") { |f|
73
+ contents = f.read
74
+ # Parse out definitions and crudely expand them
75
+ contents.scan(/%define .*\n/).each do |definition|
76
+ words = definition.strip.split(' ')
77
+ key = words[1]
78
+ value = words[2..-1].to_s
79
+ # Modify the contents with expanded values, unless they contain
80
+ # a shell command (since we're not modifying them)
81
+ contents.gsub!("%{#{key}}", value) unless value.match('%\(')
82
+ end
83
+ @name = contents.scan(/\nName: .*\n/).first.split.last
84
+ @version = contents.scan(/\nVersion: .*\n/).first.split.last
85
+ @release = contents.scan(/\nRelease: .*\n/).first.split.last
86
+ @release.gsub!("%{?dist}", ".#{@distro}")
87
+ @arch = contents.scan(/\nBuildArch: .*\n/) # TODO grab local arch if not defined
88
+ if @arch.nil?
89
+ @arch = Config::CONFIG["target_cpu"] # hoping this will work for all cases,
90
+ # can just run the 'arch' cmd if we want
91
+ else
92
+ @arch = @arch.first.split.last
93
+ end
94
+ }
95
+ super(@name, @version)
96
+
97
+ @rpmbuild_cmd = 'rpmbuild'
98
+ end
99
+
100
+ def define
101
+ super
102
+
103
+ directory "#{@topdir}/SOURCES"
104
+ directory "#{@topdir}/SPECS"
105
+
106
+ desc "Build the rpms"
107
+ task :rpms, [:include_extra_release] => [rpm_file]
108
+
109
+ # FIXME properly determine :package build artifact(s) to copy to sources dir
110
+ file rpm_file, [:include_extra_release] => [:package, "#{@topdir}/SOURCES", "#{@topdir}/SPECS"] do |t,args|
111
+ cp "#{package_dir}/#{@name}-#{@version}.tgz", "#{@topdir}/SOURCES/"
112
+ # FIXME - This seems like a hack, but we don't know the gem's name
113
+ cp "#{package_dir}/#{@name.gsub('rubygem-', '')}-#{@version}.gem", "#{@topdir}/SOURCES/"
114
+ cp @rpm_spec, "#{@topdir}/SPECS"
115
+ sh "#{@rpmbuild_cmd} " +
116
+ "--define '_topdir #{@topdir}' " +
117
+ "-ba #{@rpm_spec}"
118
+ end
119
+ end
120
+
121
+ def rpm_file
122
+ # FIXME support all a spec's subpackages as well
123
+ "#{@topdir}/RPMS/#{@arch}/#{@name}-#{@version}-#{@release}.#{@arch}.rpm"
124
+ end
125
+ end
126
+ end