Class: BoxGrinder::BbcloudDeliveryPlugin
- Inherits:
-
BasePlugin
- Object
- BasePlugin
- BoxGrinder::BbcloudDeliveryPlugin
- Defined in:
- lib/delivery/bbcloud-delivery-plugin.rb
Instance Method Summary collapse
- #account ⇒ Object
- #appliance_name ⇒ Object
- #curl_command ⇒ Object
- #disk_image ⇒ Object
- #execute(type = :bbcloud) ⇒ Object
- #ftp_hash ⇒ Object
- #image_id ⇒ Object
- #register_image ⇒ Object
- #register_image_command ⇒ Object
- #target_name ⇒ Object
- #upload ⇒ Object
Instance Method Details
#account ⇒ Object
55 56 57 58 59 60 |
# File 'lib/delivery/bbcloud-delivery-plugin.rb', line 55 def account @account ||= @exec_helper.execute("brightbox-accounts -s list").split[0] rescue RuntimeError => e @log.error e. raise PluginValidationError, "Make sure the that brightbox cloud API tools are installed. Use 'brightbox-config client_add' to add the api client details for your account." end |
#appliance_name ⇒ Object
78 79 80 |
# File 'lib/delivery/bbcloud-delivery-plugin.rb', line 78 def appliance_name "#{@appliance_config.name}-#{@appliance_config.version}.#{@appliance_config.release}-#{@appliance_config.os.name}-#{@appliance_config.os.version}-#{current_platform}" end |
#curl_command ⇒ Object
74 75 76 |
# File 'lib/delivery/bbcloud-delivery-plugin.rb', line 74 def curl_command "curl -# -u #{ftp_hash['library_ftp_user']}:#{ftp_hash['library_ftp_password']} --ftp-ssl-control -T #{disk_image} ftp://#{ftp_hash['library_ftp_host']}/incoming/#{target_name}" end |
#disk_image ⇒ Object
62 63 64 |
# File 'lib/delivery/bbcloud-delivery-plugin.rb', line 62 def disk_image @previous_deliverables[:disk] end |
#execute(type = :bbcloud) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/delivery/bbcloud-delivery-plugin.rb', line 25 def execute( type = :bbcloud ) @log.info "Adding '#{@appliance_config.name}' appliance to Brightbox Cloud..." @log.info "Using Brightbox account id #{account}" upload register_image end |
#ftp_hash ⇒ Object
66 67 68 |
# File 'lib/delivery/bbcloud-delivery-plugin.rb', line 66 def ftp_hash @ftp_hash ||= Hash[*(@exec_helper.execute("brightbox-accounts -s reset_ftp_password #{account} 2>/dev/null").split)] end |
#image_id ⇒ Object
46 47 48 49 50 51 52 53 |
# File 'lib/delivery/bbcloud-delivery-plugin.rb', line 46 def image_id @image_id ||= if @exec_helper.execute(register_image_command) =~ /img-\w{5}/ Regexp.last_match[0] else raise "Failed to obtain an image id from the registration command" end end |
#register_image ⇒ Object
41 42 43 44 |
# File 'lib/delivery/bbcloud-delivery-plugin.rb', line 41 def register_image @log.info "Registering appliance as #{image_id} under account #{account} with the name '#{appliance_name}'" @log.info "Run 'brightbox-images show #{image_id}' to check registration progress" end |
#register_image_command ⇒ Object
82 83 84 |
# File 'lib/delivery/bbcloud-delivery-plugin.rb', line 82 def register_image_command "brightbox-images register -a #{@appliance_config.hardware.arch} -s #{target_name} -n '#{appliance_name}' -d '#{@appliance_config.summary}'" end |
#target_name ⇒ Object
70 71 72 |
# File 'lib/delivery/bbcloud-delivery-plugin.rb', line 70 def target_name File.basename(disk_image) end |
#upload ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/delivery/bbcloud-delivery-plugin.rb', line 32 def upload @log.info "Uploading to #{ftp_hash['library_ftp_host']} with secure FTP" if system curl_command @log.info "Appliance #{@appliance_config.name} uploaded." else raise "An error occurred while uploading files." end end |