Skip to content

Commit

Permalink
M #-: Add prefix method to older IPAddr (#1049)
Browse files Browse the repository at this point in the history
* Revert "M #-: Update Gemfile.locks (#1040)"

This reverts commit 0dcde4b.

* M #-: Add prefix method to older IPAddr
  • Loading branch information
xorel authored Mar 31, 2021
1 parent fe2eb12 commit 1187d77
Show file tree
Hide file tree
Showing 12 changed files with 29 additions and 35 deletions.
4 changes: 1 addition & 3 deletions share/install_gems/CentOS7/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ GEM
public_suffix (>= 2.0.2, < 5.0)
augeas (0.6.4)
aws-eventstream (1.1.1)
aws-partitions (1.436.0)
aws-partitions (1.434.0)
aws-sdk-cloudwatch (1.50.0)
aws-sdk-core (~> 3, >= 3.112.0)
aws-sigv4 (~> 1.1)
Expand Down Expand Up @@ -73,7 +73,6 @@ GEM
i18n (0.9.5)
concurrent-ruby (~> 1.0)
inflection (1.0.0)
ipaddr (1.2.2)
ipaddress (0.8.3)
jmespath (1.4.0)
json (2.5.1)
Expand Down Expand Up @@ -170,7 +169,6 @@ DEPENDENCIES
gnuplot
highline (~> 1.7)
i18n (~> 0.9)
ipaddr (>= 1.2.2)
ipaddress (~> 0.8.3)
json (>= 2.0)
memcache-client
Expand Down
4 changes: 1 addition & 3 deletions share/install_gems/CentOS8/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ GEM
augeas (0.6.4)
awrence (1.2.1)
aws-eventstream (1.1.1)
aws-partitions (1.436.0)
aws-partitions (1.434.0)
aws-sdk-cloudwatch (1.50.0)
aws-sdk-core (~> 3, >= 3.112.0)
aws-sigv4 (~> 1.1)
Expand Down Expand Up @@ -80,7 +80,6 @@ GEM
i18n (0.9.5)
concurrent-ruby (~> 1.0)
inflection (1.0.0)
ipaddr (1.2.2)
ipaddress (0.8.3)
jmespath (1.4.0)
json (2.5.1)
Expand Down Expand Up @@ -212,7 +211,6 @@ DEPENDENCIES
gnuplot
highline (~> 1.7)
i18n (~> 0.9)
ipaddr (>= 1.2.2)
ipaddress (~> 0.8.3)
json (>= 2.0)
memcache-client
Expand Down
4 changes: 1 addition & 3 deletions share/install_gems/Debian10/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ GEM
augeas (0.6.4)
awrence (1.2.1)
aws-eventstream (1.1.1)
aws-partitions (1.436.0)
aws-partitions (1.434.0)
aws-sdk-cloudwatch (1.50.0)
aws-sdk-core (~> 3, >= 3.112.0)
aws-sigv4 (~> 1.1)
Expand Down Expand Up @@ -80,7 +80,6 @@ GEM
i18n (0.9.5)
concurrent-ruby (~> 1.0)
inflection (1.0.0)
ipaddr (1.2.2)
ipaddress (0.8.3)
jmespath (1.4.0)
json (2.5.1)
Expand Down Expand Up @@ -212,7 +211,6 @@ DEPENDENCIES
gnuplot
highline (~> 1.7)
i18n (~> 0.9)
ipaddr (>= 1.2.2)
ipaddress (~> 0.8.3)
json (>= 2.0)
memcache-client
Expand Down
4 changes: 1 addition & 3 deletions share/install_gems/Debian9/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ GEM
public_suffix (>= 2.0.2, < 5.0)
augeas (0.6.4)
aws-eventstream (1.1.1)
aws-partitions (1.436.0)
aws-partitions (1.434.0)
aws-sdk-cloudwatch (1.50.0)
aws-sdk-core (~> 3, >= 3.112.0)
aws-sigv4 (~> 1.1)
Expand Down Expand Up @@ -73,7 +73,6 @@ GEM
i18n (0.9.5)
concurrent-ruby (~> 1.0)
inflection (1.0.0)
ipaddr (1.2.2)
ipaddress (0.8.3)
jmespath (1.4.0)
json (2.5.1)
Expand Down Expand Up @@ -180,7 +179,6 @@ DEPENDENCIES
gnuplot
highline (~> 1.7)
i18n (~> 0.9)
ipaddr (>= 1.2.2)
ipaddress (~> 0.8.3)
json (>= 2.0)
memcache-client
Expand Down
4 changes: 1 addition & 3 deletions share/install_gems/Fedora32/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ GEM
augeas (0.6.4)
awrence (1.2.1)
aws-eventstream (1.1.1)
aws-partitions (1.436.0)
aws-partitions (1.434.0)
aws-sdk-cloudwatch (1.50.0)
aws-sdk-core (~> 3, >= 3.112.0)
aws-sigv4 (~> 1.1)
Expand Down Expand Up @@ -80,7 +80,6 @@ GEM
i18n (0.9.5)
concurrent-ruby (~> 1.0)
inflection (1.0.0)
ipaddr (1.2.2)
ipaddress (0.8.3)
jmespath (1.4.0)
json (2.5.1)
Expand Down Expand Up @@ -212,7 +211,6 @@ DEPENDENCIES
gnuplot
highline (~> 1.7)
i18n (~> 0.9)
ipaddr (>= 1.2.2)
ipaddress (~> 0.8.3)
json (>= 2.0)
memcache-client
Expand Down
4 changes: 1 addition & 3 deletions share/install_gems/Fedora33/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ GEM
augeas (0.6.4)
awrence (1.2.1)
aws-eventstream (1.1.1)
aws-partitions (1.436.0)
aws-partitions (1.434.0)
aws-sdk-cloudwatch (1.50.0)
aws-sdk-core (~> 3, >= 3.112.0)
aws-sigv4 (~> 1.1)
Expand Down Expand Up @@ -80,7 +80,6 @@ GEM
i18n (0.9.5)
concurrent-ruby (~> 1.0)
inflection (1.0.0)
ipaddr (1.2.2)
ipaddress (0.8.3)
jmespath (1.4.0)
json (2.5.1)
Expand Down Expand Up @@ -212,7 +211,6 @@ DEPENDENCIES
gnuplot
highline (~> 1.7)
i18n (~> 0.9)
ipaddr (>= 1.2.2)
ipaddress (~> 0.8.3)
json (>= 2.0)
memcache-client
Expand Down
4 changes: 0 additions & 4 deletions share/install_gems/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,3 @@ group :vmware do
gem 'rbvmomi', '~> 2.2.0'
end
end

group :oneprovision do
gem 'ipaddr', '>= 1.2.2'
end
4 changes: 1 addition & 3 deletions share/install_gems/Ubuntu1604/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ GEM
public_suffix (>= 2.0.2, < 5.0)
augeas (0.6.4)
aws-eventstream (1.1.1)
aws-partitions (1.436.0)
aws-partitions (1.434.0)
aws-sdk-cloudwatch (1.50.0)
aws-sdk-core (~> 3, >= 3.112.0)
aws-sigv4 (~> 1.1)
Expand Down Expand Up @@ -73,7 +73,6 @@ GEM
i18n (0.9.5)
concurrent-ruby (~> 1.0)
inflection (1.0.0)
ipaddr (1.2.2)
ipaddress (0.8.3)
jmespath (1.4.0)
json (2.5.1)
Expand Down Expand Up @@ -180,7 +179,6 @@ DEPENDENCIES
gnuplot
highline (~> 1.7)
i18n (~> 0.9)
ipaddr (>= 1.2.2)
ipaddress (~> 0.8.3)
json (>= 2.0)
memcache-client
Expand Down
4 changes: 1 addition & 3 deletions share/install_gems/Ubuntu1804/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ GEM
augeas (0.6.4)
awrence (1.2.1)
aws-eventstream (1.1.1)
aws-partitions (1.436.0)
aws-partitions (1.434.0)
aws-sdk-cloudwatch (1.50.0)
aws-sdk-core (~> 3, >= 3.112.0)
aws-sigv4 (~> 1.1)
Expand Down Expand Up @@ -80,7 +80,6 @@ GEM
i18n (0.9.5)
concurrent-ruby (~> 1.0)
inflection (1.0.0)
ipaddr (1.2.2)
ipaddress (0.8.3)
jmespath (1.4.0)
json (2.5.1)
Expand Down Expand Up @@ -212,7 +211,6 @@ DEPENDENCIES
gnuplot
highline (~> 1.7)
i18n (~> 0.9)
ipaddr (>= 1.2.2)
ipaddress (~> 0.8.3)
json (>= 2.0)
memcache-client
Expand Down
4 changes: 1 addition & 3 deletions share/install_gems/Ubuntu2004/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ GEM
augeas (0.6.4)
awrence (1.2.1)
aws-eventstream (1.1.1)
aws-partitions (1.436.0)
aws-partitions (1.434.0)
aws-sdk-cloudwatch (1.50.0)
aws-sdk-core (~> 3, >= 3.112.0)
aws-sigv4 (~> 1.1)
Expand Down Expand Up @@ -80,7 +80,6 @@ GEM
i18n (0.9.5)
concurrent-ruby (~> 1.0)
inflection (1.0.0)
ipaddr (1.2.2)
ipaddress (0.8.3)
jmespath (1.4.0)
json (2.5.1)
Expand Down Expand Up @@ -212,7 +211,6 @@ DEPENDENCIES
gnuplot
highline (~> 1.7)
i18n (~> 0.9)
ipaddr (>= 1.2.2)
ipaddress (~> 0.8.3)
json (>= 2.0)
memcache-client
Expand Down
4 changes: 1 addition & 3 deletions share/install_gems/Ubuntu2010/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ GEM
augeas (0.6.4)
awrence (1.2.1)
aws-eventstream (1.1.1)
aws-partitions (1.436.0)
aws-partitions (1.434.0)
aws-sdk-cloudwatch (1.50.0)
aws-sdk-core (~> 3, >= 3.112.0)
aws-sigv4 (~> 1.1)
Expand Down Expand Up @@ -80,7 +80,6 @@ GEM
i18n (0.9.5)
concurrent-ruby (~> 1.0)
inflection (1.0.0)
ipaddr (1.2.2)
ipaddress (0.8.3)
jmespath (1.4.0)
json (2.5.1)
Expand Down Expand Up @@ -212,7 +211,6 @@ DEPENDENCIES
gnuplot
highline (~> 1.7)
i18n (~> 0.9)
ipaddr (>= 1.2.2)
ipaddress (~> 0.8.3)
json (>= 2.0)
memcache-client
Expand Down
20 changes: 19 additions & 1 deletion src/ipamm_mad/remotes/packet/register_address_range
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,31 @@ IP_TYPE = %w[public_ipv4 global_ipv4]

DEFAULT_PRIVATE_CIDR = "172.16.0.0/12"

# Add ^ operator to the IPAddr class
class IPAddr

# Add ^ operator to the IPAddr class
def ^(other)
clone.set(@addr ^ other.to_i)
end

# Add prefix method, to work with older ipadddr & ruby
def prefix
case @family
when Socket::AF_INET
n = IN4MASK ^ @mask_addr
i = 32
when Socket::AF_INET6
n = IN6MASK ^ @mask_addr
i = 128
else
raise AddressFamilyError, "unsupported address family"
end
while n>0
n >>= 1
i -= 1
end
i
end
end

begin
Expand Down

0 comments on commit 1187d77

Please sign in to comment.