maas-client 0.2.3 → 0.2.4

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 7a3d68b0230db26fbd93ac4ad8fcf526ad778a12
4
- data.tar.gz: 7982b27bd1dc1594a95bb644d2225d90d3f8fb3e
2
+ SHA256:
3
+ metadata.gz: 8c5e1e49b5860c2dd08f3f54f50e4bb2e0ec0159d55f151351d382e997e3372f
4
+ data.tar.gz: 4bcf35e1650fda5b9fbb618623c63b2a2a424380bdc23bcc4c70c74385a73098
5
5
  SHA512:
6
- metadata.gz: e1763b5f980a4cdb6666adc7bd76c1958b476eb6da69ab597fc96de399337691f443a699764513ac2dc962846fad5ee496c527289e2500ab86475075ee4fc118
7
- data.tar.gz: 99b52f29b0b687bdf1de4be48f10d7a3f89786ef0d2b250d3b3b64c5037adfde8596b7116fcf314818cf59d9bf8fae97630355a6f5735668a663c87443a33227
6
+ metadata.gz: ec4cc750290fdada55ef41f463d3daf2ff3d2d42b220ad6caaf0c425f57cc4f9c8f381204657b6706877de8429fc456ff917d10a7ac307d9b647897d06883a0c
7
+ data.tar.gz: 9d51ba8ad6e5c0326ee3cec8035afcb1ac31440fc9c1e4cfec1592ab282dfffa226dd103fbfd34f6faf93776649427164be925b9f6906ecaf1421d684962b9ef
data/README.md CHANGED
@@ -20,6 +20,10 @@ $ gem install maas-client --no-ri --no-rdoc
20
20
 
21
21
  require "maas/client"
22
22
 
23
+ # when ~/.rbmaas/rbmaas.yml is configured
24
+ con = Maas::Client::MaasClient.new()
25
+
26
+ # when manually configuring
23
27
  con = Maas::Client::MaasClient.new("#{CONSUMER_KEY}:#{KEY}:#{SECRET}",
24
28
  "http://#{IP_OR_DOMAIN_NAME}/MAAS/api/2.0")
25
29
 
@@ -52,6 +56,12 @@ myarr
52
56
  ```bash
53
57
  # to generate hosts file
54
58
  rbmaas generate hosts
59
+
60
+ # to disused resources
61
+ rbmaas clear
62
+
63
+ # to initialize MAAS as defined in a yaml file
64
+ rbmaas init -f maas.yml
55
65
  ```
56
66
  ## Development and Contribution
57
67
 
data/lib/maas/client.rb CHANGED
@@ -1,4 +1,4 @@
1
- # frozen_string_literal: true
1
+ require 'maas/client/config'
2
2
  require 'oauth'
3
3
  require 'oauth/signature/plaintext'
4
4
  require 'json'
@@ -9,12 +9,20 @@ module Maas
9
9
  class MaasClient
10
10
  attr_reader :access_token
11
11
 
12
- def initialize(api_key, endpoint)
13
- @api_key = api_key
12
+ def initialize(api_key = nil, endpoint = nil)
13
+ if api_key and endpoint
14
+ @api_key = api_key
15
+ @endpoint = endpoint
16
+ elsif File.exists?(Maas::Client::Config.config[:conf_file])
17
+ Maas::Client::Config.set_config
18
+ @api_key = Maas::Client::Config.config[:maas][:key]
19
+ @endpoint = Maas::Client::Config.config[:maas][:url]
20
+ else
21
+ abort("There is no server Info provided.")
22
+ end
14
23
  @consumer_key = @api_key.split(/:/)[0]
15
24
  @key = @api_key.split(/:/)[1]
16
25
  @secret = @api_key.split(/:/)[2]
17
- @endpoint = endpoint
18
26
  consumer = OAuth::Consumer.new(
19
27
  @consumer_key,
20
28
  '',
@@ -16,12 +16,11 @@ module Maas
16
16
 
17
17
  no_commands do
18
18
  def init_rbmaas
19
- maas_config = Maas::Client::Config.config
20
- if File.exists?(maas_config[:conf_file])
19
+ if File.exists?(Maas::Client::Config.config[:conf_file])
21
20
  Maas::Client::Config.set_config
22
21
  Maas::Client::MaasClient.new(
23
- maas_config[:maas][:key],
24
- maas_config[:maas][:url]
22
+ Maas::Client::Config.config[:maas][:key],
23
+ Maas::Client::Config.config[:maas][:url]
25
24
  )
26
25
  else
27
26
  Maas::Client::Config.init_config
@@ -29,7 +28,7 @@ module Maas
29
28
  end
30
29
  end
31
30
 
32
- desc 'clear', "Clear unused resources."
31
+ desc 'clear', "Clear disused resources."
33
32
  def clear(resource)
34
33
  case resource
35
34
  when 'dns'
@@ -1,4 +1,3 @@
1
1
  maas:
2
2
  key: K:E:Y
3
3
  url: http://maas.example.com/MAAS/api/2.0
4
-
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Maas
4
4
  module Client
5
- VERSION = '0.2.3'
5
+ VERSION = '0.2.4'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: maas-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Don Draper
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-31 00:00:00.000000000 Z
11
+ date: 2018-05-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -198,7 +198,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
198
198
  version: '0'
199
199
  requirements: []
200
200
  rubyforge_project:
201
- rubygems_version: 2.6.14
201
+ rubygems_version: 2.7.6
202
202
  signing_key:
203
203
  specification_version: 4
204
204
  summary: A client library for MAAS