fog-proxmox 0.10.0 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0b70163a7fccb9ed54779d18ca8dc37d6ea04fec9ab2c94c91d13282feb589c6
4
- data.tar.gz: 65b66339365af13f176e4cd4410f58bd9fa46c10c45082852b36bb5beaa4332b
3
+ metadata.gz: d03cdedefefcb299e2a86e1d53560f027fe9178ff076f47b5f349e89e9f801e6
4
+ data.tar.gz: 3200e0a475d337e279d3a6d8a916f6f4aab8259debe6c7a3ef7a7e59487f9c55
5
5
  SHA512:
6
- metadata.gz: 6e85b1ec840dd0bb45da7eec64fb4b0a0727cf99fadc08a6a2f8a1b6a389a280b6ea36420bb611f645be77f19c351b00651f08d32e9448f904f1e4b1e0a91ee4
7
- data.tar.gz: 7e4fcd61713c55989078272a458b98fddb6399eacf36e5dc0d2678925799a48179097cec35bcc0f2332569b432d1c275fd5b25c50ba5d2fe4f3697c6c8f7ec69
6
+ metadata.gz: 63ce8917cda9c49a79fc935015cb11bbf423453ba9a40da51ae04678bfa1907e961214b2d2f47125954dedbee6b2a7dd50298391412d06dbdd6a0dacaee90100
7
+ data.tar.gz: 6e1c8db4bd2c38731bfe0113b26b0d7d5d1ca241da6e03afa1f73675abcf266ba7edc0e7edf84f08c800053cd3ef45195e0c34f364c4bf57acda3ed7b917f297
@@ -156,7 +156,6 @@ module Fog
156
156
 
157
157
  def migrate(target, options = {})
158
158
  request(:migrate_server, options.merge(target: target), vmid: vmid)
159
- reload
160
159
  end
161
160
 
162
161
  def extend(disk, size, options = {})
@@ -41,11 +41,10 @@ module Fog
41
41
 
42
42
  def initialize(new_attributes = {})
43
43
  prepare_service_value(new_attributes)
44
- attributes[:node_id] = new_attributes[:node_id] unless new_attributes[:node_id].nil?
45
- attributes[:server_id] = new_attributes[:server_id] unless new_attributes[:server_id].nil?
46
- attributes[:server_type] = new_attributes[:server_type] unless new_attributes[:server_type].nil?
47
- attributes[:name] = new_attributes[:name] unless new_attributes[:name].nil?
48
- attributes[:name] = new_attributes['name'] unless new_attributes['name'].nil?
44
+ Fog::Proxmox::Attributes.set_attr_and_sym('node_id', attributes, new_attributes)
45
+ Fog::Proxmox::Attributes.set_attr_and_sym('server_id', attributes, new_attributes)
46
+ Fog::Proxmox::Attributes.set_attr_and_sym('server_type', attributes, new_attributes)
47
+ Fog::Proxmox::Attributes.set_attr_and_sym('name', attributes, new_attributes)
49
48
  requires :node_id, :server_id, :server_type, :name
50
49
  super(new_attributes)
51
50
  end
@@ -46,9 +46,8 @@ module Fog
46
46
 
47
47
  def initialize(new_attributes = {})
48
48
  prepare_service_value(new_attributes)
49
- attributes[:node_id] = new_attributes[:node_id] unless new_attributes[:node_id].nil?
50
- attributes[:storage] = new_attributes[:storage] unless new_attributes[:storage].nil?
51
- attributes[:storage] = new_attributes['storage'] unless new_attributes['storage'].nil?
49
+ Fog::Proxmox::Attributes.set_attr_and_sym('node_id', attributes, new_attributes)
50
+ Fog::Proxmox::Attributes.set_attr_and_sym('storage', attributes, new_attributes)
52
51
  requires :node_id, :storage
53
52
  initialize_volumes
54
53
  super(new_attributes)
@@ -47,9 +47,8 @@ module Fog
47
47
 
48
48
  def initialize(new_attributes = {})
49
49
  prepare_service_value(new_attributes)
50
- attributes[:node_id] = new_attributes[:node_id] unless new_attributes[:node_id].nil?
51
- attributes[:upid] = new_attributes[:upid] unless new_attributes[:upid].nil?
52
- attributes[:upid] = new_attributes['upid'] unless new_attributes['upid'].nil?
50
+ Fog::Proxmox::Attributes.set_attr_and_sym('node_id', attributes, new_attributes)
51
+ Fog::Proxmox::Attributes.set_attr_and_sym('upid', attributes, new_attributes)
53
52
  requires :node_id, :upid
54
53
  super(new_attributes)
55
54
  end
@@ -41,9 +41,9 @@ module Fog
41
41
 
42
42
  def initialize(new_attributes = {})
43
43
  prepare_service_value(new_attributes)
44
- attributes[:node_id] = new_attributes[:node_id] unless new_attributes[:node_id].nil?
45
- attributes[:storage_id] = new_attributes[:storage_id] unless new_attributes[:storage_id].nil?
46
- attributes[:volid] = new_attributes['volid'] unless new_attributes['volid'].nil?
44
+ Fog::Proxmox::Attributes.set_attr_and_sym('node_id', attributes, new_attributes)
45
+ Fog::Proxmox::Attributes.set_attr_and_sym('storage_id', attributes, new_attributes)
46
+ Fog::Proxmox::Attributes.set_attr_and_sym('volid', attributes, new_attributes)
47
47
  requires :node_id, :storage_id, :volid
48
48
  super(new_attributes)
49
49
  end
@@ -110,6 +110,22 @@ module Fog
110
110
  val[0].to_i*1024**m
111
111
  end
112
112
 
113
+ def self.modulo_bytes(size)
114
+ size / 1024
115
+ end
116
+
117
+ def self.to_human_bytes(size)
118
+ units = ['Kb','Mb','Gb','Tb','Pb']
119
+ i = 0
120
+ human_size = size.to_s + 'b'
121
+ while i < 5 && size >= 1024
122
+ size = self.modulo_bytes(size)
123
+ human_size = size.to_s + units[i]
124
+ i+=1
125
+ end
126
+ human_size
127
+ end
128
+
113
129
  def self.extract_size(disk_value)
114
130
  size=extract_option('size', disk_value)
115
131
  size ? self.to_bytes(size) : "1G"
@@ -19,6 +19,6 @@
19
19
 
20
20
  module Fog
21
21
  module Proxmox
22
- VERSION = '0.10.0'
22
+ VERSION = '0.11.0'
23
23
  end
24
24
  end
@@ -195,4 +195,16 @@ require 'fog/proxmox/helpers/disk_helper'
195
195
  assert !Fog::Proxmox::DiskHelper.cdrom?('local:iso/alpine-virt-3.7.0-x86_64.iso')
196
196
  end
197
197
  end
198
+
199
+ describe '#to_bytes' do
200
+ it "1Gb returns 1 073 741 824" do
201
+ assert_equal Fog::Proxmox::DiskHelper.to_bytes('1Gb'), 1073741824
202
+ end
203
+ end
204
+
205
+ describe '#to_human_bytes' do
206
+ it "1 073 741 824 returns 1Gb" do
207
+ assert_equal '1Gb', Fog::Proxmox::DiskHelper.to_human_bytes(1073741824)
208
+ end
209
+ end
198
210
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fog-proxmox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tristan Robert
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-30 00:00:00.000000000 Z
11
+ date: 2020-02-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler