Class: BoxGrinder::SFTPPlugin
- Inherits:
-
BasePlugin
show all
- Defined in:
- lib/boxgrinder-build/plugins/delivery/sftp/sftp-plugin.rb
Instance Attribute Summary
Attributes inherited from BasePlugin
#deliverables, #plugin_info
Instance Method Summary
collapse
Methods inherited from BasePlugin
#current_platform, #deliverables_exists?, #init, #initialize, #is_supported_os?, #is_supported_platform?, #merge_plugin_config, #read_plugin_config, #register_deliverable, #register_supported_os, #register_supported_platform, #run, #set_default_config_value, #subtype, #supported_oses, #validate_plugin_config
Methods included from Plugins
#plugin
Instance Method Details
#after_init ⇒ Object
42
43
44
|
# File 'lib/boxgrinder-build/plugins/delivery/sftp/sftp-plugin.rb', line 42
def after_init
register_deliverable(:package => "#{@appliance_config.name}-#{@appliance_config.version}.#{@appliance_config.release}-#{@appliance_config.os.name}-#{@appliance_config.os.version}-#{@appliance_config.hardware.arch}-#{current_platform}.tgz")
end
|
#execute ⇒ Object
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
# File 'lib/boxgrinder-build/plugins/delivery/sftp/sftp-plugin.rb', line 46
def execute
PackageHelper.new(@config, @appliance_config, :log => @log, :exec_helper => @exec_helper).package( File.dirname(@previous_deliverables[:disk]), @deliverables[:package] )
@log.info "Uploading #{@appliance_config.name} appliance via SSH..."
sftp_opts={}
sftp_opts.merge!(:password => @plugin_config['password']) if @plugin_config['password']
sftp_opts.merge!(:keys => @identity.to_a) if @identity
@sftp_helper.connect(@plugin_config['host'], @plugin_config['username'], sftp_opts)
@sftp_helper.upload_files(@plugin_config['path'], @plugin_config['default_permissions'], @plugin_config['overwrite'], File.basename(@deliverables[:package]) => @deliverables[:package])
@log.info "Appliance #{@appliance_config.name} uploaded."
rescue => e
@log.error e
@log.error "An error occurred while uploading files."
raise
ensure
@sftp_helper.disconnect
end
|
#validate ⇒ Object
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/boxgrinder-build/plugins/delivery/sftp/sftp-plugin.rb', line 31
def validate
set_default_config_value('overwrite', false)
set_default_config_value('default_permissions', 0644)
set_default_config_value('identity', false)
validate_plugin_config(['path', 'username', 'host'], 'http://boxgrinder.org/tutorials/boxgrinder-build-plugins/#SFTP_Delivery_Plugin')
@identity = (@plugin_config['identity'] || @plugin_config['i'])
@sftp_helper = SFTPHelper.new(:log => @log)
end
|