Permalink
Browse files

Add OpenStack Registry

Change-Id: Ief7abee95c84d2068ed22390fce8681cda2ed9a7
  • Loading branch information...
1 parent f8bb98a commit 72c1099c607dbc208a4fbf6994c690c055996401 @frodenas frodenas committed Jul 26, 2012
Showing with 1,075 additions and 0 deletions.
  1. +29 −0 openstack_registry/Gemfile
  2. +111 −0 openstack_registry/Gemfile.lock
  3. +3 −0 openstack_registry/README
  4. +50 −0 openstack_registry/Rakefile
  5. +41 −0 openstack_registry/bin/migrate
  6. +38 −0 openstack_registry/bin/openstack_registry
  7. +26 −0 openstack_registry/bosh_openstack_registry.gemspec
  8. +12 −0 openstack_registry/db/migrations/20120508004132_create_openstack_servers.rb
  9. +25 −0 openstack_registry/lib/openstack_registry.rb
  10. +67 −0 openstack_registry/lib/openstack_registry/api_controller.rb
  11. +81 −0 openstack_registry/lib/openstack_registry/config.rb
  12. +20 −0 openstack_registry/lib/openstack_registry/errors.rb
  13. +8 −0 openstack_registry/lib/openstack_registry/models.rb
  14. +12 −0 openstack_registry/lib/openstack_registry/models/openstack_server.rb
  15. +56 −0 openstack_registry/lib/openstack_registry/runner.rb
  16. +52 −0 openstack_registry/lib/openstack_registry/server_manager.rb
  17. +7 −0 openstack_registry/lib/openstack_registry/version.rb
  18. +24 −0 openstack_registry/lib/openstack_registry/yaml_helper.rb
  19. +18 −0 openstack_registry/spec/assets/sample_config.yml
  20. +114 −0 openstack_registry/spec/spec_helper.rb
  21. +74 −0 openstack_registry/spec/unit/api_controller_spec.rb
  22. +56 −0 openstack_registry/spec/unit/config_spec.rb
  23. +82 −0 openstack_registry/spec/unit/runner_spec.rb
  24. +69 −0 openstack_registry/spec/unit/server_manager_spec.rb
  25. BIN openstack_registry/vendor/cache/archive-tar-minitar-0.5.2.gem
  26. BIN openstack_registry/vendor/cache/builder-3.0.0.gem
  27. BIN openstack_registry/vendor/cache/ci_reporter-1.7.0.gem
  28. BIN openstack_registry/vendor/cache/columnize-0.3.6.gem
  29. BIN openstack_registry/vendor/cache/daemons-1.1.8.gem
  30. BIN openstack_registry/vendor/cache/diff-lcs-1.1.3.gem
  31. BIN openstack_registry/vendor/cache/eventmachine-0.12.10.gem
  32. BIN openstack_registry/vendor/cache/excon-0.14.1.gem
  33. BIN openstack_registry/vendor/cache/fog-1.4.0.gem
  34. BIN openstack_registry/vendor/cache/formatador-0.2.3.gem
  35. BIN openstack_registry/vendor/cache/linecache19-0.5.12.gem
  36. BIN openstack_registry/vendor/cache/mime-types-1.19.gem
  37. BIN openstack_registry/vendor/cache/multi_json-1.3.4.gem
  38. BIN openstack_registry/vendor/cache/net-scp-1.0.4.gem
  39. BIN openstack_registry/vendor/cache/net-ssh-2.5.2.gem
  40. BIN openstack_registry/vendor/cache/nokogiri-1.5.5.gem
  41. BIN openstack_registry/vendor/cache/pg-0.13.2.gem
  42. BIN openstack_registry/vendor/cache/rack-1.4.1.gem
  43. BIN openstack_registry/vendor/cache/rack-protection-1.2.0.gem
  44. BIN openstack_registry/vendor/cache/rack-test-0.6.1.gem
  45. BIN openstack_registry/vendor/cache/rake-0.9.2.2.gem
  46. BIN openstack_registry/vendor/cache/rspec-2.10.0.gem
  47. BIN openstack_registry/vendor/cache/rspec-core-2.10.0.gem
  48. BIN openstack_registry/vendor/cache/rspec-expectations-2.10.0.gem
  49. BIN openstack_registry/vendor/cache/rspec-mocks-2.10.1.gem
  50. BIN openstack_registry/vendor/cache/ruby-debug-base19-0.11.25.gem
  51. BIN openstack_registry/vendor/cache/ruby-debug19-0.11.6.gem
  52. BIN openstack_registry/vendor/cache/ruby-hmac-0.4.0.gem
  53. BIN openstack_registry/vendor/cache/ruby_core_source-0.1.5.gem
  54. BIN openstack_registry/vendor/cache/sequel-3.36.1.gem
  55. BIN openstack_registry/vendor/cache/simplecov-0.6.2.gem
  56. BIN openstack_registry/vendor/cache/simplecov-html-0.5.3.gem
  57. BIN openstack_registry/vendor/cache/simplecov-rcov-0.2.3.gem
  58. BIN openstack_registry/vendor/cache/sinatra-1.3.2.gem
  59. BIN openstack_registry/vendor/cache/sqlite3-1.3.6.gem
  60. BIN openstack_registry/vendor/cache/thin-1.3.1.gem
  61. BIN openstack_registry/vendor/cache/tilt-1.3.3.gem
  62. BIN openstack_registry/vendor/cache/yajl-ruby-1.1.0.gem
View
@@ -0,0 +1,29 @@
+# Copyright (c) 2009-2012 VMware, Inc.
+
+source :rubygems
+gemspec
+
+gem "rake"
+
+group :production do
+ gem "pg"
+end
+
+group :development do
+ gem "ruby-debug", :platforms => :ruby_18
+ gem "ruby-debug19", :platforms => :ruby_19
+end
+
+group :test, :development do
+ gem "rack-test"
+
+ gem "ci_reporter"
+ gem "rspec", "~>2.10"
+
+ gem "rcov", :platforms => :ruby_18
+
+ gem "simplecov", :platforms => :ruby_19
+ gem "simplecov-rcov", :platforms => :ruby_19
+
+ gem "sqlite3"
+end
@@ -0,0 +1,111 @@
+PATH
+ remote: .
+ specs:
+ bosh_openstack_registry (0.0.1)
+ fog (~> 1.4.0)
+ sequel
+ sinatra
+ thin
+ yajl-ruby
+
+GEM
+ remote: http://rubygems.org/
+ specs:
+ archive-tar-minitar (0.5.2)
+ builder (3.0.0)
+ ci_reporter (1.7.0)
+ builder (>= 2.1.2)
+ columnize (0.3.6)
+ daemons (1.1.8)
+ diff-lcs (1.1.3)
+ eventmachine (0.12.10)
+ excon (0.14.1)
+ fog (1.4.0)
+ builder
+ excon (~> 0.14.0)
+ formatador (~> 0.2.0)
+ mime-types
+ multi_json (~> 1.0)
+ net-scp (~> 1.0.4)
+ net-ssh (>= 2.1.3)
+ nokogiri (~> 1.5.0)
+ ruby-hmac
+ formatador (0.2.3)
+ linecache (0.46)
+ rbx-require-relative (> 0.0.4)
+ linecache19 (0.5.12)
+ ruby_core_source (>= 0.1.4)
+ mime-types (1.19)
+ multi_json (1.3.4)
+ net-scp (1.0.4)
+ net-ssh (>= 1.99.1)
+ net-ssh (2.5.2)
+ nokogiri (1.5.5)
+ pg (0.13.2)
+ rack (1.4.1)
+ rack-protection (1.2.0)
+ rack
+ rack-test (0.6.1)
+ rack (>= 1.0)
+ rake (0.9.2.2)
+ rbx-require-relative (0.0.9)
+ rcov (1.0.0)
+ rspec (2.10.0)
+ rspec-core (~> 2.10.0)
+ rspec-expectations (~> 2.10.0)
+ rspec-mocks (~> 2.10.0)
+ rspec-core (2.10.0)
+ rspec-expectations (2.10.0)
+ diff-lcs (~> 1.1.3)
+ rspec-mocks (2.10.1)
+ ruby-debug (0.10.4)
+ columnize (>= 0.1)
+ ruby-debug-base (~> 0.10.4.0)
+ ruby-debug-base (0.10.4)
+ linecache (>= 0.3)
+ ruby-debug-base19 (0.11.25)
+ columnize (>= 0.3.1)
+ linecache19 (>= 0.5.11)
+ ruby_core_source (>= 0.1.4)
+ ruby-debug19 (0.11.6)
+ columnize (>= 0.3.1)
+ linecache19 (>= 0.5.11)
+ ruby-debug-base19 (>= 0.11.19)
+ ruby-hmac (0.4.0)
+ ruby_core_source (0.1.5)
+ archive-tar-minitar (>= 0.5.2)
+ sequel (3.36.1)
+ simplecov (0.6.2)
+ multi_json (~> 1.3)
+ simplecov-html (~> 0.5.3)
+ simplecov-html (0.5.3)
+ simplecov-rcov (0.2.3)
+ simplecov (>= 0.4.1)
+ sinatra (1.3.2)
+ rack (~> 1.3, >= 1.3.6)
+ rack-protection (~> 1.2)
+ tilt (~> 1.3, >= 1.3.3)
+ sqlite3 (1.3.6)
+ thin (1.3.1)
+ daemons (>= 1.0.9)
+ eventmachine (>= 0.12.6)
+ rack (>= 1.0.0)
+ tilt (1.3.3)
+ yajl-ruby (1.1.0)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ bosh_openstack_registry!
+ ci_reporter
+ pg
+ rack-test
+ rake
+ rcov
+ rspec (~> 2.10)
+ ruby-debug
+ ruby-debug19
+ simplecov
+ simplecov-rcov
+ sqlite3
@@ -0,0 +1,3 @@
+# Copyright (c) 2009-2012 VMware, Inc.
+
+BOSH OpenStack Registry
@@ -0,0 +1,50 @@
+# Copyright (c) 2009-2012 VMware, Inc.
+
+$:.unshift(File.expand_path("../../rake", __FILE__))
+
+ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __FILE__)
+
+require "rubygems"
+require "bundler"
+Bundler.setup(:default, :test)
+
+require "rake"
+begin
+ require "rspec/core/rake_task"
+rescue LoadError
+end
+
+require "bundler_task"
+require "ci_task"
+
+gem_helper = Bundler::GemHelper.new(Dir.pwd)
+
+desc "Build OpenStack Registry gem into the pkg directory"
+task "build" do
+ gem_helper.build_gem
+end
+
+desc "Build and install OpenStack Registry into system gems"
+task "install" do
+ Rake::Task["bundler:install"].invoke
+ gem_helper.install_gem
+end
+
+BundlerTask.new
+
+if defined?(RSpec)
+ namespace :spec do
+ desc "Run Unit Tests"
+ rspec_task = RSpec::Core::RakeTask.new(:unit) do |t|
+ t.pattern = "spec/unit/**/*_spec.rb"
+ t.rspec_opts = %w(--format progress --colour)
+ end
+
+ CiTask.new do |task|
+ task.rspec_task = rspec_task
+ end
+ end
+
+ desc "Run tests"
+ task :spec => %w(spec:unit)
+end
@@ -0,0 +1,41 @@
+#!/usr/bin/env ruby
+
+ENV["BUNDLE_GEMFILE"] = File.expand_path("../../Gemfile", __FILE__)
+
+require "rubygems"
+require "bundler/setup"
+require "logger"
+require "sequel"
+
+$:.unshift(File.dirname(__FILE__) + "/../lib")
+
+require "openstack_registry"
+
+config_file = nil
+
+opts = OptionParser.new do |opts|
+ opts.on("-c", "--config FILE", "configuration file") do |opt|
+ config_file = opt
+ end
+end
+
+opts.parse!(ARGV.dup)
+
+if config_file.nil?
+ puts opts
+ exit 1
+end
+
+include Bosh::OpenstackRegistry::YamlHelper
+
+config = load_yaml_file(config_file)
+
+db = Bosh::OpenstackRegistry.connect_db(config["db"])
+migrations_dir = File.expand_path("../../db/migrations", __FILE__)
+
+options = {
+ :table => "openstack_registry_schema"
+}
+
+Sequel.extension :migration
+Sequel::TimestampMigrator.run(db, migrations_dir, options)
@@ -0,0 +1,38 @@
+#!/usr/bin/env ruby
+
+gemfile = File.expand_path("../../Gemfile", __FILE__)
+
+if File.exists?(gemfile)
+ ENV["BUNDLE_GEMFILE"] = gemfile
+ require "rubygems"
+ require "bundler/setup"
+end
+
+$:.unshift(File.expand_path("../../lib", __FILE__))
+
+require "openstack_registry"
+require "optparse"
+
+config_file = nil
+
+opts = OptionParser.new do |opts|
+ opts.on("-c", "--config FILE", "configuration file") do |opt|
+ config_file = opt
+ end
+end
+
+opts.parse!(ARGV.dup)
+
+if config_file.nil?
+ puts opts
+ exit 1
+end
+
+runner = Bosh::OpenstackRegistry::Runner.new(config_file)
+
+Signal.trap("INT") do
+ runner.stop
+ exit(1)
+end
+
+runner.run
@@ -0,0 +1,26 @@
+# Copyright (c) 2009-2012 VMware, Inc.
+
+require File.dirname(__FILE__) + "/lib/openstack_registry/version"
+
+Gem::Specification.new do |s|
+ s.name = "bosh_openstack_registry"
+ s.version = Bosh::OpenstackRegistry::VERSION
+ s.platform = Gem::Platform::RUBY
+ s.summary = "BOSH OpenStack registry"
+ s.description = s.summary
+ s.author = "VMware"
+ s.email = "support@vmware.com"
+ s.homepage = "http://www.vmware.com"
+
+ s.files = `git ls-files -- bin/* lib/*`.split("\n") + %w(README Rakefile)
+ s.test_files = `git ls-files -- spec/*`.split("\n")
+ s.require_path = "lib"
+ s.bindir = "bin"
+ s.executables = %w(openstack_registry)
+
+ s.add_dependency "sequel"
+ s.add_dependency "sinatra"
+ s.add_dependency "thin"
+ s.add_dependency "yajl-ruby"
+ s.add_dependency "fog", "~>1.4.0"
+end
@@ -0,0 +1,12 @@
+# Copyright (c) 2009-2012 VMware, Inc.
+
+Sequel.migration do
+ change do
+ create_table :openstack_servers do
+ primary_key :id
+
+ String :server_id, :null => false, :unique => true
+ String :settings, :null => false, :text => true
+ end
+ end
+end
@@ -0,0 +1,25 @@
+# Copyright (c) 2009-2012 VMware, Inc.
+
+module Bosh
+ module OpenstackRegistry
+ autoload :Models, "openstack_registry/models"
+ end
+end
+
+require "fog"
+require "logger"
+require "sequel"
+require "sinatra/base"
+require "thin"
+require "yajl"
+
+require "openstack_registry/yaml_helper"
+
+require "openstack_registry/api_controller"
+require "openstack_registry/config"
+require "openstack_registry/errors"
+require "openstack_registry/server_manager"
+require "openstack_registry/runner"
+require "openstack_registry/version"
+
+Sequel::Model.plugin :validation_helpers
Oops, something went wrong.

0 comments on commit 72c1099

Please sign in to comment.