deltacloud-core 0.1.2 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (158) hide show
  1. data/DISCLAIMER +8 -0
  2. data/{COPYING → LICENSE} +0 -0
  3. data/NOTICE +13 -0
  4. data/Rakefile +50 -51
  5. data/bin/deltacloudd +8 -1
  6. data/config.ru +0 -2
  7. data/config/drivers.yaml +48 -0
  8. data/deltacloud-core.gemspec +75 -0
  9. data/deltacloud.rb +3 -2
  10. data/lib/deltacloud/backend_capability.rb +15 -3
  11. data/lib/deltacloud/base_driver.rb +0 -2
  12. data/lib/deltacloud/base_driver/base_driver.rb +85 -89
  13. data/lib/deltacloud/base_driver/features.rb +61 -7
  14. data/lib/deltacloud/base_driver/mock_driver.rb +42 -43
  15. data/lib/deltacloud/core_ext.rb +18 -0
  16. data/lib/deltacloud/core_ext/integer.rb +31 -0
  17. data/lib/deltacloud/core_ext/string.rb +50 -0
  18. data/lib/deltacloud/drivers/azure/azure_driver.rb +71 -22
  19. data/lib/deltacloud/drivers/ec2/ec2_driver.rb +641 -584
  20. data/lib/deltacloud/drivers/ec2/ec2_mock_driver.rb +0 -2
  21. data/lib/deltacloud/drivers/eucalyptus/eucalyptus_driver.rb +167 -0
  22. data/lib/deltacloud/drivers/gogrid/gogrid_client.rb +39 -1
  23. data/lib/deltacloud/drivers/gogrid/gogrid_driver.rb +41 -25
  24. data/lib/deltacloud/drivers/mock/data/buckets/blobs/blob1.yml +6 -3
  25. data/lib/deltacloud/drivers/mock/data/buckets/blobs/blob2.yml +6 -3
  26. data/lib/deltacloud/drivers/mock/data/buckets/blobs/blob3.yml +4 -2
  27. data/lib/deltacloud/drivers/mock/data/buckets/blobs/blob4.yml +5 -2
  28. data/lib/deltacloud/drivers/mock/data/buckets/blobs/blob5.yml +4 -2
  29. data/lib/deltacloud/drivers/mock/data/instances/inst0.yml +1 -0
  30. data/lib/deltacloud/drivers/mock/data/instances/inst1.yml +1 -0
  31. data/lib/deltacloud/drivers/mock/data/instances/inst2.yml +1 -0
  32. data/lib/deltacloud/drivers/mock/data/storage_volumes/vol1.yml +1 -0
  33. data/lib/deltacloud/drivers/mock/data/storage_volumes/vol2.yml +1 -0
  34. data/lib/deltacloud/drivers/mock/data/storage_volumes/vol3.yml +1 -0
  35. data/lib/deltacloud/drivers/mock/mock_driver.rb +138 -30
  36. data/lib/deltacloud/drivers/opennebula/cloud_client.rb +13 -15
  37. data/lib/deltacloud/drivers/opennebula/occi_client.rb +13 -15
  38. data/lib/deltacloud/drivers/opennebula/opennebula_driver.rb +13 -15
  39. data/lib/deltacloud/drivers/rackspace/rackspace_driver.rb +224 -113
  40. data/lib/deltacloud/drivers/rhevm/rhevm_client.rb +332 -0
  41. data/lib/deltacloud/drivers/rhevm/rhevm_driver.rb +221 -170
  42. data/lib/deltacloud/drivers/rimuhosting/rimuhosting_driver.rb +0 -1
  43. data/lib/deltacloud/drivers/sbc/sbc_client.rb +247 -0
  44. data/lib/deltacloud/drivers/sbc/sbc_driver.rb +297 -0
  45. data/lib/deltacloud/drivers/terremark/terremark_driver.rb +0 -2
  46. data/lib/deltacloud/hardware_profile.rb +1 -3
  47. data/lib/deltacloud/helpers.rb +0 -2
  48. data/lib/deltacloud/helpers/application_helper.rb +86 -12
  49. data/lib/deltacloud/helpers/blob_stream.rb +19 -2
  50. data/lib/deltacloud/helpers/conversion_helper.rb +0 -2
  51. data/lib/deltacloud/helpers/hardware_profiles_helper.rb +0 -2
  52. data/lib/deltacloud/method_serializer.rb +0 -2
  53. data/lib/deltacloud/models/base_model.rb +0 -2
  54. data/lib/deltacloud/models/blob.rb +1 -2
  55. data/lib/deltacloud/models/bucket.rb +0 -2
  56. data/lib/deltacloud/models/image.rb +0 -2
  57. data/lib/deltacloud/models/instance.rb +19 -2
  58. data/lib/deltacloud/models/instance_profile.rb +4 -2
  59. data/lib/deltacloud/models/key.rb +0 -2
  60. data/lib/deltacloud/models/load_balancer.rb +0 -2
  61. data/lib/deltacloud/models/realm.rb +0 -2
  62. data/lib/deltacloud/models/storage_snapshot.rb +0 -2
  63. data/lib/deltacloud/models/storage_volume.rb +4 -2
  64. data/lib/deltacloud/runner.rb +132 -0
  65. data/lib/deltacloud/state_machine.rb +0 -2
  66. data/lib/deltacloud/validation.rb +9 -7
  67. data/lib/drivers.rb +36 -48
  68. data/lib/sinatra/accept_media_types.rb +26 -0
  69. data/lib/sinatra/lazy_auth.rb +16 -0
  70. data/lib/sinatra/rabbit.rb +112 -54
  71. data/lib/sinatra/rack_driver_select.rb +50 -16
  72. data/lib/sinatra/rack_etag.rb +79 -0
  73. data/lib/sinatra/rack_matrix_params.rb +84 -0
  74. data/lib/sinatra/rack_runtime.rb +47 -0
  75. data/lib/sinatra/static_assets.rb +16 -0
  76. data/lib/sinatra/url_for.rb +31 -4
  77. data/public/favicon.ico +0 -0
  78. data/public/images/bread-bg.png +0 -0
  79. data/public/images/error.png +0 -0
  80. data/public/images/pending.png +0 -0
  81. data/public/images/running.png +0 -0
  82. data/public/images/stopped.png +0 -0
  83. data/public/javascripts/application.js +35 -0
  84. data/public/stylesheets/compiled/application.css +59 -5
  85. data/public/stylesheets/compiled/screen.css +1 -1
  86. data/server.rb +293 -29
  87. data/support/fedora/deltacloud-core +78 -0
  88. data/support/fedora/deltacloud-core.spec +143 -0
  89. data/support/fedora/deltacloudd +78 -18
  90. data/support/fedora/rubygem-deltacloud-core.spec +76 -40
  91. data/tests/common.rb +172 -0
  92. data/tests/drivers/mock/api_test.rb +133 -0
  93. data/tests/drivers/mock/hardware_profiles_test.rb +134 -0
  94. data/tests/drivers/mock/images_test.rb +126 -0
  95. data/tests/drivers/mock/instance_states_test.rb +71 -0
  96. data/tests/drivers/mock/instances_test.rb +236 -0
  97. data/tests/drivers/mock/realms_test.rb +93 -0
  98. data/tests/drivers/mock/setup.rb +3 -0
  99. data/tests/drivers/mock/url_for_test.rb +67 -0
  100. data/tests/drivers/rackspace/api_test.rb +41 -0
  101. data/tests/drivers/rackspace/hardware_profiles_test.rb +53 -0
  102. data/tests/drivers/rackspace/images_test.rb +40 -0
  103. data/tests/drivers/rackspace/instances_test.rb +161 -0
  104. data/tests/drivers/rackspace/realms_test.rb +36 -0
  105. data/tests/drivers/rackspace/setup.rb +14 -0
  106. data/tests/drivers/rhevm/api_test.rb +39 -0
  107. data/tests/drivers/rhevm/hardware_profiles_test.rb +53 -0
  108. data/tests/drivers/rhevm/images_test.rb +42 -0
  109. data/tests/drivers/rhevm/instances_test.rb +179 -0
  110. data/tests/drivers/rhevm/realms_test.rb +35 -0
  111. data/tests/drivers/rhevm/setup.rb +14 -0
  112. data/tests/rabbit_test.rb +52 -0
  113. data/views/api/show.html.haml +2 -5
  114. data/views/blobs/new.html.haml +17 -1
  115. data/views/blobs/show.html.haml +6 -0
  116. data/views/blobs/show.xml.haml +5 -1
  117. data/views/buckets/index.html.haml +1 -12
  118. data/views/buckets/index.xml.haml +3 -5
  119. data/views/docs/operation.html.haml +23 -11
  120. data/views/drivers/index.html.haml +15 -0
  121. data/views/drivers/index.xml.haml +7 -0
  122. data/views/drivers/show.html.haml +20 -0
  123. data/views/drivers/show.xml.haml +7 -0
  124. data/views/error.html.haml +31 -0
  125. data/views/errors/auth_exception.xml.haml +2 -1
  126. data/views/errors/backend_capability_failure.xml.haml +2 -1
  127. data/views/errors/backend_error.html.haml +3 -0
  128. data/views/errors/backend_error.xml.haml +2 -2
  129. data/views/errors/validation_failure.xml.haml +3 -2
  130. data/views/images/index.html.haml +1 -6
  131. data/views/images/index.xml.haml +2 -0
  132. data/views/images/new.html.haml +14 -0
  133. data/views/images/show.xml.haml +2 -0
  134. data/views/instances/index.html.haml +8 -6
  135. data/views/instances/index.xml.haml +4 -0
  136. data/views/instances/new.html.haml +40 -11
  137. data/views/instances/run.html.haml +9 -0
  138. data/views/instances/run.xml.haml +7 -0
  139. data/views/instances/run_command.html.haml +16 -0
  140. data/views/instances/show.html.haml +14 -0
  141. data/views/instances/show.xml.haml +12 -4
  142. data/views/layout.html.haml +7 -2
  143. data/views/load_balancers/index.html.haml +1 -1
  144. data/views/load_balancers/new.html.haml +2 -2
  145. data/views/load_balancers/show.html.haml +1 -1
  146. data/views/storage_snapshots/index.html.haml +3 -0
  147. data/views/storage_snapshots/new.html.haml +9 -0
  148. data/views/storage_volumes/attach.html.haml +20 -0
  149. data/views/storage_volumes/index.html.haml +16 -1
  150. data/views/storage_volumes/index.xml.haml +1 -10
  151. data/views/storage_volumes/new.html.haml +17 -0
  152. data/views/storage_volumes/show.html.haml +8 -0
  153. data/views/storage_volumes/show.xml.haml +25 -3
  154. metadata +197 -127
  155. data/lib/deltacloud/drivers/rackspace/rackspace_client.rb +0 -130
  156. data/parse.rb +0 -7
  157. data/test.rb +0 -3
  158. data/views/api/drivers.xml.haml +0 -6
@@ -0,0 +1,78 @@
1
+ #!/bin/bash
2
+ #
3
+ #
4
+ # deltacloud-core startup script for deltacloud-core server
5
+ #
6
+ # chkconfig: - 97 03
7
+ # description: deltacloud-core is primary server process for the \
8
+ # Deltacloud Core component.
9
+ #
10
+
11
+ [ -r /etc/sysconfig/deltacloud-core ] && . /etc/sysconfig/deltacloud-core
12
+
13
+ ENV="${ENV:-production}"
14
+ DRIVER="${DRIVER:-ec2}"
15
+ PORT="${PORT:-3002}"
16
+ LOCKFILE="${LOCKFILE:-/var/lock/subsys/deltacloud-core }"
17
+ LOGFILE="${LOGFILE:-/var/log/deltacloud-core/$DRIVER.log}"
18
+
19
+ [ ! -d /var/log/deltacloud-core ] && mkdir -p /var/log/deltacloud-core
20
+
21
+ PROG=/usr/bin/deltacloudd
22
+
23
+ . /etc/init.d/functions
24
+
25
+ start() {
26
+ echo -n "Starting deltacloud-core: "
27
+
28
+ $PROG -i $DRIVER -e $ENV -p $PORT >> $LOGFILE 2>&1 &
29
+ RETVAL=$?
30
+ if [ $RETVAL -eq 0 ] && touch $LOCKFILE ; then
31
+ echo_success
32
+ echo
33
+ else
34
+ echo_failure
35
+ echo
36
+ fi
37
+ }
38
+
39
+ stop() {
40
+ echo -n "Shutting down deltacloud-core: "
41
+ RETVAL=$?
42
+ killall deltacloudd
43
+ if [ $RETVAL -eq 0 ] && rm -f $LOCKFILE ; then
44
+ echo_success
45
+ echo
46
+ else
47
+ echo_failure
48
+ echo
49
+ fi
50
+ }
51
+
52
+ case "$1" in
53
+ start)
54
+ start
55
+ ;;
56
+ stop)
57
+ stop
58
+ ;;
59
+ restart)
60
+ stop
61
+ start
62
+ ;;
63
+ reload)
64
+ ;;
65
+ force-reload)
66
+ restart
67
+ ;;
68
+ status)
69
+ status $PROG
70
+ RETVAL=$?
71
+ ;;
72
+ *)
73
+ echo "Usage: deltacloud-core {start|stop|restart|status}"
74
+ exit 1
75
+ ;;
76
+ esac
77
+
78
+ exit $RETVAL
@@ -0,0 +1,143 @@
1
+ %global ruby_sitelib %(ruby -rrbconfig -e "puts Config::CONFIG['sitelibdir']")
2
+ %global gemdir %(ruby -rubygems -e 'puts Gem::dir' 2>/dev/null)
3
+ %global geminstdir %{gemdir}/gems/deltacloud-core-%{version}
4
+
5
+ Summary: Deltacloud REST API
6
+ Name: deltacloud-core
7
+ Version: 0.3.0
8
+ Release: 1%{?dist}
9
+ Group: Development/Languages
10
+ License: ASL 2.0 and MIT
11
+ URL: http://incubator.apache.org/deltacloud
12
+ Source0: http://gems.rubyforge.org/gems/deltacloud-core-%{version}.gem
13
+ # Note: This would be needed only for EPEL branches:
14
+ BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
15
+ Requires: rubygems
16
+ Requires: ruby(abi) = 1.8
17
+ Requires: rubygem(haml)
18
+ Requires: rubygem(sinatra) >= 1.0
19
+ Requires: rubygem(rack) >= 1.1.0
20
+ Requires: rubygem(thin)
21
+ Requires: rubygem(haml)
22
+ Requires: rubygem(json) >= 1.4.0
23
+ Requires: rubygem(net-ssh) >= 2.0.0
24
+ Requires: rubygem(rack-accept)
25
+ Requires(post): chkconfig
26
+ Requires(preun): chkconfig
27
+ Requires(preun): initscripts
28
+ Requires(postun): initscripts
29
+ BuildRequires: rubygems
30
+ BuildRequires: ruby(abi) = 1.8
31
+ BuildRequires: rubygem(sinatra) >= 1.0
32
+ BuildRequires: rubygem(haml)
33
+ BuildRequires: rubygem(rack) >= 1.1.0
34
+ BuildRequires: rubygem(nokogiri) >= 1.4.3
35
+ BuildRequires: rubygem(net-ssh) >= 2.0.0
36
+ BuildRequires: rubygem(rack-accept)
37
+ BuildRequires: rubygem(json) >= 1.4.0
38
+ BuildRequires: rubygem(rake) >= 0.8.7
39
+ BuildRequires: rubygem(rack-test) >= 0.5.0
40
+ BuildRequires: rubygem(rspec) >= 1.3.0
41
+ BuildArch: noarch
42
+ Provides: deltacloud-core = %{version}
43
+
44
+ %description
45
+ The Deltacloud API is built as a service-based REST API.
46
+ You do not directly link a Deltacloud library into your program to use it.
47
+ Instead, a client speaks the Deltacloud API over HTTP to a server
48
+ which implements the REST interface.
49
+
50
+ %package doc
51
+ Summary: Documentation for %{name}
52
+ Group: Documentation
53
+ Requires:%{name} = %{version}-%{release}
54
+
55
+ %description doc
56
+ Documentation for %{name}
57
+
58
+ %prep
59
+
60
+ %build
61
+
62
+ %install
63
+ rm -rf %{buildroot}
64
+ mkdir -p %{buildroot}%{gemdir}
65
+ mkdir -p %{buildroot}%{_initddir}
66
+ gem install --local --install-dir %{buildroot}%{gemdir} \
67
+ --force --rdoc %{SOURCE0}
68
+ mkdir -p %{buildroot}/%{_bindir}
69
+ mkdir -p %{buildroot}/config
70
+ mv %{buildroot}%{gemdir}/bin/* %{buildroot}/%{_bindir}
71
+ mv %{buildroot}%{geminstdir}/support/fedora/deltacloud-core %{buildroot}%{_initddir}
72
+ mv -f %{buildroot}%{geminstdir}/support/fedora/deltacloudd %{buildroot}%{geminstdir}/bin
73
+ rmdir %{buildroot}%{gemdir}/bin
74
+ find %{buildroot}%{geminstdir}/bin -type f | xargs chmod 755
75
+ find %{buildroot}%{geminstdir}/lib -type f | xargs chmod -x
76
+ chmod 755 %{buildroot}%{_initddir}/deltacloud-core
77
+
78
+ %check
79
+ pushd %{buildroot}%{geminstdir}
80
+ rake test:mock
81
+ popd
82
+
83
+ %clean
84
+ rm -rf %{buildroot}
85
+
86
+ %post
87
+ # This adds the proper /etc/rc*.d links for the script
88
+ /sbin/chkconfig --add deltacloud-core
89
+
90
+ %preun
91
+ if [ $1 -eq 0 ] ; then
92
+ /sbin/service deltacloud-core stop >/dev/null 2>&1
93
+ /sbin/chkconfig --del deltacloud-core
94
+ fi
95
+
96
+ %postun
97
+ if [ "$1" -ge "1" ] ; then
98
+ /sbin/service deltacloud-core condrestart >/dev/null 2>&1 || :
99
+ fi
100
+
101
+ %files
102
+ %defattr(-, root, root, -)
103
+ %{_initddir}/deltacloud-core
104
+ %{_bindir}/deltacloudd
105
+ %dir %{geminstdir}/
106
+ %{geminstdir}/bin
107
+ %{geminstdir}/LICENSE
108
+ %{geminstdir}/DISCLAIMER
109
+ %{geminstdir}/NOTICE
110
+ %{geminstdir}/config.ru
111
+ %{geminstdir}/*.rb
112
+ %{geminstdir}/Rakefile
113
+ %{geminstdir}/views
114
+ %{geminstdir}/lib
115
+ %{geminstdir}/public/images
116
+ %{geminstdir}/public/stylesheets
117
+ %{geminstdir}/public/favicon.ico
118
+ %{gemdir}/cache/deltacloud-core-%{version}.gem
119
+ %{gemdir}/specifications/deltacloud-core-%{version}.gemspec
120
+ %{geminstdir}/config/drivers.yaml
121
+ # MIT
122
+ %{gemdir}/gems/deltacloud-core-%{version}/public/javascripts
123
+
124
+ %files doc
125
+ %defattr(-, root, root, -)
126
+ %{gemdir}/doc/deltacloud-core-%{version}
127
+ %{geminstdir}/tests
128
+ %{geminstdir}/support
129
+ %{geminstdir}/deltacloud-core.gemspec
130
+
131
+ %changelog
132
+ * Fri Apr 8 2011 David Lutterkort <lutter@redhat.com> - 0.3.0-1
133
+ - Renamed COPYING to LICENSE, include NOTICE and DISCLAIMER
134
+
135
+ * Fri Feb 04 2011 Michal Fojtik <mfojtik@redhat.com> - 0.2.0-2
136
+ - Package renamed to deltacloud-core, since it's not library and it's providing
137
+ full REST API server with init script.
138
+ - Fixed dependency issues
139
+ - Removed bundled gems and RPMs
140
+ - Fixed path in pushd inside tests section
141
+
142
+ * Mon Jan 31 2011 Michal Fojtik <mfojtik@redhat.com> - 0.2.0-1
143
+ - Initial package
@@ -2,10 +2,21 @@
2
2
 
3
3
  require 'rubygems'
4
4
  require 'optparse'
5
- require 'thin'
5
+
6
+ # See if we can require +name+ and return +true+ if the library is there,
7
+ # +false+ otherwise. Note that, as a side effect, the library will be
8
+ # loaded
9
+ def library_present?(name)
10
+ begin
11
+ require name
12
+ true
13
+ rescue LoadError
14
+ false
15
+ end
16
+ end
6
17
 
7
18
  options = {
8
- :env => 'production'
19
+ :env => 'development'
9
20
  }
10
21
  optparse = OptionParser.new do |opts|
11
22
 
@@ -25,6 +36,9 @@ BANNER
25
36
  opts.on( '-p', '--port PORT', 'Use PORT (default: 3001)') do |port|
26
37
  ENV["API_PORT"] = port
27
38
  end
39
+ opts.on( '-P', '--provider PROVIDER', 'Use PROVIDER (default is set in the driver)') do |provider|
40
+ ENV['API_PROVIDER'] = provider
41
+ end
28
42
  opts.on( '-e', '--env ENV', 'Environment (default: "development")') { |env| options[:env] = env }
29
43
  opts.on( '-h', '--help', '') { options[:help] = true }
30
44
  end
@@ -44,25 +58,71 @@ end
44
58
  ENV["API_HOST"] = "localhost" unless ENV["API_HOST"]
45
59
  ENV["API_PORT"] = "3001" unless ENV["API_PORT"]
46
60
 
61
+ msg = "Starting Deltacloud API :: #{ENV["API_DRIVER"]} "
62
+ msg << ":: #{ENV['API_PROVIDER']} " if ENV['API_PROVIDER']
63
+ msg << ":: http://#{ENV["API_HOST"]}:#{ENV["API_PORT"]}/api"
64
+ puts msg
65
+ puts
66
+
47
67
  dirname="#{File.dirname(__FILE__)}/.."
48
68
 
49
- argv_opts = ARGV.clone
50
- argv_opts << ['start'] unless Thin::Runner.commands.include?(options[0])
51
- argv_opts << ['--address', ENV["API_HOST"] ]
52
- argv_opts << ['--port', ENV["API_PORT"] ]
53
- argv_opts << ['--rackup', 'config.ru' ]
54
- argv_opts << ['--chdir', dirname ]
55
- argv_opts << ['-e', options[:env] ]
56
- argv_opts << ['--threaded', '-D', '--stats', '/stats']
69
+ have_thin = library_present?('thin')
70
+ have_rerun = library_present?('rerun')
57
71
 
58
- argv_opts.flatten!
72
+ unless have_thin
73
+ require 'rack'
59
74
 
60
- puts "Starting Deltacloud API :: #{ENV["API_DRIVER"]} :: http://#{ENV["API_HOST"]}:#{ENV["API_PORT"]}/api"
61
- puts
75
+ # We can't chdir with webrick so add our root directory
76
+ # onto the load path
77
+ $: << dirname
62
78
 
63
- thin = Thin::Runner.new(argv_opts)
64
- begin
65
- thin.run!
66
- rescue Exception => e
67
- puts "ERROR: #{e.message}"
79
+ # Read in config.ru and convert it to an instance of Rack::Builder
80
+ cfgfile = File.read(File.join(dirname, 'config.ru'))
81
+ inner_app = eval("Rack::Builder.new {(" + cfgfile + "\n )}.to_app",
82
+ nil, 'config.ru')
83
+
84
+ app = Rack::Builder.new {
85
+ use Rack::CommonLogger # apache-like logging
86
+ use Rack::Reloader if options[:env] == "development"
87
+ set :root, dirname # Set Sinatra root since we can't chdir to ../
88
+ run inner_app
89
+ }.to_app
90
+
91
+ # There's a bug with string ports on JRuby so convert to int
92
+ # http://jira.codehaus.org/browse/JRUBY-4868
93
+ port = ENV["API_PORT"].to_i
94
+
95
+ puts "=> Ctrl-C to shutdown server"
96
+ Rack::Handler::WEBrick.run(app,
97
+ :Host => ENV["API_HOST"],
98
+ :Port => port,
99
+ :AccessLog => [])
100
+ else
101
+ argv_opts = ARGV.clone
102
+ argv_opts << ['start'] unless Thin::Runner.commands.include?(options[0])
103
+ argv_opts << ['--address', ENV["API_HOST"] ]
104
+ argv_opts << ['--port', ENV["API_PORT"] ]
105
+ argv_opts << ['--rackup', 'config.ru' ]
106
+ argv_opts << ['--chdir', dirname ]
107
+ argv_opts << ['-e', options[:env] ]
108
+ argv_opts << ['--threaded', '-D', '--stats', '/stats']
109
+
110
+ argv_opts.flatten!
111
+
112
+ if have_rerun && options[:env] == "development"
113
+ argv_opts.unshift "thin"
114
+ command = argv_opts.join(" ")
115
+ topdir = File::expand_path(File::join(File::dirname(__FILE__), ".."))
116
+ rerun = Rerun::Runner.new(command, :dir => topdir)
117
+ rerun.start
118
+ rerun.join
119
+ else
120
+ thin = Thin::Runner.new(argv_opts)
121
+
122
+ begin
123
+ thin.run!
124
+ rescue Exception => e
125
+ puts "ERROR: #{e.message}"
126
+ end
127
+ end
68
128
  end
@@ -5,29 +5,30 @@
5
5
 
6
6
  Summary: Deltacloud REST API
7
7
  Name: rubygem-%{gemname}
8
- Version: 0.0.1
9
- Release: 2%{?dist}
8
+ Version: 0.3.0
9
+ Release: 1%{?dist}
10
10
  Group: Development/Languages
11
11
  License: ASL 2.0 and MIT
12
- URL: http://www.deltacloud.org
12
+ URL: http://incubator.apache.org/deltacloud
13
13
  Source0: http://gems.rubyforge.org/gems/%{gemname}-%{version}.gem
14
14
  BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
15
15
  Requires: rubygems
16
16
  Requires: ruby(abi) = 1.8
17
- Requires: rubygem(eventmachine) >= 0.12.10
18
- Requires: rubygem(haml) >= 2.2.17
19
- Requires: rubygem(sinatra) >= 0.9.4
20
- Requires: rubygem(rack) >= 1.0.0
21
- Requires: rubygem(thin) >= 1.2.5
22
- Requires: rubygem(builder) >= 2.1.2
23
- Requires: rubygem(json) >= 1.2.3
24
- BuildRequires: ruby-json >= 1.1.9
25
- BuildRequires: rubygem(rake) >= 0.8.7
26
- BuildRequires: rubygem(rack-test) >= 0.4.0
27
- BuildRequires: rubygem(cucumber) >= 0.4.0
28
- BuildRequires: rubygem(rcov) >= 0.9.6
17
+ Requires: rubygem(haml)
18
+ Requires: rubygem(sinatra) >= 1.0
19
+ Requires: rubygem(rack) >= 1.1.0
20
+ Requires: rubygem(thin)
21
+ Requires: rubygem(json) >= 1.4.0
22
+ Requires(post): chkconfig
23
+ Requires(preun): chkconfig
24
+ Requires(preun): initscripts
25
+ Requires(postun): initscripts
29
26
  BuildRequires: rubygems
30
27
  BuildRequires: ruby(abi) = 1.8
28
+ BuildRequires: rubygem(json) >= 1.4.0
29
+ BuildRequires: rubygem(rake) >= 0.8.7
30
+ BuildRequires: rubygem(rack-test) >= 0.5.0
31
+ BuildRequires: rubygem(rspec) >= 1.3.0
31
32
  BuildArch: noarch
32
33
  Provides: rubygem(%{gemname}) = %{version}
33
34
 
@@ -37,6 +38,14 @@ You do not directly link a Deltacloud library into your program to use it.
37
38
  Instead, a client speaks the Deltacloud API over HTTP to a server
38
39
  which implements the REST interface.
39
40
 
41
+ %package doc
42
+ Summary: Documentation for %{name}
43
+ Group: Documentation
44
+ Requires:%{name} = %{version}-%{release}
45
+
46
+ %description doc
47
+ Documentation for %{name}
48
+
40
49
  %prep
41
50
 
42
51
  %build
@@ -44,48 +53,75 @@ which implements the REST interface.
44
53
  %install
45
54
  rm -rf %{buildroot}
46
55
  mkdir -p %{buildroot}%{gemdir}
56
+ mkdir -p %{buildroot}%{_initddir}
47
57
  gem install --local --install-dir %{buildroot}%{gemdir} \
48
58
  --force --rdoc %{SOURCE0}
49
59
  mkdir -p %{buildroot}/%{_bindir}
50
- mv %{buildroot}%{geminstdir}/support/fedora/deltacloudd %{buildroot}/%{geminstdir}/bin
60
+ mkdir -p %{buildroot}/config
51
61
  mv %{buildroot}%{gemdir}/bin/* %{buildroot}/%{_bindir}
62
+ mv %{buildroot}%{geminstdir}/support/fedora/%{gemname} %{buildroot}%{_initddir}
63
+ mv -f %{buildroot}%{geminstdir}/support/fedora/deltacloudd %{buildroot}%{geminstdir}/bin
52
64
  rmdir %{buildroot}%{gemdir}/bin
53
- find %{buildroot}%{geminstdir}/bin -type f | xargs chmod a+x
65
+ find %{buildroot}%{geminstdir}/bin -type f | xargs chmod 755
66
+ find %{buildroot}%{geminstdir}/lib -type f | xargs chmod -x
67
+ chmod 755 %{buildroot}%{_initddir}/%{gemname}
54
68
 
55
- # Needs json_pure gem / not available in Fedora yet
56
- #%check
57
- #pushd %{buildroot}%{geminstdir}
58
- #cucumber features/*.feature
59
- #popd
69
+ %check
70
+ pushd %{geminstdir}
71
+ rake test:mock
72
+ popd
60
73
 
61
74
  %clean
62
75
  rm -rf %{buildroot}
63
76
 
77
+ %post
78
+ # This adds the proper /etc/rc*.d links for the script
79
+ /sbin/chkconfig --add %{gemname}
80
+
81
+ %preun
82
+ if [ $1 -eq 0 ] ; then
83
+ /sbin/service %{gemname} stop >/dev/null 2>&1
84
+ /sbin/chkconfig --del %{gemname}
85
+ fi
86
+
87
+ %postun
88
+ if [ "$1" -ge "1" ] ; then
89
+ /sbin/service %{gemname} condrestart >/dev/null 2>&1 || :
90
+ fi
91
+
64
92
  %files
65
93
  %defattr(-, root, root, -)
94
+ %{_initddir}/%{gemname}
66
95
  %{_bindir}/deltacloudd
67
- %{gemdir}/gems/%{gemname}-%{version}/bin
68
- %{gemdir}/gems/%{gemname}-%{version}/lib
69
- %{gemdir}/gems/%{gemname}-%{version}/public/favicon.ico
70
- %{gemdir}/gems/%{gemname}-%{version}/public/images
71
- %{gemdir}/gems/%{gemname}-%{version}/public/stylesheets
72
- %{gemdir}/gems/%{gemname}-%{version}/tests
73
- %{gemdir}/gems/%{gemname}-%{version}/views
74
- %{gemdir}/gems/%{gemname}-%{version}/Rakefile
75
- %{gemdir}/gems/%{gemname}-%{version}/*.rb
76
- %{gemdir}/gems/%{gemname}-%{version}/config.ru
77
- %doc %{gemdir}/gems/%{gemname}-%{version}/support/fedora
78
- %doc %{gemdir}/gems/%{gemname}-%{version}/COPYING
79
- %doc %{gemdir}/doc/%{gemname}-%{version}
96
+ %dir %{geminstdir}/
97
+ %{geminstdir}/bin
98
+ %{geminstdir}/LICENSE
99
+ %{geminstdir}/NOTICE
100
+ %{geminstdir}/DISCLAIMER
101
+ %{geminstdir}/config.ru
102
+ %{geminstdir}/*.rb
103
+ %{geminstdir}/Rakefile
104
+ %{geminstdir}/views
105
+ %{geminstdir}/lib
106
+ %{geminstdir}/public/images
107
+ %{geminstdir}/public/stylesheets
108
+ %{geminstdir}/public/favicon.ico
80
109
  %{gemdir}/cache/%{gemname}-%{version}.gem
81
110
  %{gemdir}/specifications/%{gemname}-%{version}.gemspec
111
+ %{geminstdir}/config/drivers.yaml
82
112
  # MIT
83
113
  %{gemdir}/gems/%{gemname}-%{version}/public/javascripts
84
114
 
115
+ %files doc
116
+ %defattr(-, root, root, -)
117
+ %{gemdir}/doc/%{gemname}-%{version}
118
+ %{geminstdir}/tests
119
+ %{geminstdir}/support
120
+ %{geminstdir}/%{gemname}.gemspec
121
+
85
122
  %changelog
86
- * Mon Apr 26 2010 Michal Fojtik <mfojtik@packager> - 0.0.1-1
87
- - Initial package
123
+ * Fri Apr 8 2011 David Lutterkort <lutter@redhat.com> - 0.3.0-1
124
+ - - Renamed COPYING to LICENSE, include NOTICE and DISCLAIMER
88
125
 
89
- * Mon Apr 26 2010 Michal Fojtik <mfojtik@packager> - 0.0.1-2
90
- - Fixed broken dependencies
91
- - Added new launcher for Fedora
126
+ * Mon Jan 31 2011 Michal Fojtik <mfojtik@redhat.com> - 0.2.0-1
127
+ - Initial package