tdl 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,6 +8,7 @@
8
8
  ###########################################################
9
9
 
10
10
  require 'cloud_inst'
11
+ require 'package_system'
11
12
 
12
13
  ###############################################################
13
14
  # Use various subsystems to process an etdl
@@ -28,54 +29,18 @@ class ETDLProcessor
28
29
 
29
30
  puts "using address #{inst.address}\nssh:#{inst.ssh}\nscp:#{inst.scp}".green
30
31
 
32
+ # TODO compare instance to etdl os
33
+
31
34
  inst
32
35
  end
33
36
 
34
37
  def process(etdl, instance)
35
- # TODO need to open firewall ports (we have to open them manually now)
36
-
37
- # set hostname
38
- hostname = etdl.instance_attributes[:hostname]
39
- unless hostname.nil?
40
- puts "Setting hostname to #{hostname}".green
41
- instance.exec "sudo hostname #{hostname}"
42
-
43
- # append hostname to /etc/hosts/
44
- etdl.instance_attributes[:files] <<
45
- {:name => '/etc/hosts', :append => true,
46
- :owner => 'root', :group => 'root', :mode => 644,
47
- :contents => "#{instance.address} #{hostname}"}
48
- end
38
+ # TODO setup repos
49
39
 
50
40
  # yum install packages
51
41
  packages = etdl.instance_attributes[:packages].join(" ")
52
42
  puts "installing #{packages}".green
53
- puts instance.exec("sudo yum install -y --nogpgcheck #{packages}").blue
54
-
55
- # start services
56
- services = etdl.instance_attributes[:services]
57
- services.each { |s|
58
- puts "starting/enabling service #{s[:name]}".green
59
- s[:pre].each { |cmd|
60
- puts " running precommand #{cmd}".green
61
- puts instance.exec("sudo #{cmd}").blue
62
- }
63
- puts instance.exec("sudo service #{s[:name]} start").blue
64
- puts instance.exec("sudo chkconfig --levels 35 #{s[:name]} on").blue
65
- s[:post].each { |cmd|
66
- puts " running postcommand #{cmd}".green
67
- puts instance.exec("sudo #{cmd}").blue
68
- }
69
- }
70
-
71
- # create dirs
72
- dirs = etdl.instance_attributes[:dirs]
73
- dirs.each { |d|
74
- puts "creating dir #{d[:name]}".green
75
- instance.exec("sudo rm -rf #{d[:name]}") if d[:remove]
76
- instance.exec("sudo mkdir -p #{d[:name]}")
77
- instance.exec("sudo chown #{d[:owner]}.#{d[:group]} #{d[:name]}")
78
- }
43
+ puts instance.exec(TDLTools::PackageSystem.install_pkg_cmd(packages)).blue
79
44
 
80
45
  # copy files over
81
46
  files = etdl.instance_attributes[:files]
@@ -85,19 +50,27 @@ class ETDLProcessor
85
50
  tf.close
86
51
 
87
52
  instance.cp tf.path, f[:name]
88
- instance.exec("sudo chown #{f[:owner]}.#{f[:group]} #{f[:name]}")
89
- instance.exec("sudo chmod #{f[:mode]} #{f[:name]}")
90
53
  }
91
54
 
92
55
  cmds = etdl.instance_attributes[:commands]
93
56
  cmds.each { |c|
94
- puts "running command #{c[:cmd]} as #{c[:user]}"
95
- puts instance.exec("sudo -u #{c[:user]} -i #{c[:cmd]}").blue
57
+ puts "running command #{c[:cmd]}"
58
+ puts instance.exec("#{c[:cmd]}").blue
96
59
  }
97
60
  end
98
61
 
99
62
  def verify(etdl, instance)
100
- # TODO
63
+ etdl.verify_cmds.each { |v|
64
+ puts "running verification #{v}"
65
+ output = instance.exec("#{v}")
66
+ if $?.to_i == 0
67
+ puts output.blue
68
+ puts " ...success!".blue
69
+ else
70
+ puts output.red
71
+ puts " ... #{v} failed".red
72
+ end
73
+ }
101
74
  end
102
75
 
103
76
  def terminate_instance(instance)
@@ -0,0 +1,20 @@
1
+ # tdl-tools package system representation
2
+ #
3
+ # Part of the Aeolus suite http://aeolusproject.org
4
+ # Licensed under the MIT license
5
+ # Copyright (C) 2013 Red Hat, Inc.
6
+ # Written By Mo Morsi <mmorsi@redhat.com>
7
+ #
8
+ ###########################################################
9
+
10
+ # TODO use libosinfo to pull os information
11
+ # support os's other than rpm based ones
12
+
13
+ module TDLTools
14
+ class PackageSystem
15
+ # return command to install the specified packages on the local system
16
+ def self.install_pkg_cmd(packages)
17
+ "sudo yum install -y --nogpgcheck #{packages}"
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,14 @@
1
+ # tdl-tools helper utility, return path to tdl-tools gem
2
+ #
3
+ # Part of the Aeolus suite http://aeolusproject.org
4
+ # Licensed under the MIT license
5
+ # Copyright (C) 2013 Red Hat, Inc.
6
+ # Written By Mo Morsi <mmorsi@redhat.com>
7
+ #
8
+ ###########################################################
9
+
10
+ module TDLTools
11
+ def self.gem_path
12
+ File.dirname(File.expand_path(__FILE__)) + "/../"
13
+ end
14
+ end
@@ -0,0 +1,47 @@
1
+ # type of cloud deploying instance/image to
2
+ type:
3
+
4
+ # for tdl-launch:
5
+ provider:
6
+ username:
7
+ password:
8
+ image:
9
+ keyname:
10
+ ssh_cmd:
11
+ scp_cmd:
12
+
13
+ # for imagefactory ec2
14
+ #account:
15
+ #access_key:
16
+ #secret_access_key:
17
+ #certificate:
18
+ #key:
19
+
20
+ # for imagefactory openstack
21
+ #username:
22
+ #tenant:
23
+ #password:
24
+ #strategy:
25
+ #auth_url:
26
+ #glance_host:
27
+ #glance_port:
28
+
29
+ # for imagefactory rhevm
30
+ #username:
31
+ #password:
32
+ #api_url:
33
+ #nfs_path:
34
+ #nfs_dir:
35
+ #nfs_host:
36
+ #cluster:
37
+ #timeout:
38
+
39
+ # for imagefactory vsphere
40
+ #username:
41
+ #password:
42
+ #api_url:
43
+ #username:
44
+ #password:
45
+ #datastore:
46
+ #compute_resource:
47
+ #network_name:
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tdl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-26 00:00:00.000000000 Z
12
+ date: 2013-03-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -30,6 +30,8 @@ dependencies:
30
30
  description: Aeolus Template Description Language Tools
31
31
  email: mmorsi@redhat.com
32
32
  executables:
33
+ - tdl-config.rb
34
+ - tdl-apply.rb
33
35
  - tdl-launch.rb
34
36
  - tdl-convert.rb
35
37
  - tdl-verify.rb
@@ -39,10 +41,19 @@ extra_rdoc_files: []
39
41
  files:
40
42
  - lib/etdl_processor.rb
41
43
  - lib/etdl.rb
44
+ - lib/tdl_gem_path.rb
42
45
  - lib/cloud_inst.rb
46
+ - lib/package_system.rb
47
+ - data/sample.etdl
48
+ - data/tdl.rng
49
+ - data/sample.tdl
50
+ - data/etdl.rng
43
51
  - LICENSE
44
52
  - Rakefile
45
53
  - README.md
54
+ - tdl-config.yml
55
+ - bin/tdl-config.rb
56
+ - bin/tdl-apply.rb
46
57
  - bin/tdl-launch.rb
47
58
  - bin/tdl-convert.rb
48
59
  - bin/tdl-verify.rb