Class: Dcmgr::Endpoints::Metadata::Provider_20110519
- Inherits:
-
Provider_20101101
- Object
- Provider
- Provider_20101101
- Dcmgr::Endpoints::Metadata::Provider_20110519
- Defined in:
- lib/dcmgr/endpoints/metadata.rb
Overview
This version implements compatibility with amazon EC2
Instance Method Summary collapse
- #document(src_ip) ⇒ Object
- #instance_id(src_ip) ⇒ Object
- #local_hostname(src_ip) ⇒ Object
- #local_ipv4(src_ip) ⇒ Object
- #mac(src_ip) ⇒ Object
- #network(src_ip) ⇒ Object
- #public_ipv4(src_ip) ⇒ Object
- #public_keys(src_ip) ⇒ Object
- #security_groups(src_ip) ⇒ Object
- #user_data(src_ip) ⇒ Object
-
#wmi_id(src_ip) ⇒ Object
(also: #ami_id)
EC2 Functions not implemented yet 169.254.169.254/latest/meta-data/ami-launch-index 169.254.169.254/latest/meta-data/ami-manifest-path 169.254.169.254/latest/meta-data/ancestor-ami-ids 169.254.169.254/latest/meta-data/block-device-mapping 169.254.169.254/latest/meta-data/instance-type/instance-action 169.254.169.254/latest/meta-data/instance-type 169.254.169.254/latest/meta-data/kernel-id 169.254.169.254/latest/meta-data/placement/availability-zone 169.254.169.254/latest/meta-data/product-codes 169.254.169.254/latest/meta-data/placement 169.254.169.254/latest/meta-data/profile 169.254.169.254/latest/meta-data/public-hostname 169.254.169.254/latest/meta-data/ramdisk-id 169.254.169.254/latest/meta-data/reservation-id.
Methods inherited from Provider_20101101
Instance Method Details
#document(src_ip) ⇒ Object
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 |
# File 'lib/dcmgr/endpoints/metadata.rb', line 175 def document(src_ip) inst = get_instance_from_ip(src_ip) ret = { :instance_id=>inst.canonical_uuid, :cpu_cores=>inst.cpu_cores, :memory_size=>inst.memory_size, :state => inst.state, :user_data=>inst.user_data.to_s, } # IP/network values ret[:network] = inst.nic.map { |nic| nic.ip.map { |ip| {:ip=>ip.ipv4, :uuid=>ip.network.canonical_uuid, } } } ret[:volume] = inst.volume.map { |v| } ret end |
#instance_id(src_ip) ⇒ Object
231 232 233 |
# File 'lib/dcmgr/endpoints/metadata.rb', line 231 def instance_id(src_ip) get_instance_from_ip(src_ip).cuuid end |
#local_hostname(src_ip) ⇒ Object
235 236 237 |
# File 'lib/dcmgr/endpoints/metadata.rb', line 235 def local_hostname(src_ip) get_instance_from_ip(src_ip).hostname end |
#local_ipv4(src_ip) ⇒ Object
239 240 241 242 243 244 245 246 247 248 249 |
# File 'lib/dcmgr/endpoints/metadata.rb', line 239 def local_ipv4(src_ip) get_instance_from_ip(src_ip).nic.map { |nic| nic.ip.map { |ip| unless ip.is_natted? ip.ipv4 else nil end }.compact }.join("\n") end |
#mac(src_ip) ⇒ Object
217 218 219 220 221 |
# File 'lib/dcmgr/endpoints/metadata.rb', line 217 def mac(src_ip) get_instance_from_ip(src_ip).nic.map { |nic| nic.pretty_mac_addr }.join("\n") end |
#network(src_ip) ⇒ Object
223 224 225 226 227 228 229 |
# File 'lib/dcmgr/endpoints/metadata.rb', line 223 def network(src_ip) get_instance_from_ip(src_ip).nic.map { |nic| nic.ip.map { |ip| ip.network.cuuid } }.join("\n") end |
#public_ipv4(src_ip) ⇒ Object
251 252 253 254 255 256 257 258 259 260 261 |
# File 'lib/dcmgr/endpoints/metadata.rb', line 251 def public_ipv4(src_ip) get_instance_from_ip(src_ip).nic.map { |nic| nic.ip.map { |ip| if ip.is_natted? ip.ipv4 else nil end }.compact }.join("\n") end |
#public_keys(src_ip) ⇒ Object
263 264 265 266 267 |
# File 'lib/dcmgr/endpoints/metadata.rb', line 263 def public_keys(src_ip) i = get_instance_from_ip(src_ip) # ssh_key_data is possible to be nil. i.ssh_key_data.nil? ? '' : i.ssh_key_data[:public_key] end |
#security_groups(src_ip) ⇒ Object
269 270 271 272 273 |
# File 'lib/dcmgr/endpoints/metadata.rb', line 269 def security_groups(src_ip) get_instance_from_ip(src_ip).security_groups.map { |grp| grp.canonical_uuid }.join("\n") end |
#user_data(src_ip) ⇒ Object
275 276 277 |
# File 'lib/dcmgr/endpoints/metadata.rb', line 275 def user_data(src_ip) get_instance_from_ip(src_ip).user_data end |
#wmi_id(src_ip) ⇒ Object Also known as: ami_id
EC2 Functions not implemented yet 169.254.169.254/latest/meta-data/ami-launch-index 169.254.169.254/latest/meta-data/ami-manifest-path 169.254.169.254/latest/meta-data/ancestor-ami-ids 169.254.169.254/latest/meta-data/block-device-mapping 169.254.169.254/latest/meta-data/instance-type/instance-action 169.254.169.254/latest/meta-data/instance-type 169.254.169.254/latest/meta-data/kernel-id 169.254.169.254/latest/meta-data/placement/availability-zone 169.254.169.254/latest/meta-data/product-codes 169.254.169.254/latest/meta-data/placement 169.254.169.254/latest/meta-data/profile 169.254.169.254/latest/meta-data/public-hostname 169.254.169.254/latest/meta-data/ramdisk-id 169.254.169.254/latest/meta-data/reservation-id
212 213 214 |
# File 'lib/dcmgr/endpoints/metadata.rb', line 212 def wmi_id(src_ip) get_instance_from_ip(src_ip).image.cuuid end |