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 +4 -4
- data/lib/fog/compute/proxmox/models/server.rb +0 -1
- data/lib/fog/compute/proxmox/models/snapshot.rb +4 -5
- data/lib/fog/compute/proxmox/models/storage.rb +2 -3
- data/lib/fog/compute/proxmox/models/task.rb +2 -3
- data/lib/fog/compute/proxmox/models/volume.rb +3 -3
- data/lib/fog/proxmox/helpers/disk_helper.rb +16 -0
- data/lib/fog/proxmox/version.rb +1 -1
- data/spec/helpers/disk_helper_spec.rb +12 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d03cdedefefcb299e2a86e1d53560f027fe9178ff076f47b5f349e89e9f801e6
|
4
|
+
data.tar.gz: 3200e0a475d337e279d3a6d8a916f6f4aab8259debe6c7a3ef7a7e59487f9c55
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 63ce8917cda9c49a79fc935015cb11bbf423453ba9a40da51ae04678bfa1907e961214b2d2f47125954dedbee6b2a7dd50298391412d06dbdd6a0dacaee90100
|
7
|
+
data.tar.gz: 6e1c8db4bd2c38731bfe0113b26b0d7d5d1ca241da6e03afa1f73675abcf266ba7edc0e7edf84f08c800053cd3ef45195e0c34f364c4bf57acda3ed7b917f297
|
@@ -41,11 +41,10 @@ module Fog
|
|
41
41
|
|
42
42
|
def initialize(new_attributes = {})
|
43
43
|
prepare_service_value(new_attributes)
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
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
|
-
|
50
|
-
|
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
|
-
|
51
|
-
|
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
|
-
|
45
|
-
|
46
|
-
|
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"
|
data/lib/fog/proxmox/version.rb
CHANGED
@@ -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.
|
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-
|
11
|
+
date: 2020-02-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|