bbrowning-deltacloud-core 0.0.1.1 → 0.0.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. data/COPYING +176 -502
  2. data/Rakefile +21 -14
  3. data/deltacloud.rb +3 -0
  4. data/lib/deltacloud/base_driver/base_driver.rb +22 -11
  5. data/lib/deltacloud/base_driver.rb +12 -11
  6. data/lib/deltacloud/drivers/ec2/ec2_driver.rb +15 -12
  7. data/lib/deltacloud/drivers/gogrid/gogrid_driver.rb +16 -11
  8. data/lib/deltacloud/drivers/mock/data/images/img1.yml +3 -0
  9. data/lib/deltacloud/drivers/mock/data/images/img2.yml +3 -0
  10. data/lib/deltacloud/drivers/mock/data/images/img3.yml +3 -0
  11. data/lib/deltacloud/drivers/mock/data/instances/inst0.yml +16 -0
  12. data/lib/deltacloud/drivers/mock/data/instances/inst1.yml +9 -0
  13. data/lib/deltacloud/drivers/mock/data/instances/inst2.yml +9 -0
  14. data/lib/deltacloud/drivers/mock/data/storage_snapshots/snap1.yml +4 -0
  15. data/lib/deltacloud/drivers/mock/data/storage_snapshots/snap2.yml +4 -0
  16. data/lib/deltacloud/drivers/mock/data/storage_snapshots/snap3.yml +4 -0
  17. data/lib/deltacloud/drivers/mock/data/storage_volumes/vol1.yml +6 -0
  18. data/lib/deltacloud/drivers/mock/data/storage_volumes/vol2.yml +6 -0
  19. data/lib/deltacloud/drivers/mock/data/storage_volumes/vol3.yml +6 -0
  20. data/lib/deltacloud/drivers/mock/mock_driver.rb +13 -11
  21. data/lib/deltacloud/drivers/rackspace/rackspace_client.rb +12 -11
  22. data/lib/deltacloud/drivers/rackspace/rackspace_driver.rb +12 -11
  23. data/lib/deltacloud/drivers/rhevm/rhevm_driver.rb +12 -11
  24. data/lib/deltacloud/drivers/rimuhosting/rimuhosting_client.rb +12 -11
  25. data/lib/deltacloud/drivers/rimuhosting/rimuhosting_driver.rb +14 -12
  26. data/lib/deltacloud/drivers/terremark/terremark_driver.rb +12 -11
  27. data/lib/deltacloud/helpers/application_helper.rb +64 -11
  28. data/lib/deltacloud/helpers/conversion_helper.rb +12 -11
  29. data/lib/deltacloud/method_serializer.rb +12 -11
  30. data/lib/deltacloud/models/base_model.rb +12 -11
  31. data/lib/deltacloud/models/image.rb +12 -11
  32. data/lib/deltacloud/models/instance.rb +13 -12
  33. data/lib/deltacloud/models/instance_profile.rb +12 -11
  34. data/lib/deltacloud/models/realm.rb +12 -11
  35. data/lib/deltacloud/models/storage_snapshot.rb +12 -11
  36. data/lib/deltacloud/models/storage_volume.rb +12 -11
  37. data/lib/drivers.rb +12 -0
  38. data/lib/sinatra/rabbit.rb +1 -0
  39. data/lib/sinatra/respond_to.rb +3 -0
  40. data/lib/sinatra/url_for.rb +3 -4
  41. data/server.rb +40 -80
  42. data/{torquebox-ec2-config.ru → support/torquebox/torquebox-ec2-config.ru} +0 -0
  43. data/tests/api_test.rb +37 -0
  44. data/tests/hardware_profiles_test.rb +120 -0
  45. data/tests/images_test.rb +95 -78
  46. data/tests/instance_states_test.rb +52 -0
  47. data/tests/instances_test.rb +193 -110
  48. data/tests/realms_test.rb +66 -44
  49. data/views/errors/not_found.html.haml +6 -0
  50. data/views/errors/not_found.xml.haml +2 -0
  51. data/views/hardware_profiles/index.xml.haml +1 -1
  52. data/views/hardware_profiles/show.xml.haml +3 -2
  53. data/views/images/index.xml.haml +4 -3
  54. data/views/images/show.xml.haml +2 -2
  55. data/views/instances/index.xml.haml +6 -8
  56. data/views/instances/show.xml.haml +9 -10
  57. data/views/realms/index.xml.haml +1 -3
  58. data/views/realms/show.xml.haml +4 -5
  59. data/views/storage_snapshots/index.xml.haml +3 -5
  60. data/views/storage_snapshots/show.xml.haml +2 -4
  61. data/views/storage_volumes/index.xml.haml +7 -7
  62. data/views/storage_volumes/show.xml.haml +2 -4
  63. metadata +37 -39
  64. data/tests/deltacloud_test.rb +0 -60
  65. data/tests/storage_snapshots_test.rb +0 -48
  66. data/tests/storage_volumes_test.rb +0 -48
@@ -1,19 +1,20 @@
1
1
  #
2
2
  # Copyright (C) 2009 Red Hat, Inc.
3
3
  #
4
- # This library is free software; you can redistribute it and/or
5
- # modify it under the terms of the GNU Lesser General Public
6
- # License as published by the Free Software Foundation; either
7
- # version 2.1 of the License, or (at your option) any later version.
4
+ # Licensed to the Apache Software Foundation (ASF) under one or more
5
+ # contributor license agreements. See the NOTICE file distributed with
6
+ # this work for additional information regarding copyright ownership. The
7
+ # ASF licenses this file to you under the Apache License, Version 2.0 (the
8
+ # "License"); you may not use this file except in compliance with the
9
+ # License. You may obtain a copy of the License at
8
10
  #
9
- # This library is distributed in the hope that it will be useful,
10
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
- # Lesser General Public License for more details.
11
+ # http://www.apache.org/licenses/LICENSE-2.0
13
12
  #
14
- # You should have received a copy of the GNU Lesser General Public
15
- # License along with this library; if not, write to the Free Software
16
- # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
16
+ # License for the specific language governing permissions and limitations
17
+ # under the License.
17
18
 
18
19
  # Methods added to this helper will be available to all templates in the application.
19
20
  module ApplicationHelper
@@ -53,4 +54,56 @@ module ApplicationHelper
53
54
  return 'password' if driver_has_feature?(:authentication_password)
54
55
  end
55
56
 
57
+ def filter_all(model)
58
+ filter = {}
59
+ filter.merge!(:id => params[:id]) if params[:id]
60
+ filter.merge!(:architecture => params[:architecture]) if params[:architecture]
61
+ filter.merge!(:owner_id => params[:owner_id]) if params[:owner_id]
62
+ filter.merge!(:state => params[:state]) if params[:state]
63
+ filter = nil if filter.keys.size.eql?(0)
64
+ singular = model.to_s.singularize.to_sym
65
+ @elements = driver.send(model.to_sym, credentials, filter)
66
+ instance_variable_set(:"@#{model}", @elements)
67
+ respond_to do |format|
68
+ format.html { haml :"#{model}/index" }
69
+ format.xml { haml :"#{model}/index" }
70
+ format.json { convert_to_json(singular, @elements) }
71
+ end
72
+ end
73
+
74
+ def show(model)
75
+ @element = driver.send(model, credentials, { :id => params[:id]} )
76
+ instance_variable_set("@#{model}", @element)
77
+ if @element
78
+ respond_to do |format|
79
+ format.html { haml :"#{model.to_s.pluralize}/show" }
80
+ format.xml { haml :"#{model.to_s.pluralize}/show" }
81
+ format.json { convert_to_json(model, @element) }
82
+ end
83
+ else
84
+ report_error(404, 'not_found')
85
+ end
86
+ end
87
+
88
+ def report_error(status, template)
89
+ @error = request.env['sinatra.error']
90
+ response.status = status
91
+ respond_to do |format|
92
+ format.xml { haml :"errors/#{template}", :layout => false }
93
+ format.html { haml :"errors/#{template}" }
94
+ end
95
+ end
96
+
97
+ def instance_action(name)
98
+ @instance = driver.send(:"#{name}_instance", credentials, params["id"])
99
+
100
+ return redirect(instances_url) if name.eql?(:destroy) or @instance.class!=Instance
101
+
102
+ respond_to do |format|
103
+ format.html { haml :"instances/show" }
104
+ format.xml { haml :"instances/show" }
105
+ format.json {convert_to_json(:instance, @instance) }
106
+ end
107
+ end
108
+
56
109
  end
@@ -1,19 +1,20 @@
1
1
  #
2
2
  # Copyright (C) 2009 Red Hat, Inc.
3
3
  #
4
- # This library is free software; you can redistribute it and/or
5
- # modify it under the terms of the GNU Lesser General Public
6
- # License as published by the Free Software Foundation; either
7
- # version 2.1 of the License, or (at your option) any later version.
4
+ # Licensed to the Apache Software Foundation (ASF) under one or more
5
+ # contributor license agreements. See the NOTICE file distributed with
6
+ # this work for additional information regarding copyright ownership. The
7
+ # ASF licenses this file to you under the Apache License, Version 2.0 (the
8
+ # "License"); you may not use this file except in compliance with the
9
+ # License. You may obtain a copy of the License at
8
10
  #
9
- # This library is distributed in the hope that it will be useful,
10
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
- # Lesser General Public License for more details.
11
+ # http://www.apache.org/licenses/LICENSE-2.0
13
12
  #
14
- # You should have received a copy of the GNU Lesser General Public
15
- # License along with this library; if not, write to the Free Software
16
- # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
16
+ # License for the specific language governing permissions and limitations
17
+ # under the License.
17
18
 
18
19
 
19
20
  require 'deltacloud/base_driver'
@@ -1,19 +1,20 @@
1
1
  #
2
2
  # Copyright (C) 2009 Red Hat, Inc.
3
3
  #
4
- # This library is free software; you can redistribute it and/or
5
- # modify it under the terms of the GNU Lesser General Public
6
- # License as published by the Free Software Foundation; either
7
- # version 2.1 of the License, or (at your option) any later version.
4
+ # Licensed to the Apache Software Foundation (ASF) under one or more
5
+ # contributor license agreements. See the NOTICE file distributed with
6
+ # this work for additional information regarding copyright ownership. The
7
+ # ASF licenses this file to you under the Apache License, Version 2.0 (the
8
+ # "License"); you may not use this file except in compliance with the
9
+ # License. You may obtain a copy of the License at
8
10
  #
9
- # This library is distributed in the hope that it will be useful,
10
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
- # Lesser General Public License for more details.
11
+ # http://www.apache.org/licenses/LICENSE-2.0
13
12
  #
14
- # You should have received a copy of the GNU Lesser General Public
15
- # License along with this library; if not, write to the Free Software
16
- # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
16
+ # License for the specific language governing permissions and limitations
17
+ # under the License.
17
18
 
18
19
  require 'base64'
19
20
  require 'digest'
@@ -1,19 +1,20 @@
1
1
  #
2
2
  # Copyright (C) 2009 Red Hat, Inc.
3
3
  #
4
- # This library is free software; you can redistribute it and/or
5
- # modify it under the terms of the GNU Lesser General Public
6
- # License as published by the Free Software Foundation; either
7
- # version 2.1 of the License, or (at your option) any later version.
4
+ # Licensed to the Apache Software Foundation (ASF) under one or more
5
+ # contributor license agreements. See the NOTICE file distributed with
6
+ # this work for additional information regarding copyright ownership. The
7
+ # ASF licenses this file to you under the Apache License, Version 2.0 (the
8
+ # "License"); you may not use this file except in compliance with the
9
+ # License. You may obtain a copy of the License at
8
10
  #
9
- # This library is distributed in the hope that it will be useful,
10
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
- # Lesser General Public License for more details.
11
+ # http://www.apache.org/licenses/LICENSE-2.0
13
12
  #
14
- # You should have received a copy of the GNU Lesser General Public
15
- # License along with this library; if not, write to the Free Software
16
- # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
16
+ # License for the specific language governing permissions and limitations
17
+ # under the License.
17
18
 
18
19
 
19
20
  class BaseModel
@@ -1,19 +1,20 @@
1
1
  #
2
2
  # Copyright (C) 2009 Red Hat, Inc.
3
3
  #
4
- # This library is free software; you can redistribute it and/or
5
- # modify it under the terms of the GNU Lesser General Public
6
- # License as published by the Free Software Foundation; either
7
- # version 2.1 of the License, or (at your option) any later version.
4
+ # Licensed to the Apache Software Foundation (ASF) under one or more
5
+ # contributor license agreements. See the NOTICE file distributed with
6
+ # this work for additional information regarding copyright ownership. The
7
+ # ASF licenses this file to you under the Apache License, Version 2.0 (the
8
+ # "License"); you may not use this file except in compliance with the
9
+ # License. You may obtain a copy of the License at
8
10
  #
9
- # This library is distributed in the hope that it will be useful,
10
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
- # Lesser General Public License for more details.
11
+ # http://www.apache.org/licenses/LICENSE-2.0
13
12
  #
14
- # You should have received a copy of the GNU Lesser General Public
15
- # License along with this library; if not, write to the Free Software
16
- # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
16
+ # License for the specific language governing permissions and limitations
17
+ # under the License.
17
18
 
18
19
 
19
20
  class Image < BaseModel
@@ -1,19 +1,20 @@
1
1
  #
2
2
  # Copyright (C) 2009 Red Hat, Inc.
3
3
  #
4
- # This library is free software; you can redistribute it and/or
5
- # modify it under the terms of the GNU Lesser General Public
6
- # License as published by the Free Software Foundation; either
7
- # version 2.1 of the License, or (at your option) any later version.
4
+ # Licensed to the Apache Software Foundation (ASF) under one or more
5
+ # contributor license agreements. See the NOTICE file distributed with
6
+ # this work for additional information regarding copyright ownership. The
7
+ # ASF licenses this file to you under the Apache License, Version 2.0 (the
8
+ # "License"); you may not use this file except in compliance with the
9
+ # License. You may obtain a copy of the License at
8
10
  #
9
- # This library is distributed in the hope that it will be useful,
10
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
- # Lesser General Public License for more details.
11
+ # http://www.apache.org/licenses/LICENSE-2.0
13
12
  #
14
- # You should have received a copy of the GNU Lesser General Public
15
- # License along with this library; if not, write to the Free Software
16
- # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
16
+ # License for the specific language governing permissions and limitations
17
+ # under the License.
17
18
 
18
19
 
19
20
  class Instance < BaseModel
@@ -27,7 +28,7 @@ class Instance < BaseModel
27
28
  attr_accessor :public_addresses
28
29
  attr_accessor :private_addresses
29
30
  attr_accessor :instance_profile
30
-
31
+ attr_accessor :launch_time
31
32
  def initialize(init=nil)
32
33
  super(init)
33
34
  self.actions = [] if self.actions.nil?
@@ -1,19 +1,20 @@
1
1
  #
2
2
  # Copyright (C) 2009 Red Hat, Inc.
3
3
  #
4
- # This library is free software; you can redistribute it and/or
5
- # modify it under the terms of the GNU Lesser General Public
6
- # License as published by the Free Software Foundation; either
7
- # version 2.1 of the License, or (at your option) any later version.
4
+ # Licensed to the Apache Software Foundation (ASF) under one or more
5
+ # contributor license agreements. See the NOTICE file distributed with
6
+ # this work for additional information regarding copyright ownership. The
7
+ # ASF licenses this file to you under the Apache License, Version 2.0 (the
8
+ # "License"); you may not use this file except in compliance with the
9
+ # License. You may obtain a copy of the License at
8
10
  #
9
- # This library is distributed in the hope that it will be useful,
10
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
- # Lesser General Public License for more details.
11
+ # http://www.apache.org/licenses/LICENSE-2.0
13
12
  #
14
- # You should have received a copy of the GNU Lesser General Public
15
- # License along with this library; if not, write to the Free Software
16
- # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
16
+ # License for the specific language governing permissions and limitations
17
+ # under the License.
17
18
 
18
19
  # Model to store the hardware profile applied to an instance together with
19
20
  # any instance-specific overrides
@@ -1,19 +1,20 @@
1
1
  #
2
2
  # Copyright (C) 2009 Red Hat, Inc.
3
3
  #
4
- # This library is free software; you can redistribute it and/or
5
- # modify it under the terms of the GNU Lesser General Public
6
- # License as published by the Free Software Foundation; either
7
- # version 2.1 of the License, or (at your option) any later version.
4
+ # Licensed to the Apache Software Foundation (ASF) under one or more
5
+ # contributor license agreements. See the NOTICE file distributed with
6
+ # this work for additional information regarding copyright ownership. The
7
+ # ASF licenses this file to you under the Apache License, Version 2.0 (the
8
+ # "License"); you may not use this file except in compliance with the
9
+ # License. You may obtain a copy of the License at
8
10
  #
9
- # This library is distributed in the hope that it will be useful,
10
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
- # Lesser General Public License for more details.
11
+ # http://www.apache.org/licenses/LICENSE-2.0
13
12
  #
14
- # You should have received a copy of the GNU Lesser General Public
15
- # License along with this library; if not, write to the Free Software
16
- # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
16
+ # License for the specific language governing permissions and limitations
17
+ # under the License.
17
18
 
18
19
 
19
20
  class Realm < BaseModel
@@ -1,19 +1,20 @@
1
1
  #
2
2
  # Copyright (C) 2009 Red Hat, Inc.
3
3
  #
4
- # This library is free software; you can redistribute it and/or
5
- # modify it under the terms of the GNU Lesser General Public
6
- # License as published by the Free Software Foundation; either
7
- # version 2.1 of the License, or (at your option) any later version.
4
+ # Licensed to the Apache Software Foundation (ASF) under one or more
5
+ # contributor license agreements. See the NOTICE file distributed with
6
+ # this work for additional information regarding copyright ownership. The
7
+ # ASF licenses this file to you under the Apache License, Version 2.0 (the
8
+ # "License"); you may not use this file except in compliance with the
9
+ # License. You may obtain a copy of the License at
8
10
  #
9
- # This library is distributed in the hope that it will be useful,
10
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
- # Lesser General Public License for more details.
11
+ # http://www.apache.org/licenses/LICENSE-2.0
13
12
  #
14
- # You should have received a copy of the GNU Lesser General Public
15
- # License along with this library; if not, write to the Free Software
16
- # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
16
+ # License for the specific language governing permissions and limitations
17
+ # under the License.
17
18
 
18
19
 
19
20
 
@@ -1,19 +1,20 @@
1
1
  #
2
2
  # Copyright (C) 2009 Red Hat, Inc.
3
3
  #
4
- # This library is free software; you can redistribute it and/or
5
- # modify it under the terms of the GNU Lesser General Public
6
- # License as published by the Free Software Foundation; either
7
- # version 2.1 of the License, or (at your option) any later version.
4
+ # Licensed to the Apache Software Foundation (ASF) under one or more
5
+ # contributor license agreements. See the NOTICE file distributed with
6
+ # this work for additional information regarding copyright ownership. The
7
+ # ASF licenses this file to you under the Apache License, Version 2.0 (the
8
+ # "License"); you may not use this file except in compliance with the
9
+ # License. You may obtain a copy of the License at
8
10
  #
9
- # This library is distributed in the hope that it will be useful,
10
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
- # Lesser General Public License for more details.
11
+ # http://www.apache.org/licenses/LICENSE-2.0
13
12
  #
14
- # You should have received a copy of the GNU Lesser General Public
15
- # License along with this library; if not, write to the Free Software
16
- # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
16
+ # License for the specific language governing permissions and limitations
17
+ # under the License.
17
18
 
18
19
 
19
20
  class StorageVolume < BaseModel
data/lib/drivers.rb CHANGED
@@ -9,6 +9,18 @@ DRIVERS = {
9
9
  :mock => { :name => "Mock" }
10
10
  }
11
11
 
12
+ DEFAULT_COLLECTIONS = [
13
+ :hardware_profiles,
14
+ :images,
15
+ :instances,
16
+ :instance_states,
17
+ :realms,
18
+ :storage_volumes,
19
+ :storage_snapshots
20
+ ]
21
+
22
+ DRIVER=ENV['API_DRIVER'] ? ENV['API_DRIVER'].to_sym : :mock
23
+
12
24
  def driver_name
13
25
  DRIVERS[DRIVER][:name]
14
26
  end
@@ -203,6 +203,7 @@ module Sinatra
203
203
  # operation on this collection.
204
204
  def collection(name, &block)
205
205
  raise DuplicateCollectionException if collections[name]
206
+ return unless driver.has_collection?(name.to_sym)
206
207
  collections[name] = Collection.new(name, &block)
207
208
  collections[name].add_feature_params(driver.features(name))
208
209
  collections[name].generate
@@ -267,3 +267,6 @@ module Sinatra
267
267
  end
268
268
  end
269
269
  end
270
+
271
+ Rack::Mime::MIME_TYPES.merge!({ ".gv" => "text/plain" })
272
+ Sinatra::Application.register Sinatra::RespondTo
@@ -18,7 +18,7 @@ module Sinatra
18
18
  when :path_only
19
19
  base = request.script_name
20
20
  when :full
21
- scheme = request.scheme || "http"
21
+ scheme = request.scheme || 'http'
22
22
  if (scheme == 'http' && request.port == 80 ||
23
23
  scheme == 'https' && request.port == 443)
24
24
  port = ""
@@ -30,9 +30,8 @@ module Sinatra
30
30
  else
31
31
  raise TypeError, "Unknown url_for mode #{mode}"
32
32
  end
33
- # Don't add the base fragment if url_for
34
- # gets called more than once per url or
35
- # the url_fragment passed in is an absolute url
33
+ # Don't add the base fragment if url_for gets called more than once
34
+ # per url or the url_fragment passed in is an absolute url
36
35
  if url_fragment.match(/^#{base}/) or url_fragment.match(/^http/)
37
36
  url_fragment
38
37
  else