Permalink
Browse files

Solve merge conflicts

  • Loading branch information...
2 parents 28f2a71 + ec961dc commit 3592fd9687f78ee870684d385e1326a363a80771 @frodenas frodenas committed May 4, 2012
View
@@ -0,0 +1 @@
+*.swp
View
@@ -14,8 +14,8 @@ begin
rescue LoadError
end
-require "bundler_task"
-require "ci_task"
+require "../bosh/rake/bundler_task"
+require "../bosh/rake/ci_task"
gem_helper = Bundler::GemHelper.new(Dir.pwd)
@@ -62,10 +62,10 @@ def delete_stemcell(stemcell_id)
end
##
- # Creates OpenStack server and waits until it's in running state
+ # Creates an OpenStack server and waits until it's in running state
# @param [String] agent_id Agent id associated with new VM
# @param [String] stemcell_id AMI id that will be used
- # to power on new instance
+ # to power on new server
# @param [Hash] resource_pool Resource pool specification
# @param [Hash] network_spec Network specification, if it contains
# security groups they must be existing
@@ -79,7 +79,7 @@ def delete_stemcell(stemcell_id)
#
# @return [String] created server id
def create_vm(agent_id, stemcell_id, resource_pool,
- network_spec, disk_locality = nil, environment = nil)
+ network_spec = nil, disk_locality = nil, environment = nil)
with_thread_name("create_vm(#{agent_id}, ...)") do
network_configurator = NetworkConfigurator.new(network_spec)
@@ -155,7 +155,7 @@ def create_vm(agent_id, stemcell_id, resource_pool,
end
##
- # Terminates OpenStack server and waits until it reports as terminated
+ # Terminates an OpenStack server and waits until it reports as terminated
# @param [String] server_id Running OpenStack server id
def delete_vm(server_id)
with_thread_name("delete_vm(#{server_id})") do
@@ -173,7 +173,7 @@ def delete_vm(server_id)
end
##
- # Reboots OpenStack Server
+ # Reboots an OpenStack Server
# @param [String] server_id Running OpenStack server id
def reboot_vm(server_id)
with_thread_name("reboot_vm(#{server_id})") do
@@ -183,7 +183,7 @@ def reboot_vm(server_id)
end
##
- # Configures networking an existing OpenStack server
+ # Configures networking on existing OpenStack server
# @param [String] server_id Running OpenStack server id
# @param [Hash] network_spec raw network spec passed by director
def configure_networks(server_id, network_spec)
@@ -247,7 +247,7 @@ def create_disk(size, server_id = nil)
end
##
- # Deletes OpenStack volume
+ # Deletes an OpenStack volume
# @param [String] disk_id volume id
def delete_disk(disk_id)
with_thread_name("delete_disk(#{disk_id})") do
View
@@ -4,6 +4,7 @@
require "rubygems"
require "bundler"
+
Bundler.setup(:default, :test)
require "rspec"
@@ -22,14 +23,13 @@ class OpenStackConfig
Bosh::Clouds::Config.configure(os_config)
-MOCK_AWS_ACCESS_KEY_ID = "foo"
-MOCK_AWS_SECRET_ACCESS_KEY = "bar"
-
def mock_cloud_options
{
"openstack" => {
- "access_key_id" => MOCK_AWS_ACCESS_KEY_ID,
- "secret_access_key" => MOCK_AWS_SECRET_ACCESS_KEY
+ "auth_url" => "http://127.0.0.1:5000/v2.0/tokens",
+ "username" => "admin",
+ "api_key" => "nova",
+ "tenant" => "admin"
},
"agent" => {
"foo" => "bar",
@@ -39,57 +39,21 @@ def mock_cloud_options
end
def make_cloud(options = nil)
- Bosh::AwsCloud::Cloud.new(options || mock_cloud_options)
-end
-
-def mock_registry(endpoint = "http://registry:3333")
- registry = mock("registry", :endpoint => endpoint)
- Bosh::AwsCloud::RegistryClient.stub!(:new).and_return(registry)
- registry
+ Bosh::OpenStackCloud::Cloud.new(options || mock_cloud_options)
end
def mock_cloud(options = nil)
- instances = double("instances")
+ servers = double("servers")
volumes = double("volumes")
- images = double("images")
-
- ec2 = double(AWS::EC2)
- ec2.stub(:instances).and_return(instances)
- ec2.stub(:volumes).and_return(volumes)
- ec2.stub(:images).and_return(images)
+ openstack = double(Fog::Compute)
- AWS::EC2.stub(:new).and_return(ec2)
-
- yield ec2 if block_given?
-
- Bosh::AwsCloud::Cloud.new(options || mock_cloud_options)
-end
-
-def dynamic_network_spec
- { "type" => "dynamic" }
-end
+ openstack.stub(:servers).and_return(servers)
+ openstack.stub(:volumes).and_return(volumes)
-def vip_network_spec
- {
- "type" => "vip",
- "ip" => "10.0.0.1"
- }
-end
+ Fog::Compute.stub(:new).and_return(openstack)
-def combined_network_spec
- {
- "network_a" => dynamic_network_spec,
- "network_b" => vip_network_spec
- }
-end
+ yield openstack if block_given?
-def resource_pool_spec
- {
- "key_name" => "test_key",
- "availability_zone" => "foobar-1a",
- "instance_type" => "m3.zb"
- }
+ Bosh::OpenStackCloud::Cloud.new(options || mock_cloud_options)
end
-
-
@@ -1,146 +1,23 @@
-# Copyright (c) 2009-2012 VMware, Inc.
+# Copyright (c) 2012 Piston Cloud Computing, Inc.
require File.expand_path("../../spec_helper", __FILE__)
-describe Bosh::AwsCloud::Cloud do
+describe Bosh::OpenStackCloud::Cloud do
- before(:each) do
- @registry = mock_registry
- end
-
- it "attaches EC2 volume to an instance" do
- instance = double("instance", :id => "i-test")
+ it "attaches OpenStack volume to a server" do
+ server = double("server", :id => "i-test")
volume = double("volume", :id => "v-foobar")
attachment = double("attachment", :device => "/dev/sdf")
- cloud = mock_cloud do |ec2|
- ec2.instances.should_receive(:[]).with("i-test").and_return(instance)
- ec2.volumes.should_receive(:[]).with("v-foobar").and_return(volume)
- end
-
- volume.should_receive(:attach_to).
- with(instance, "/dev/sdf").and_return(attachment)
-
- instance.should_receive(:block_device_mappings).and_return({})
-
- attachment.should_receive(:status).and_return(:attaching)
- cloud.should_receive(:wait_resource).with(attachment, :attaching, :attached)
-
- old_settings = { "foo" => "bar" }
- new_settings = {
- "foo" => "bar",
- "disks" => {
- "persistent" => {
- "v-foobar" => "/dev/sdf"
- }
- }
- }
-
- @registry.should_receive(:read_settings).
- with("i-test").
- and_return(old_settings)
-
- @registry.should_receive(:update_settings).with("i-test", new_settings)
-
- cloud.attach_disk("i-test", "v-foobar")
- end
-
- it "picks available device name" do
- instance = double("instance", :id => "i-test")
- volume = double("volume", :id => "v-foobar")
- attachment = double("attachment", :device => "/dev/sdh")
-
- cloud = mock_cloud do |ec2|
- ec2.instances.should_receive(:[]).with("i-test").and_return(instance)
- ec2.volumes.should_receive(:[]).with("v-foobar").and_return(volume)
- end
-
- instance.should_receive(:block_device_mappings).
- and_return({ "/dev/sdf" => "foo", "/dev/sdg" => "bar" })
-
- volume.should_receive(:attach_to).
- with(instance, "/dev/sdh").and_return(attachment)
-
- attachment.should_receive(:status).and_return(:attaching)
- cloud.should_receive(:wait_resource).with(attachment, :attaching, :attached)
-
- old_settings = { "foo" => "bar" }
- new_settings = {
- "foo" => "bar",
- "disks" => {
- "persistent" => {
- "v-foobar" => "/dev/sdh"
- }
- }
- }
-
- @registry.should_receive(:read_settings).
- with("i-test").
- and_return(old_settings)
-
- @registry.should_receive(:update_settings).with("i-test", new_settings)
-
- cloud.attach_disk("i-test", "v-foobar")
- end
-
- it "picks available device name" do
- instance = double("instance", :id => "i-test")
- volume = double("volume", :id => "v-foobar")
- attachment = double("attachment", :device => "/dev/sdh")
-
- cloud = mock_cloud do |ec2|
- ec2.instances.should_receive(:[]).with("i-test").and_return(instance)
- ec2.volumes.should_receive(:[]).with("v-foobar").and_return(volume)
+ cloud = mock_cloud do |openstack|
+ openstack.servers.should_receive(:get).with("i-test").and_return(server)
+ openstack.volumes.should_receive(:get).with("v-foobar").and_return(volume)
end
- instance.should_receive(:block_device_mappings).
- and_return({ "/dev/sdf" => "foo", "/dev/sdg" => "bar" })
-
- volume.should_receive(:attach_to).
- with(instance, "/dev/sdh").and_return(attachment)
-
- attachment.should_receive(:status).and_return(:attaching)
- cloud.should_receive(:wait_resource).with(attachment, :attaching, :attached)
-
- old_settings = { "foo" => "bar" }
- new_settings = {
- "foo" => "bar",
- "disks" => {
- "persistent" => {
- "v-foobar" => "/dev/sdh"
- }
- }
- }
-
- @registry.should_receive(:read_settings).
- with("i-test").
- and_return(old_settings)
-
- @registry.should_receive(:update_settings).with("i-test", new_settings)
+ server.should_receive(:attach_volume).with("v-foobar", "i-test", "v-foobar")
+ cloud.stub(:update_agent_settings).and_return({})
cloud.attach_disk("i-test", "v-foobar")
end
- it "raises an error when sdf..sdp are all reserved" do
- instance = double("instance", :id => "i-test")
- volume = double("volume", :id => "v-foobar")
-
- cloud = mock_cloud do |ec2|
- ec2.instances.should_receive(:[]).with("i-test").and_return(instance)
- ec2.volumes.should_receive(:[]).with("v-foobar").and_return(volume)
- end
-
- all_mappings = ("f".."p").inject({}) do |hash, char|
- hash["/dev/sd#{char}"] = "foo"
- hash
- end
-
- instance.should_receive(:block_device_mappings).
- and_return(all_mappings)
-
- expect {
- cloud.attach_disk("i-test", "v-foobar")
- }.to raise_error(Bosh::Clouds::CloudError, /too many disks attached/)
- end
-
end
@@ -1,14 +1,14 @@
-# Copyright (c) 2009-2012 VMware, Inc.
+# Copyright (c) 2012 Piston Cloud Computing, Inc.
require File.expand_path("../../spec_helper", __FILE__)
-describe Bosh::AwsCloud::Cloud do
+describe Bosh::OpenStackCloud::Cloud do
describe "creating via provider" do
it "can be created using Bosh::Cloud::Provider" do
- cloud = Bosh::Clouds::Provider.create(:aws, mock_cloud_options)
- cloud.should be_an_instance_of(Bosh::AwsCloud::Cloud)
+ cloud = Bosh::Clouds::Provider.create(:openstack, mock_cloud_options)
+ cloud.should be_an_instance_of(Bosh::OpenStackCloud::Cloud)
end
end
Oops, something went wrong.

0 comments on commit 3592fd9

Please sign in to comment.