Script 'mail_helper' called by obssrc
Hello community,
here is the log from the commit of package vagrant-libvirt for openSUSE:Factory
checked in at 2021-06-14 23:11:01
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/vagrant-libvirt (Old)
and /work/SRC/openSUSE:Factory/.vagrant-libvirt.new.32437 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "vagrant-libvirt"
Mon Jun 14 23:11:01 2021 rev:13 rq:899876 version:0.5.3
Changes:
--------
--- /work/SRC/openSUSE:Factory/vagrant-libvirt/vagrant-libvirt.changes
2021-06-09 21:52:56.858543780 +0200
+++
/work/SRC/openSUSE:Factory/.vagrant-libvirt.new.32437/vagrant-libvirt.changes
2021-06-14 23:11:31.320797791 +0200
@@ -1,0 +2,6 @@
+Sat Jun 12 09:53:18 UTC 2021 - Martin Hauke <[email protected]>
+
+- Update to version 0.5.3
+ * Use qemu-img json output and compute virtual size.
+
+-------------------------------------------------------------------
Old:
----
vagrant-libvirt-0.5.2.gem
New:
----
vagrant-libvirt-0.5.3.gem
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ vagrant-libvirt.spec ++++++
--- /var/tmp/diff_new_pack.F4B6lC/_old 2021-06-14 23:11:31.796798650 +0200
+++ /var/tmp/diff_new_pack.F4B6lC/_new 2021-06-14 23:11:31.800798658 +0200
@@ -21,7 +21,7 @@
%global rb_ruby_suffix %rb_default_ruby_suffix
Name: vagrant-libvirt
-Version: 0.5.2
+Version: 0.5.3
Release: 0
%define mod_name vagrant-libvirt
%define mod_full_name %{mod_name}-%{version}
++++++ vagrant-libvirt-0.5.2.gem -> vagrant-libvirt-0.5.3.gem ++++++
Binary files old/checksums.yaml.gz and new/checksums.yaml.gz differ
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/vagrant-libvirt/action/create_domain.rb
new/lib/vagrant-libvirt/action/create_domain.rb
--- old/lib/vagrant-libvirt/action/create_domain.rb 2021-06-07
16:33:42.000000000 +0200
+++ new/lib/vagrant-libvirt/action/create_domain.rb 2021-06-11
23:37:46.000000000 +0200
@@ -266,7 +266,7 @@
end
env[:ui].info(" -- Storage pool: #{@storage_pool_name}")
@domain_volumes.each do |volume|
- env[:ui].info(" -- Image(#{volume[:device]}):
#{volume[:path]}, #{volume[:virtual_size]}G")
+ env[:ui].info(" -- Image(#{volume[:device]}):
#{volume[:path]}, #{volume[:virtual_size].to_GB}G")
end
if not @disk_driver_opts.empty?
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/vagrant-libvirt/action/create_domain_volume.rb
new/lib/vagrant-libvirt/action/create_domain_volume.rb
--- old/lib/vagrant-libvirt/action/create_domain_volume.rb 2021-06-07
16:33:42.000000000 +0200
+++ new/lib/vagrant-libvirt/action/create_domain_volume.rb 2021-06-11
23:37:46.000000000 +0200
@@ -39,7 +39,7 @@
@backing_file = box_volume.path
# Virtual size of image. Take value worked out by HandleBoxImage
- @capacity = env[:box_volumes][index][:virtual_size] # G
+ @capacity = env[:box_volumes][index][:virtual_size].to_B # Byte
# Create new volume from xml template. Fog currently doesn't
support
# volume snapshots directly.
@@ -47,7 +47,7 @@
xml = Nokogiri::XML::Builder.new do |xml|
xml.volume do
xml.name(@name)
- xml.capacity(@capacity, unit: 'G')
+ xml.capacity(@capacity, unit: 'B')
xml.target do
xml.format(type: 'qcow2')
xml.permissions do
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/vagrant-libvirt/action/handle_box_image.rb
new/lib/vagrant-libvirt/action/handle_box_image.rb
--- old/lib/vagrant-libvirt/action/handle_box_image.rb 2021-06-07
16:33:42.000000000 +0200
+++ new/lib/vagrant-libvirt/action/handle_box_image.rb 2021-06-11
23:37:46.000000000 +0200
@@ -1,5 +1,8 @@
require 'log4r'
require 'open3'
+require 'json'
+
+require 'vagrant-libvirt/util/byte_number'
module VagrantPlugins
module ProviderLibvirt
@@ -65,7 +68,7 @@
{
:path => image_path,
:name => volume_name,
- :virtual_size => virtual_size.to_i,
+ :virtual_size => virtual_size,
:format => HandleBoxImage.verify_box_format(format)
}
}
@@ -81,16 +84,18 @@
# Override box_virtual_size
box_virtual_size = env[:box_volumes][0][:virtual_size]
if config.machine_virtual_size
- if config.machine_virtual_size < box_virtual_size
+ config_machine_virtual_size =
ByteNumber.from_GB(config.machine_virtual_size)
+ puts config_machine_virtual_size < box_virtual_size
+ if config_machine_virtual_size < box_virtual_size
# Warn that a virtual size less than the box metadata size
# is not supported and will be ignored
env[:ui].warn I18n.t(
'vagrant_libvirt.warnings.ignoring_virtual_size_too_small',
- requested: config.machine_virtual_size, minimum:
box_virtual_size
+ requested: config_machine_virtual_size.to_GB, minimum:
box_virtual_size.to_GB
)
else
env[:ui].info I18n.t('vagrant_libvirt.manual_resize_required')
- box_virtual_size = config.machine_virtual_size
+ box_virtual_size = config_machine_virtual_size
end
end
# save for use by later actions
@@ -131,7 +136,7 @@
# Virtual size has to be set for allocating space in storage pool.
box_virtual_size = env[:machine].box.metadata['virtual_size']
raise Errors::NoBoxVirtualSizeSet if box_virtual_size.nil?
- return box_virtual_size
+ return ByteNumber.from_GB(box_virtual_size)
end
def self.get_box_image_path(box, box_name)
@@ -153,14 +158,14 @@
end
def self.get_box_disk_settings(image_path)
- stdout, stderr, status = Open3.capture3('qemu-img', 'info',
image_path)
+ stdout, stderr, status = Open3.capture3('qemu-img', 'info',
'--output=json', image_path)
if !status.success?
raise Errors::BadBoxImage, image: image_path, out: stdout, err:
stderr
end
- image_info_lines = stdout.split("\n")
- format = image_info_lines.find { |l| l.start_with?('file format:')
}.split(' ')[2]
- virtual_size = image_info_lines.find { |l| l.start_with?('virtual
size:') }.split(' ')[2]
+ image_info = JSON.parse(stdout)
+ format = image_info['format']
+ virtual_size = ByteNumber.new(image_info['virtual-size'])
return format, virtual_size
end
@@ -178,12 +183,11 @@
message = "Creating volume #{box_volume[:name]}"
message << " in storage pool #{config.storage_pool_name}."
@logger.info(message)
-
begin
fog_volume =
env[:machine].provider.driver.connection.volumes.create(
name: box_volume[:name],
allocation: "#{box_image_size / 1024 / 1024}M",
- capacity: "#{box_volume[:virtual_size]}G",
+ capacity: "#{box_volume[:virtual_size].to_B}B",
format_type: box_volume[:format],
owner: storage_uid(env),
group: storage_gid(env),
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/vagrant-libvirt/util/byte_number.rb
new/lib/vagrant-libvirt/util/byte_number.rb
--- old/lib/vagrant-libvirt/util/byte_number.rb 1970-01-01 01:00:00.000000000
+0100
+++ new/lib/vagrant-libvirt/util/byte_number.rb 2021-06-11 23:37:46.000000000
+0200
@@ -0,0 +1,71 @@
+class ByteNumber < Numeric
+ def initialize(int)
+ @int = int
+ end
+
+ def to_s
+ @int.to_s
+ end
+
+ def to_i
+ @int
+ end
+
+ def to_f
+ @int.to_f
+ end
+
+ def to_B
+ to_i
+ end
+
+ def to_KB
+ _compute_unit_to_n_kilo(1)
+ end
+
+ def to_MB
+ _compute_unit_to_n_kilo(2)
+ end
+
+ def to_GB
+ _compute_unit_to_n_kilo(3)
+ end
+
+ def coerce(other)
+ to_i.coerce(other)
+ end
+
+ def <=>(other)
+ to_i <=> other
+ end
+
+ def +(other)
+ to_i + other
+ end
+
+ def -(other)
+ to_i - other
+ end
+
+ def *(other)
+ to_i * other
+ end
+
+ def /(other)
+ to_i / other
+ end
+
+ def pow(n)
+ self.class.new(to_i ** n)
+ end
+
+ def self.from_GB(value)
+ self.new(value*(1024**3))
+ end
+
+ private
+ def _compute_unit_to_n_kilo(n=0)
+ (to_f/(1024 ** n)).ceil
+ end
+end
+
\ No newline at end of file
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/vagrant-libvirt/version
new/lib/vagrant-libvirt/version
--- old/lib/vagrant-libvirt/version 2021-06-07 16:33:42.000000000 +0200
+++ new/lib/vagrant-libvirt/version 2021-06-11 23:37:46.000000000 +0200
@@ -1 +1 @@
-0.5.2
+0.5.3
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/metadata new/metadata
--- old/metadata 2021-06-07 16:33:42.000000000 +0200
+++ new/metadata 2021-06-11 23:37:46.000000000 +0200
@@ -1,7 +1,7 @@
--- !ruby/object:Gem::Specification
name: vagrant-libvirt
version: !ruby/object:Gem::Version
- version: 0.5.2
+ version: 0.5.3
platform: ruby
authors:
- Lukas Stanek
@@ -11,7 +11,7 @@
autorequire:
bindir: bin
cert_chain: []
-date: 2021-06-07 00:00:00.000000000 Z
+date: 2021-06-11 00:00:00.000000000 Z
dependencies:
- !ruby/object:Gem::Dependency
name: rspec-core
@@ -216,6 +216,7 @@
- lib/vagrant-libvirt/templates/private_network.xml.erb
- lib/vagrant-libvirt/templates/public_interface.xml.erb
- lib/vagrant-libvirt/util.rb
+- lib/vagrant-libvirt/util/byte_number.rb
- lib/vagrant-libvirt/util/collection.rb
- lib/vagrant-libvirt/util/erb_template.rb
- lib/vagrant-libvirt/util/error_codes.rb
@@ -256,12 +257,14 @@
- spec/unit/action/start_domain_spec/default_added_tpm_version.xml
- spec/unit/action/wait_till_up_spec.rb
- spec/unit/config_spec.rb
+- spec/unit/provider_spec.rb
- spec/unit/templates/domain_all_settings.xml
- spec/unit/templates/domain_custom_cpu_model.xml
- spec/unit/templates/domain_defaults.xml
- spec/unit/templates/domain_spec.rb
- spec/unit/templates/tpm/version_1.2.xml
- spec/unit/templates/tpm/version_2.0.xml
+- spec/unit/util/byte_number_spec.rb
homepage: https://github.com/vagrant-libvirt/vagrant-libvirt
licenses:
- MIT
@@ -310,6 +313,8 @@
- spec/unit/action/halt_domain_spec.rb
- spec/unit/action/create_domain_volume_spec.rb
- spec/unit/config_spec.rb
+- spec/unit/util/byte_number_spec.rb
+- spec/unit/provider_spec.rb
- spec/unit/templates/domain_defaults.xml
- spec/unit/templates/domain_all_settings.xml
- spec/unit/templates/domain_spec.rb
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/spec/unit/action/create_domain_volume_spec/one_disk_in_storage.xml
new/spec/unit/action/create_domain_volume_spec/one_disk_in_storage.xml
--- old/spec/unit/action/create_domain_volume_spec/one_disk_in_storage.xml
2021-06-07 16:33:42.000000000 +0200
+++ new/spec/unit/action/create_domain_volume_spec/one_disk_in_storage.xml
2021-06-11 23:37:46.000000000 +0200
@@ -1,6 +1,6 @@
<volume>
<name>test.img</name>
- <capacity unit="G">5</capacity>
+ <capacity unit="B">5368709120</capacity>
<target>
<format type="qcow2"></format>
<permissions>
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/spec/unit/action/create_domain_volume_spec/three_disks_in_storage_disk_0.xml
new/spec/unit/action/create_domain_volume_spec/three_disks_in_storage_disk_0.xml
---
old/spec/unit/action/create_domain_volume_spec/three_disks_in_storage_disk_0.xml
2021-06-07 16:33:42.000000000 +0200
+++
new/spec/unit/action/create_domain_volume_spec/three_disks_in_storage_disk_0.xml
2021-06-11 23:37:46.000000000 +0200
@@ -1,6 +1,6 @@
<volume>
<name>test.img</name>
- <capacity unit="G">5</capacity>
+ <capacity unit="B">5368709120</capacity>
<target>
<format type="qcow2"></format>
<permissions>
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/spec/unit/action/create_domain_volume_spec/three_disks_in_storage_disk_1.xml
new/spec/unit/action/create_domain_volume_spec/three_disks_in_storage_disk_1.xml
---
old/spec/unit/action/create_domain_volume_spec/three_disks_in_storage_disk_1.xml
2021-06-07 16:33:42.000000000 +0200
+++
new/spec/unit/action/create_domain_volume_spec/three_disks_in_storage_disk_1.xml
2021-06-11 23:37:46.000000000 +0200
@@ -1,6 +1,6 @@
<volume>
<name>test_1.img</name>
- <capacity unit="G">10</capacity>
+ <capacity unit="B">10737423360</capacity>
<target>
<format type="qcow2"></format>
<permissions>
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/spec/unit/action/create_domain_volume_spec/three_disks_in_storage_disk_2.xml
new/spec/unit/action/create_domain_volume_spec/three_disks_in_storage_disk_2.xml
---
old/spec/unit/action/create_domain_volume_spec/three_disks_in_storage_disk_2.xml
2021-06-07 16:33:42.000000000 +0200
+++
new/spec/unit/action/create_domain_volume_spec/three_disks_in_storage_disk_2.xml
2021-06-11 23:37:46.000000000 +0200
@@ -1,6 +1,6 @@
<volume>
<name>test_2.img</name>
- <capacity unit="G">20</capacity>
+ <capacity unit="B">21474836480</capacity>
<target>
<format type="qcow2"></format>
<permissions>
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/spec/unit/action/create_domain_volume_spec.rb
new/spec/unit/action/create_domain_volume_spec.rb
--- old/spec/unit/action/create_domain_volume_spec.rb 2021-06-07
16:33:42.000000000 +0200
+++ new/spec/unit/action/create_domain_volume_spec.rb 2021-06-11
23:37:46.000000000 +0200
@@ -3,6 +3,8 @@
require 'support/libvirt_context'
require 'vagrant-libvirt/action/destroy_domain'
+require 'vagrant-libvirt/util/byte_number'
+
describe VagrantPlugins::ProviderLibvirt::Action::CreateDomainVolume do
subject { described_class.new(app, env) }
@@ -38,7 +40,7 @@
env[:box_volumes] = [
{
:name=>"test_vagrant_box_image_1.1.1_0.img",
- :virtual_size=>5
+ :virtual_size=>ByteNumber.new(5368709120)
}
]
end
@@ -65,15 +67,15 @@
env[:box_volumes] = [
{
:name=>"test_vagrant_box_image_1.1.1_0.img",
- :virtual_size=>5
+ :virtual_size=>ByteNumber.new(5368709120)
},
{
:name=>"test_vagrant_box_image_1.1.1_1.img",
- :virtual_size=>10
+ :virtual_size=>ByteNumber.new(10737423360)
},
{
:name=>"test_vagrant_box_image_1.1.1_2.img",
- :virtual_size=>20
+ :virtual_size=>ByteNumber.new(21474836480)
}
]
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/spec/unit/action/handle_box_image_spec.rb
new/spec/unit/action/handle_box_image_spec.rb
--- old/spec/unit/action/handle_box_image_spec.rb 2021-06-07
16:33:42.000000000 +0200
+++ new/spec/unit/action/handle_box_image_spec.rb 2021-06-11
23:37:46.000000000 +0200
@@ -1,8 +1,11 @@
require 'spec_helper'
+require 'json'
require 'support/sharedcontext'
require 'support/libvirt_context'
require 'vagrant-libvirt/action/destroy_domain'
+require 'vagrant-libvirt/util/byte_number'
+
describe VagrantPlugins::ProviderLibvirt::Action::HandleBoxImage do
subject { described_class.new(app, env) }
@@ -15,6 +18,41 @@
let(:all) { double('all') }
let(:box_volume) { double('box_volume') }
let(:fog_volume) { double('fog_volume') }
+ let(:config) { double('config') }
+
+ qemu_json_return_5G = JSON.dump({
+ "virtual-size": 5368709120,
+ "filename": "/test/box.img",
+ "cluster-size": 65536,
+ "format": "qcow2",
+ "actual-size": 655360,
+ "dirty-flag": false
+ })
+ byte_number_5G = ByteNumber.new(5368709120)
+
+
+ qemu_json_return_10G = JSON.dump({
+ "virtual-size": 10737423360,
+ "filename": "/test/disk.qcow2",
+ "cluster-size": 65536,
+ "format": "qcow2",
+ "actual-size": 655360,
+ "dirty-flag": false
+ })
+ byte_number_10G = ByteNumber.new(10737423360)
+
+ qemu_json_return_20G = JSON.dump({
+ "virtual-size": 21474836480,
+ "filename": "/test/box_2.img",
+ "cluster-size": 65536,
+ "format": "qcow2",
+ "actual-size": 1508708352,
+ "dirty-flag": false
+ })
+ byte_number_20G = ByteNumber.new(21474836480)
+
+
+
describe '#call' do
before do
@@ -51,13 +89,53 @@
{
:path=>"/test/box.img",
:name=>"test_vagrant_box_image_1.1.1_box.img",
- :virtual_size=>5,
+ :virtual_size=>byte_number_5G,
:format=>"qcow2"
}
]
)
end
+ context 'When config.machine_virtual_size is set and smaller than
box_virtual_size' do
+ before do
+ allow(env[:machine]).to
receive_message_chain("provider_config.machine_virtual_size").and_return(1)
+ end
+ it 'should warning must be raise' do
+ expect(ui).to receive(:warn).with("Ignoring requested virtual disk
size of '1' as it is below\nthe minimum box image size of '5'.")
+ expect(subject.call(env)).to be_nil
+ expect(env[:box_volumes]).to eq(
+ [
+ {
+ :path=>"/test/box.img",
+ :name=>"test_vagrant_box_image_1.1.1_box.img",
+ :virtual_size=>byte_number_5G,
+ :format=>"qcow2"
+ }
+ ]
+ )
+ end
+ end
+
+ context 'When config.machine_virtual_size is set and higher than
box_virtual_size' do
+ before do
+ allow(env[:machine]).to
receive_message_chain("provider_config.machine_virtual_size").and_return(20)
+ end
+ it 'should be use' do
+ expect(ui).to receive(:info).with("Created volume larger than box
defaults, will require manual resizing of\nfilesystems to utilize.")
+ expect(subject.call(env)).to be_nil
+ expect(env[:box_volumes]).to eq(
+ [
+ {
+ :path=>"/test/box.img",
+ :name=>"test_vagrant_box_image_1.1.1_box.img",
+ :virtual_size=>byte_number_20G,
+ :format=>"qcow2"
+ }
+ ]
+ )
+ end
+ end
+
context 'when disk image not in storage pool' do
before do
allow(File).to receive(:exist?).and_return(true)
@@ -74,7 +152,7 @@
hash_including(
:name => "test_vagrant_box_image_1.1.1_box.img",
:allocation => "5120M",
- :capacity => "5G",
+ :capacity => "5368709120B",
)
)
expect(subject).to receive(:upload_image)
@@ -122,14 +200,14 @@
'/test/'.concat(arg.to_s)
end
allow(status).to receive(:success?).and_return(true)
- allow(Open3).to receive(:capture3).with('qemu-img', 'info',
'/test/box.img').and_return([
- "image: /test/box.img\nfile format: qcow2\nvirtual size: 5 GiB
(5368709120 bytes)\ndisk size: 1.45 GiB\n", "", status
+ allow(Open3).to receive(:capture3).with('qemu-img', 'info',
'--output=json', '/test/box.img').and_return([
+ qemu_json_return_5G, "", status
])
- allow(Open3).to receive(:capture3).with('qemu-img', 'info',
'/test/disk.qcow2').and_return([
- "image: /test/disk.qcow2\nfile format: qcow2\nvirtual size: 10 GiB
(10737418240 bytes)\ndisk size: 1.45 GiB\n", "", status
+ allow(Open3).to receive(:capture3).with('qemu-img', 'info',
'--output=json', '/test/disk.qcow2').and_return([
+ qemu_json_return_10G, "", status
])
- allow(Open3).to receive(:capture3).with('qemu-img', 'info',
'/test/box_2.img').and_return([
- "image: /test/box_2.img\nfile format: qcow2\nvirtual size: 20 GiB
(21474836480 bytes)\ndisk size: 1.45 GiB\n", "", status
+ allow(Open3).to receive(:capture3).with('qemu-img', 'info',
'--output=json', '/test/box_2.img').and_return([
+ qemu_json_return_20G, "", status
])
end
@@ -141,19 +219,19 @@
{
:path=>"/test/box.img",
:name=>"test_vagrant_box_image_1.1.1_send_box_name.img",
- :virtual_size=>5,
+ :virtual_size=>byte_number_5G,
:format=>"qcow2"
},
{
:path=>"/test/disk.qcow2",
:name=>"test_vagrant_box_image_1.1.1_disk.img",
- :virtual_size=>10,
+ :virtual_size=>byte_number_10G,
:format=>"qcow2"
},
{
:path=>"/test/box_2.img",
:name=>"test_vagrant_box_image_1.1.1_box_2.img",
- :virtual_size=>20,
+ :virtual_size=>byte_number_20G,
:format=>"qcow2"
}
]
@@ -176,7 +254,7 @@
hash_including(
:name => "test_vagrant_box_image_1.1.1_send_box_name.img",
:allocation => "5120M",
- :capacity => "5G",
+ :capacity => "5368709120B",
)
)
expect(subject).to receive(:upload_image)
@@ -186,7 +264,7 @@
hash_including(
:name => "test_vagrant_box_image_1.1.1_disk.img",
:allocation => "10240M",
- :capacity => "10G",
+ :capacity => "10737423360B",
)
)
expect(subject).to receive(:upload_image)
@@ -196,7 +274,7 @@
hash_including(
:name => "test_vagrant_box_image_1.1.1_box_2.img",
:allocation => "20480M",
- :capacity => "20G",
+ :capacity => "21474836480B",
)
)
expect(subject).to receive(:upload_image)
@@ -279,14 +357,14 @@
'/test/'.concat(arg.to_s)
end
allow(status).to receive(:success?).and_return(true)
- allow(Open3).to receive(:capture3).with('qemu-img', 'info',
'/test/box.img').and_return([
- "image: /test/box.img\nfile format: qcow2\nvirtual size: 5 GiB
(5368709120 bytes)\ndisk size: 1.45 GiB\n", "", status
+ allow(Open3).to receive(:capture3).with('qemu-img', 'info',
"--output=json", '/test/box.img').and_return([
+ qemu_json_return_5G, "", status
])
- allow(Open3).to receive(:capture3).with('qemu-img', 'info',
'/test/disk.qcow2').and_return([
- "image: /test/disk.qcow2\nfile format: qcow2\nvirtual size: 10 GiB
(10737418240 bytes)\ndisk size: 1.45 GiB\n", "", status
+ allow(Open3).to receive(:capture3).with('qemu-img', 'info',
"--output=json", '/test/disk.qcow2').and_return([
+ qemu_json_return_10G, "", status
])
- allow(Open3).to receive(:capture3).with('qemu-img', 'info',
'/test/box_2.img').and_return([
- "image: /test/box_2.img\nfile format: qcow2\nvirtual size: 20 GiB
(21474836480 bytes)\ndisk size: 1.45 GiB\n", "", status
+ allow(Open3).to receive(:capture3).with('qemu-img', 'info',
"--output=json", '/test/box_2.img').and_return([
+ qemu_json_return_20G, "", status
])
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/spec/unit/provider_spec.rb
new/spec/unit/provider_spec.rb
--- old/spec/unit/provider_spec.rb 1970-01-01 01:00:00.000000000 +0100
+++ new/spec/unit/provider_spec.rb 2021-06-11 23:37:46.000000000 +0200
@@ -0,0 +1,11 @@
+require 'spec_helper'
+require 'support/sharedcontext'
+
+describe 'VagrantPlugins::ProviderLibvirt::Provider' do
+ require 'vagrant-libvirt/provider'
+
+ include_context 'unit'
+
+ describe '#ssh_info' do
+ end
+end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/spec/unit/util/byte_number_spec.rb
new/spec/unit/util/byte_number_spec.rb
--- old/spec/unit/util/byte_number_spec.rb 1970-01-01 01:00:00.000000000
+0100
+++ new/spec/unit/util/byte_number_spec.rb 2021-06-11 23:37:46.000000000
+0200
@@ -0,0 +1,26 @@
+require 'spec_helper'
+
+require 'vagrant-libvirt/util/byte_number'
+
+
+describe ByteNumber do
+ describe '#ByteNumber to Gigrabyte' do
+ it 'should return bigger size' do
+ expect( ByteNumber.new("10737423360").to_GB).to eq(11)
+ expect( ByteNumber.new("737423360").to_GB).to eq(1)
+ expect( ByteNumber.new("110737423360").to_GB).to eq(104)
+ end
+ end
+
+ describe '#ByteNumber from Gigrabyte' do
+ it 'should convert' do
+ expect( ByteNumber.from_GB(5).to_i).to eq(5368709120)
+ end
+ end
+
+ describe '#ByteNumber pow' do
+ it 'should be work like interger' do
+ expect( ByteNumber.new(5).pow(5).to_i).to eq(5**5)
+ end
+ end
+end
\ No newline at end of file