Module: Deployment::Methods::Helper

Defined in:
lib/depengine/dsl/helper.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.validates_not_empty(attribute, message = nil) ⇒ Object

Raises:

  • (ArgumentError)


78
79
80
# File 'lib/depengine/dsl/helper.rb', line 78

def validates_not_empty(attribute, message=nil)
  raise ArgumentError, message || "Parameter is empty", caller if attribute.nil?
end

.validates_presence_of(attribute, message = nil) ⇒ Object

Raises:

  • (ArgumentError)


73
74
75
# File 'lib/depengine/dsl/helper.rb', line 73

def validates_presence_of(attribute, message=nil)
  raise ArgumentError, message || "Missing parameter", caller if attribute.nil?
end

Instance Method Details

#assert_url_response_of(options = {}) ⇒ Object



16
17
18
19
20
21
22
23
24
25
# File 'lib/depengine/dsl/helper.rb', line 16

def assert_url_response_of(options={})
  asserter = ::Asserter::Url.new
  asserter.check_protocol  = options[:check_protocol] ||  @cdb['check_protocol'] || "http"
  asserter.check_host  = options[:check_host] || @cdb['check_host']
  asserter.check_port  = options[:check_port] || @cdb['check_port'] || '80'
  asserter.check_uri  = options[:check_uri] || @cdb['check_uri'] || '/'
  asserter.check_response_string  = options[:chek_response_string] || @cdb['check_response_string'] || 'html'

  asserter.assert_url_response_of(options)
end

#report_by_mail(options = {}) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
# File 'lib/depengine/dsl/helper.rb', line 34

def report_by_mail(options={})
  reporter = ::Reporter::Mail.new
  reporter.deploy_email_from  = options[:deploy_email_from] || @cdb['deploy_email_from']
  reporter.deploy_email_to  = options[:deploy_email_to] || @cdb['deploy_email_to']
  reporter.application_name  = options[:application_name] ||  $recipe_config[:application_name] || @cdb['application_name']
  reporter.module_name  = options[:module_name] ||  $recipe_config[:module_name] || @cdb['module_name']
  reporter.environment  =  $recipe_config['ENVIRONMENT']
  reporter.version  =  @version.to_json
  reporter.worker  = self
  reporter.send(options)
end

#report_to_cdb(options = {}) ⇒ Object



27
28
29
30
31
32
# File 'lib/depengine/dsl/helper.rb', line 27

def report_to_cdb(options={})
  reporter = ::Reporter::Cdb.new
  reporter.version  = @version.to_json
  reporter.worker  = self
  reporter.set_version(options)
end

#samba_mount(remote_path, local_path) ⇒ Object



60
61
62
63
64
65
# File 'lib/depengine/dsl/helper.rb', line 60

def samba_mount (remote_path, local_path)
  smb                   = ::Helper::Smb.new
  smb.remote_path       = remote_path
  smb.local_path        = local_path
  smb.samba_mount()
end

#samba_umount(local_path) ⇒ Object



67
68
69
70
71
# File 'lib/depengine/dsl/helper.rb', line 67

def samba_umount (local_path)
  smb                   = ::Helper::Smb.new
  smb.local_path        = local_path
  smb.samba_umount()
end

#sendmail(options) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/depengine/dsl/helper.rb', line 4

def sendmail(options)
  Helper.validates_presence_of options[:from],    "Mail-FROM not set"
  Helper.validates_presence_of options[:to],      "Mail-TO not set"
  Helper.validates_presence_of options[:subject], "No mail subject set"
  Helper.validates_presence_of options[:body],    "No mail body set"
  Helper.validates_presence_of @cdb['smtp_host'], "SMTP host not set"

  helper = ::Helper::Mail.new
  helper.smtp_host = @cdb['smtp_host']
  helper.sendmail(options)
end

#tomcat_deploy(options = {}) ⇒ Object



46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/depengine/dsl/helper.rb', line 46

def tomcat_deploy(options={})
  publisher = ::Publisher::Tomcat.new
  publisher.servers  = options[:servers] || @cdb['servers']
  publisher.runners = options[:runners] || @cdb['runners'] || publisher.servers
  publisher.initd_script  = options[:initd_script] || @cdb['initd_script']
  publisher.application_name  = options[:application_name] ||  $recipe_config[:application_name] || @cdb['application_name']
  publisher.catalina_home  = options[:catalina_home] || @cdb['catalina_home']
  publisher.tomcat_context  = options[:tomcat_context] || @cdb['tomcat_context']
  publisher.logfilename  = options[:logfilename] || @cdb['logfilename']
  publisher.check_host  = options[:check_host] || @cdb['check_host']
  publisher.worker  = self
  publisher.deploy(options)
end