Class: Vagrant::Smartos::Zones::Util::PlatformImages
- Inherits:
-
Object
- Object
- Vagrant::Smartos::Zones::Util::PlatformImages
- Defined in:
- lib/vagrant/smartos/zones/util/platform_images.rb
Instance Attribute Summary collapse
-
#env ⇒ Object
readonly
Returns the value of attribute env.
-
#image ⇒ Object
readonly
Returns the value of attribute image.
-
#machine ⇒ Object
readonly
Returns the value of attribute machine.
Instance Method Summary collapse
- #get_platform_image(image) ⇒ Object
-
#initialize(env, machine = nil) ⇒ PlatformImages
constructor
A new instance of PlatformImages.
- #install(image) ⇒ Object
- #latest ⇒ Object
- #list ⇒ Object
Constructor Details
#initialize(env, machine = nil) ⇒ PlatformImages
Returns a new instance of PlatformImages.
12 13 14 15 16 |
# File 'lib/vagrant/smartos/zones/util/platform_images.rb', line 12 def initialize(env, machine = nil) @env = env @machine = machine setup_smartos_directories end |
Instance Attribute Details
#env ⇒ Object (readonly)
Returns the value of attribute env.
10 11 12 |
# File 'lib/vagrant/smartos/zones/util/platform_images.rb', line 10 def env @env end |
#image ⇒ Object (readonly)
Returns the value of attribute image.
10 11 12 |
# File 'lib/vagrant/smartos/zones/util/platform_images.rb', line 10 def image @image end |
#machine ⇒ Object (readonly)
Returns the value of attribute machine.
10 11 12 |
# File 'lib/vagrant/smartos/zones/util/platform_images.rb', line 10 def machine @machine end |
Instance Method Details
#get_platform_image(image) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/vagrant/smartos/zones/util/platform_images.rb', line 18 def get_platform_image(image) @image = image @image = latest_remote_or_current_image if image == 'latest' install(image) platform_image_path end |
#install(image) ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/vagrant/smartos/zones/util/platform_images.rb', line 25 def install(image) @image = image @image = latest_remote_or_current_image if image == 'latest' if ::File.exist?(platform_image_path) && valid? ui.info "SmartOS platform image #{image} exists" else download_checksum_file download_platform_image end end |
#latest ⇒ Object
40 41 42 43 44 45 |
# File 'lib/vagrant/smartos/zones/util/platform_images.rb', line 40 def latest latest_html = Vagrant::Smartos::Zones::Util::Downloader.new(platform_image_latest_url).read latest = latest_html.match(/(\d{8}T\d{6}Z)/) return unless latest latest[1] end |
#list ⇒ Object
36 37 38 |
# File 'lib/vagrant/smartos/zones/util/platform_images.rb', line 36 def list ui.info(images.join("\n"), prefix: false) end |