Project

General

Profile

Download (7.53 KB) Statistics
| Branch: | Tag: | Revision:

runcible / README.md @ 4376f477

1
# Runcible
2

    
3
[![Build Status](https://secure.travis-ci.org/Katello/runcible.png)](http://travis-ci.org/Katello/runcible)
4

    
5
Exposing Pulp's juiciest parts. http://www.pulpproject.org/
6

    
7
Latest Live Tested Version: **pulp-server-2.2.0-0.22.beta.el6.noarch**
8

    
9
Current stable Runcible: https://github.com/Katello/runcible/tree/0.3
10

    
11
For in-depth class and method documentation: http://katello.github.com/runcible/
12

    
13
## Installation
14

    
15
Add this line to your application's Gemfile:
16

    
17
    gem 'runcible'
18

    
19
And then execute:
20

    
21
    $ bundle
22

    
23
Or install it yourself as:
24

    
25
    $ gem install runcible
26

    
27
## Usage
28

    
29
### Set Configuration
30

    
31
To use a single resource or extension, the configuration can be set:
32

    
33
    repo_api = Runcible::Resources::Repository.new({
34
                :url      => "",
35
                :api_path => "",
36
                :user     => "",
37
                :logger   => ""
38
              })
39
    repo_api.find(id)
40

    
41
Alternatively, a single 'server' instance which can easily use all 
42
  resources and extensions can be instantiated:
43

    
44
    my_runcible = Runcible::Instance.new({
45
                :url      => "",
46
                :api_path => "",
47
                :user     => "",
48
                :logger   => ""
49
              })
50
     runcible.resources.repository.find(id)
51

    
52
Required Configuration:
53

    
54
    :uri      => The base URI of the Pulp server (default: https://localhost)
55
    :api_path => The API path of the Pulp server (default: pulp/api/v2/)
56
    :user     => The Pulp username to be used in authentication
57
    :logger   => The location to log RestClient calls (e.g. stdout)
58
  
59
Authentication Options are either HTTP or Oauth:
60

    
61
    :http_auth  => {:password => ''}
62

    
63
    :oauth      => {:oauth_secret => "",
64
                    :oauth_key    => "" }
65

    
66
For an example on parsing the Pulp server.conf and using values provided within for the configuration see the [test_runner](https://github.com/Katello/runcible/blob/master/test/integration/test_runner.rb)
67

    
68
### Make a Request
69

    
70
Runcible provides two representations of Pulp entities to make API calls: [resources](https://github.com/Katello/runcible/tree/master/lib/runcible/resources) and [extensions](https://github.com/Katello/runcible/tree/master/lib/runcible/extensions)
71

    
72
The best examples of how to use either the resources or extensions can be found within the [tests](https://github.com/Katello/runcible/tree/master/test/integration)
73

    
74
#### Resources
75

    
76
Resources are designed to be one-for-one with the Pulp API calls in terms of required parameters and naming of the calls.  For example, in order to create a repository, associate a Yum importer and a distributor:
77

    
78
    my_runcible = Runcible::Instance.new(config)
79
    my_runcible.resources.repository.create("Repository_ID")
80
    my_runcible.resources.repository.associate_importer("Repository_ID", "yum_importer", {})
81
    my_runcible.resources.repository.associate_distributor("Repository_ID", "yum_distributor", {"relative_url" => "/", "http" => true, "https" => true})
82

    
83
    or
84

    
85
    Runcible::Resources::Repository.new(config).create("Repository_ID")
86
    Runcible::Resources::Repository.new(config).associate_importer("Repository_ID", "yum_importer", {})
87
    Runcible::Resources::Repository.new(config).associate_distributor("Repository_ID", "yum_distributor", {"relative_url" => "/", "http" => true, "https" => true})
88

    
89
#### Extensions
90

    
91
Extensions are constructs around the Pulp API that make retrieving, accessing or creating certain data types easier.  For example, providing objects that represent the details of a yum importer or distributor, and providing functions to create a Repository with an importer and distributors in a single call.  The same three step process above using extensions is:
92

    
93
    my_runcible = Runcible::Instance.new(config)
94
    my_runcible.extensions.repository.create_with_importer_and_distributor("Repository_ID", {:id=>'yum_importer'}, [{'type_id' => 'yum_distributor', 'id'=>'123', 'auto_publish'=>true, 'config'=>{'relative_url' => '/', 'http' => true, 'https' => true}}])
95

    
96
    or
97

    
98
    Runcible::Extensions::Repository.new(config).create_with_importer_and_distributors("Repository_ID", {:id=>'yum_importer'}, [{'type_id' => 'yum_distributor', 'id'=>'123', 'auto_publish'=>true, 'config'=>{'relative_url' => '/', 'http' => true, 'https' => true}}])
99

    
100
Alternatively, using distributor and importer objects:
101

    
102
    distributors = [Runcible::Models::YumDistributor.new('/path', true, true, :id => '123')]
103
    importer = Runcible::Models::YumImporter.new()
104

    
105
    my_runcible = Runcible::Instance.new(config)
106
    my_runcible.extensions.repository.create_with_importer_and_distributors("Repository_ID", importer, distributors)
107

    
108
    or
109

    
110
    Runcible::Extensions::Repository.new(config).create_with_importer_and_distributors("Repository_ID", importer, distributors)
111

    
112
## Testing
113

    
114
To run all tests using recorded data, run:
115

    
116
    rake test mode=none
117

    
118
To run all tests to record data:
119
   
120
    rake test mode=all
121

    
122
To run a single test using recorded data, run:
123
   
124
    rake test mode=none test=extensions/respository
125
    or (by filename)
126
    rake test mode=none test=./test/extensions/respository_test.rb
127

    
128
To run tests against your live Pulp without recording a new cassette set record flag to false (does not apply to mode=none):
129

    
130
    record=false
131

    
132
To run with  oauth, simply append the following to any commend:
133
   
134
    auth_type=oauth
135

    
136
To see RestClient logs while testing:
137
  
138
    logging=true
139

    
140
## Updating Documentation
141

    
142
The documentation is built with yard and hosted on Github via the gh-pages branch of the repository. To update the documentation on Github:
143

    
144
    yard doc
145
    git checkout gh-pages
146
    cp -rf doc/* ./
147
    git add ./
148
    git commit -a -m 'Updating docs to version X.X'
149
    git push <upstream> gh-pages
150
    
151
## Building and Releasing
152

    
153
An official release of Runcible should include the release of a gem on rubygems.org and an update to the documentation branch. At a minimum, the following two actions should be performed for each release:
154

    
155
1. [Build and Release Gem](#gem)
156
2. [Updating Documentation](#updating-documentation)
157

    
158
### Gem
159

    
160
While anyone can grab the source and build a new version of the gem, only those with Rubygems.org permissions on the project can release an official version.
161

    
162
To build a new version of Runcible, first bump the version depending on the type of release.
163

    
164
    cd runcible/
165
    vim lib/runcible/version.rb
166

    
167
Now update the version to the new version, and commit the changes.
168

    
169
    git commit -a -m 'Version bump'
170

    
171
Now build:
172
    
173
    gem build runcible.gemspec
174

    
175

    
176
#### Official Release
177
  
178
For an official release, again assuming you have the right permssions:
179

    
180
    gem push runcible-<version>.gem
181

    
182
### RPM Release
183

    
184
If you are wanting to generate a new RPM build, please make sure you have followed the steps above if the build is going to include new code.  All builds should first go in gem form to Rubygems.  You'll need to make sure tito is installed:
185

    
186
    yum install tito
187

    
188
Now tag, making sure the tag version matches the gem version:
189

    
190
    tito tag
191

    
192
Assuming you have the right dependencies available, you can do a local test build with tito (although we recommend using mock):
193

    
194
    tito build --test --rpm
195

    
196
With mock:
197

    
198
    tito build --test --rpm --builder=mock --builder-arg mock=<name_of_mock_config>
199

    
200
From here there are a variety of options to build and release an RPM pakaged version of Runcible (e.g. you can build an SRPM to feed to Koji, or use mock locally)
201

    
202
## Contributing
203

    
204
1. Fork it
205
2. Create your feature branch (`git checkout -b my-new-feature`)
206
3. Commit your changes (`git commit -am 'Added some feature'`)
207
4. Ensure all tests are passing
208
5. Push to the branch (`git push origin my-new-feature`)
209
6. Create new Pull Request