Module: GCEMetadata::Command
- Defined in:
- lib/gce_metadata/command.rb
Constant Summary collapse
- DATA_KEY_ORDER =
%w(instance project)
- META_DATA_KEY_ORDER =
%w( attributes cpu-platform description disks hostname id image licenses machine-type maintenance-event network-interfaces scheduling service-accounts tags virtual-clock zone )
Class Method Summary collapse
Class Method Details
.show(api_version = 'v1') ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/gce_metadata/command.rb', line 30 def show(api_version = 'v1') timeout do v = (api_version || '').strip keys = GCEMetadata.instance.keys unless keys.include?(v.gsub(%r'([^/])$', '\1/')) puts("#{self.class.name}.instance.keys\n#{keys.ai}") raise ArgumentError, "API version must be one of #{GCEMetadata.instance.keys.inspect} but was #{api_version.inspect}" end show_yaml_path_if_loaded data = GCEMetadata.instance.to_hash data = data[v] data.extend(HashKeyOrderable) data.key_order = DATA_KEY_ORDER = data['instance'] .extend(HashKeyOrderable) .key_order = META_DATA_KEY_ORDER puts YAML.dump(data) end end |
.show_api_versions ⇒ Object
50 51 52 53 54 55 |
# File 'lib/gce_metadata/command.rb', line 50 def show_api_versions timeout do show_yaml_path_if_loaded puts GCEMetadata.instance.keys end end |
.show_dummy_yaml ⇒ Object
57 58 59 60 |
# File 'lib/gce_metadata/command.rb', line 57 def show_dummy_yaml show_yaml_path_if_loaded puts IO.read(File.(File.join(File.dirname(__FILE__), 'dummy.yml'))) end |