Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

add ec2 meta data support for windows platform. #125

Closed
wants to merge 1 commit into from

3 participants

Feifei Jia Ken Barber Daniel Pittman
Feifei Jia

Add a ARP check of windows platform so that Windows server in EC2 can get meta data.

Daniel Pittman daniel-pittman commented on the diff
lib/facter/ec2.rb
((5 lines not shown))
is_amazon_arp = false
- if not arp_table.nil?
- arp_table.each_line do |line|
- is_amazon_arp = true if line.include?('fe:ff:ff:ff:ff:ff')
- break
+ if Facter.value(:operatingsystem) == 'windows'
+ arp_table = Facter::Util::Resolution.exec('arp -a')

The -n on Unix is specifically to prevent MAC address to name translation. I don't think Windows supports that flag; will we always get a hex MAC address there?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Daniel Pittman daniel-pittman commented on the diff
lib/facter/ec2.rb
((5 lines not shown))
is_amazon_arp = false
- if not arp_table.nil?
- arp_table.each_line do |line|
- is_amazon_arp = true if line.include?('fe:ff:ff:ff:ff:ff')
- break
+ if Facter.value(:operatingsystem) == 'windows'

The only line of difference between the two platforms are the arguments passed to the arp command. Can you restructure this code so that there is no duplicate other than that single decision point?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Feifei Jia

The ether address is also different between Windows and Linux.

Daniel Pittman

You are right; it would be good to change that from a strict string match to a regular expression that would match both at the same time; the fundamentals are still identical, and matching both platform patterns at the same time doesn't seem risky. Thanks.

Ken Barber
Owner

I've raised a new request myself here:

#140

Since the ticket became important to solve. See comments in ticket.

Ken Barber kbarber closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 27, 2011
  1. add ec2 meta data support for windows platform.

    Feifei Jia authored
This page is out of date. Refresh to see the latest.
Showing with 15 additions and 5 deletions.
  1. +15 −5 lib/facter/ec2.rb
20 lib/facter/ec2.rb
View
@@ -48,12 +48,22 @@ def has_euca_mac?
# Is there an entry in the arp table for fe:ff:ff:ff:ff:ff,
# this is a red flag for being on amazon
def has_ec2_arp?
- arp_table = Facter::Util::Resolution.exec('arp -an')
is_amazon_arp = false
- if not arp_table.nil?
- arp_table.each_line do |line|
- is_amazon_arp = true if line.include?('fe:ff:ff:ff:ff:ff')
- break
+ if Facter.value(:operatingsystem) == 'windows'

The only line of difference between the two platforms are the arguments passed to the arp command. Can you restructure this code so that there is no duplicate other than that single decision point?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ arp_table = Facter::Util::Resolution.exec('arp -a')

The -n on Unix is specifically to prevent MAC address to name translation. I don't think Windows supports that flag; will we always get a hex MAC address there?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ if not arp_table.nil?
+ arp_table.each_line("\r\n") do |line|
+ is_amazon_arp = true if line.include?('fe-ff-ff-ff-ff-ff')
+ break
+ end
+ end
+ else
+ arp_table = Facter::Util::Resolution.exec('arp -an')
+ if not arp_table.nil?
+ arp_table.each_line do |line|
+ is_amazon_arp = true if line.include?('fe:ff:ff:ff:ff:ff')
+ break
+ end
end
end
is_amazon_arp
Something went wrong with that request. Please try again.