project-fifo-ruby 0.2.0 → 0.3.0

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.
@@ -5,9 +5,10 @@ class ProjectFifo
5
5
 
6
6
  attr_reader :fifo, :namespace
7
7
 
8
- def initialize(fifo, namespace)
8
+ def initialize(fifo, namespace, name="name")
9
9
  @namespace = namespace
10
10
  @fifo = fifo
11
+ @name = name
11
12
  end
12
13
 
13
14
  def list
@@ -23,13 +24,16 @@ class ProjectFifo
23
24
  fifo.get(namespace + '/' + uuid)
24
25
  end
25
26
 
27
+ def get_by_name(name)
28
+ list.map{|i| get(i) }.select{|i| i[@name] == name}
29
+ end
30
+
26
31
  def metadata(uuid, key, value)
27
32
  fifo.put([ namespace, uuid, 'metadata'].join('/'), { key => value })
28
33
  end
29
34
 
30
35
  def create(data)
31
- validator = HashValidator.validate(data, validations)
32
- raise(ArgumentError, validator.errors) unless validator.valid?
36
+ validate!(data)
33
37
  fifo.post(namespace, data)
34
38
  end
35
39
 
@@ -46,6 +50,11 @@ class ProjectFifo
46
50
  end
47
51
 
48
52
  protected
53
+ def validate!(data)
54
+ validator = HashValidator.validate(data, validations)
55
+ raise(ArgumentError, validator.errors) unless validator.valid?
56
+ end
57
+
49
58
  def validations()
50
59
  return {}
51
60
  end
@@ -5,7 +5,7 @@ class ProjectFifo
5
5
  class VM < ProjectFifo::Resource
6
6
 
7
7
  def initialize(fifo)
8
- super(fifo, 'vms')
8
+ super(fifo, 'vms', 'alias')
9
9
  end
10
10
 
11
11
  %w{ start stop reboot }.each do |act|
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "project-fifo-ruby"
5
- spec.version = '0.2.0'
5
+ spec.version = '0.3.0'
6
6
  spec.authors = [ "Brian Akins" ]
7
7
  spec.email = [ "brian@akins.org" ]
8
8
  spec.description = %q{A simple incomplete project-fifo client API}
data/test.rb CHANGED
@@ -6,6 +6,12 @@ fifo = ProjectFifo.new("http://192.168.1.100/api/0.1.0/", "admin", "admin")
6
6
 
7
7
  fifo.connect
8
8
 
9
+ pp fifo.packages.get_by_name("medium")
10
+ pp fifo.ipranges.get_by_name("default")
11
+ pp fifo.datasets.get_by_name("ubuntu-12.04")
12
+ pp fifo.vms.get_by_name("netatalk")
13
+ exit
14
+
9
15
  fifo.vms.list.each do |id|
10
16
  vm = fifo.vms[id]
11
17
  pp vm.config.dataset
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: project-fifo-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-05-02 00:00:00.000000000 Z
12
+ date: 2013-05-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rest-client