Skip to content

Commit ae1dcd7

Browse files
author
Peter Wang
committed
Avoid uploading license if all features are same
If the features in the license file are the same with the installed features on the Unity, skips the uploading.
1 parent 95ff04c commit ae1dcd7

File tree

7 files changed

+59
-8
lines changed

7 files changed

+59
-8
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -649,4 +649,6 @@ peter.wang13 at emc.com
649649

650650
## Release Notes
651651

652-
0.1.0 - Initial release.
652+
0.1.0 - Initial release.
653+
0.1.1 - Add license differential uploading.
654+
- Pool expansion if new raid groups are added.

examples/example_license.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
unity_system { 'FNM00150600267':
2-
ip => '10.245.101.35',
2+
ip => '10.245.101.39',
33
user => 'admin',
44
password => 'Password123!',
55
}

examples/example_lun.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
# Define a Unity System
33
unity_system { 'FNM00150600267':
4-
ip => '10.245.101.35',
4+
ip => '10.245.101.39',
55
user => 'admin',
66
password => 'Password123!',
77
}

lib/puppet/provider/unity_license/license_provider.rb

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,56 @@ def create
2424

2525
unity = get_unity_system(@resource[:unity_system])
2626
unity.upload_license(@resource[:license_file].to_s)
27+
2728
end
2829

2930
def destroy
3031
Puppet.info "License #{@resource[:licence_file]} is not able to remove from Unity system."
3132
end
3233

3334
def exists?
34-
Puppet.info "License #{@resource[:license_file]} cannot be queried."
35+
Puppet.info "Checking existence of License #{@resource[:license_file]}."
3536
# Always force license uploading.
36-
false
37+
is_license_same? @resource[:license_file].to_s
3738
end
39+
40+
41+
def get_file_info(path)
42+
feature_names = []
43+
File.open(path, 'r') do |license|
44+
while (line = license.gets)
45+
if line.include? 'INCREMENT'
46+
f_name = line.split[1]
47+
feature_names << f_name
48+
end
49+
end
50+
51+
return feature_names
52+
end
53+
end
54+
55+
def get_array_licenses
56+
license_names = []
57+
unity = get_unity_system(@resource[:unity_system])
58+
licenses = unity.get_license
59+
licenses.to_enum.each do |license|
60+
license_names << license.name.to_s
61+
end
62+
63+
license_names
64+
65+
end
66+
67+
def is_license_same?(path)
68+
curr = get_array_licenses
69+
file_lic = get_file_info path
70+
if curr.to_set == file_lic.to_set
71+
Puppet.debug "No change in #{path}. Skipping license uploading."
72+
return true
73+
else
74+
Puppet.info "New changes found in #{path}, uploading changes: #{(file_lic.to_set - curr.to_set).to_a}."
75+
return false
76+
end
77+
end
78+
3879
end

lib/puppet/util/dellemc/unity_helper.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,22 @@
88
$storops = RubyPython.import('storops')
99
$storops.enable_log
1010

11+
$unity_info = {}
12+
1113
def get_unity_system(unity_resource)
1214
local_unity = @resource.catalog.resource(unity_resource.to_s)
15+
if $unity_info.include? local_unity[:ip]
16+
Puppet.info "#{local_unity[:ip]} is already connected, using the cached connection."
17+
return $unity_info[local_unity[:ip]]
18+
end
1319
unity = $storops.UnitySystem.new(local_unity[:ip], local_unity[:user], local_unity[:password])
20+
$unity_info[local_unity[:ip]] = unity
21+
22+
unity
1423
end
1524

1625
def get_raid_group_parameters(raid_groups)
1726
pool = RubyPython.import('storops.unity.resource.pool')
18-
disk = RubyPython.import('storops.unity.resource.disk')
1927
parameters = []
2028
raid_groups.each do |raid_group|
2129
# disk_group = disk.UnityDiskGroup.new(raid_group[:disk_group])

metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "dellemc-unity",
3-
"version": "0.1.0",
3+
"version": "0.1.1",
44
"author": "Peter Wang",
55
"summary": "Configure and manage the DellEMC Unity storage systems.",
66
"license": "Apache-2.0",

rebuild_install.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ rem A handy script for debugging the puppet module
44

55
cmd /c puppet module uninstall dellemc-unity
66
cmd /c puppet module build
7-
cmd /c puppet module install ".\pkg\dellemc-unity-0.1.0.tar.gz" --ignore-dependencies
7+
cmd /c puppet module install ".\pkg\dellemc-unity-0.1.1.tar.gz" --ignore-dependencies

0 commit comments

Comments
 (0)