Skip to content

Commit 698cdde

Browse files
authored
Merge pull request #29 from ninech/netbox_2.4_compatibility
Update for Netbox 2.4
2 parents 2dbc21c + 206020f commit 698cdde

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+11628
-7350
lines changed

Diff for: README.md

+31-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
[![Code Climate](https://codeclimate.com/github/ninech/netbox-client-ruby/badges/gpa.svg)](https://codeclimate.com/github/ninech/netbox-client-ruby)
66

77
This is a gem to pragmatically access your [Netbox instance](https://github.com/digitalocean/netbox)
8-
via it's API from Ruby. This gem is currently only compatible with Netbox v2.
8+
via it's API from Ruby. This gem is currently only compatible with Netbox v2.4 or newer.
99

1010
## Installation
1111

@@ -134,6 +134,11 @@ NetboxClientRuby.secrets.session_key = persisted_session_key
134134
Not all objects which the Netbox API exposes are currently implemented. Implementing new objects
135135
[is trivial](https://github.com/ninech/netbox-client-ruby/commit/e3cee19d21a8a6ce480d7c03d23d7c3fbc92417a), though.
136136

137+
* Circuits:
138+
* Circuits
139+
* Circuit Types
140+
* Circuit Terminations
141+
* Providers
137142
* DCIM:
138143
* Devices
139144
* Device Roles
@@ -146,6 +151,7 @@ Not all objects which the Netbox API exposes are currently implemented. Implemen
146151
* Racks
147152
* Rack Groups
148153
* Rack Roles
154+
* Rack Reservations
149155
* Regions
150156
* Sites
151157
* IPAM:
@@ -178,11 +184,33 @@ if it was added in the meantime without the list above having been updated.
178184

179185
## Development
180186

181-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests.
182-
You can also run `bin/console` for an interactive prompt that will allow you to experiment.
187+
After checking out the repo, run `bin/setup` to install dependencies.
188+
Then, run `rake spec` to run the tests.
183189

184190
To install this gem onto your local machine, run `bundle exec rake install`.
185191

192+
To experiment interactively, fire up the Netbox Docker container by running `docker-compose up -d`.
193+
Then, run `bin/console` for an interactive prompt that will allow you to experiment against your local Netbox.
194+
195+
### Load Development Data
196+
197+
To simplify development, e.g. via the `bin/console` described above, there is a very complete sample set of Netbox data readily available.
198+
You can use it to query almost every object and relation in Netbox.
199+
200+
```bash
201+
cat dump.sql | docker-compose exec postgres psql -U postgres
202+
```
203+
204+
### Dump Development from Database
205+
206+
Should you want to export the current set of data, use the command below.
207+
208+
```bash
209+
docker-compose exec postgres pg_dump -U netbox --exclude-table-data=extras_objectchange -Cc netbox > dump.sql
210+
```
211+
212+
(Remove `--exclude-table-data=extras_objectchange` from the command if you want to retain the history!)
213+
186214
## Contributing
187215

188216
Bug reports and pull requests are very welcome [on GitHub](https://github.com/ninech/netbox-client-ruby).

Diff for: bin/console

+23-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,29 @@ require 'netbox-client-ruby'
66
# You can add fixtures and/or initialization code here to make experimenting
77
# with your gem easier. You can also use a different console, if you like.
88

9-
# (If you use this, don't forget to add pry to your Gemfile!)
9+
NetboxClientRuby.configure do |c|
10+
c.netbox.auth.token = '0123456789abcdef0123456789abcdef01234567'
11+
c.netbox.auth.rsa_private_key.path =
12+
File.expand_path('../netbox-client-ruby_rsa', __dir__)
13+
c.netbox.auth.rsa_private_key.password = nil
14+
c.netbox.api_base_url = "http://#{`docker-compose port nginx 8080`.strip}/api/"
15+
c.faraday.logger = :detailed_logger
16+
end
17+
18+
NCR = NetboxClientRuby
19+
20+
version = File.read(File.expand_path('../VERSION', __dir__)).strip
21+
22+
puts <<~WELCOME_TEXT
23+
This is using NetboxClientRuby v#{version}.
24+
`NetboxClientRuby` has been abbreviated to `NCR` in this console.
25+
You will be talking to '#{NetboxClientRuby.config.netbox.api_base_url}'.
26+
27+
Wondering how many regions you have in your Netbox?
28+
Type: NetboxClientRuby.dcim.regions.count
29+
Or Short: NCR.dcim.regions.count
30+
WELCOME_TEXT
31+
1032
require 'pry'
1133
Pry.start
1234

Diff for: docker-compose.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
version: '2'
22
services:
33
nginx:
4-
image: nginx:1.11-alpine
4+
image: nginx:1.14-alpine
55
command: nginx -g 'daemon off;' -c /etc/netbox-nginx/nginx.conf
66
depends_on:
77
- netbox
@@ -11,15 +11,15 @@ services:
1111
ports:
1212
- 8080
1313
netbox:
14-
image: ninech/netbox:latest
14+
image: ninech/netbox:v2.4.3
1515
depends_on:
1616
- postgres
1717
volumes:
1818
- netbox-static-files:/opt/netbox/netbox/static
1919
- netbox-nginx-config:/etc/netbox-nginx/
2020
env_file: 'netbox.env'
2121
postgres:
22-
image: postgres:9.6-alpine
22+
image: postgres:10.4-alpine
2323
environment:
2424
POSTGRES_USER: netbox
2525
POSTGRES_PASSWORD: netbox

0 commit comments

Comments
 (0)