fog 1.27.0 → 1.28.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +71 -0
- data/Rakefile +2 -2
- data/bin/fog +2 -2
- data/fog.gemspec +4 -3
- data/lib/fog/bin/clodo.rb +1 -1
- data/lib/fog/bin/openstack.rb +5 -0
- data/lib/fog/digitalocean/examples/getting_started.md +46 -4
- data/lib/fog/digitalocean/models/compute/server.rb +1 -3
- data/lib/fog/digitalocean/models/compute/servers.rb +30 -0
- data/lib/fog/fogdocker/compute.rb +3 -2
- data/lib/fog/fogdocker/requests/compute/container_action.rb +1 -1
- data/lib/fog/fogdocker/requests/compute/container_all.rb +1 -1
- data/lib/fog/fogdocker/requests/compute/container_commit.rb +1 -1
- data/lib/fog/fogdocker/requests/compute/container_create.rb +1 -1
- data/lib/fog/fogdocker/requests/compute/container_delete.rb +1 -1
- data/lib/fog/fogdocker/requests/compute/container_get.rb +1 -1
- data/lib/fog/fogdocker/requests/compute/image_all.rb +1 -1
- data/lib/fog/fogdocker/requests/compute/image_create.rb +1 -1
- data/lib/fog/fogdocker/requests/compute/image_delete.rb +1 -1
- data/lib/fog/fogdocker/requests/compute/image_get.rb +1 -1
- data/lib/fog/fogdocker/requests/compute/image_search.rb +1 -1
- data/lib/fog/google/compute.rb +2 -1
- data/lib/fog/google/core.rb +42 -12
- data/lib/fog/google/dns.rb +2 -1
- data/lib/fog/google/monitoring.rb +1 -1
- data/lib/fog/google/sql.rb +1 -1
- data/lib/fog/hp/requests/storage/get_object.rb +5 -3
- data/lib/fog/joyent/compute.rb +2 -0
- data/lib/fog/openstack.rb +1 -0
- data/lib/fog/openstack/baremetal.rb +370 -0
- data/lib/fog/openstack/core.rb +1 -0
- data/lib/fog/openstack/docs/orchestration.md +318 -0
- data/lib/fog/openstack/docs/storage.md +1 -7
- data/lib/fog/openstack/models/baremetal/chassis.rb +60 -0
- data/lib/fog/openstack/models/baremetal/chassis_collection.rb +38 -0
- data/lib/fog/openstack/models/baremetal/driver.rb +30 -0
- data/lib/fog/openstack/models/baremetal/drivers.rb +21 -0
- data/lib/fog/openstack/models/baremetal/node.rb +85 -0
- data/lib/fog/openstack/models/baremetal/nodes.rb +38 -0
- data/lib/fog/openstack/models/baremetal/port.rb +61 -0
- data/lib/fog/openstack/models/baremetal/ports.rb +38 -0
- data/lib/fog/openstack/models/orchestration/event.rb +20 -0
- data/lib/fog/openstack/models/orchestration/events.rb +28 -0
- data/lib/fog/openstack/models/orchestration/resource.rb +32 -0
- data/lib/fog/openstack/models/orchestration/resource_schemas.rb +17 -0
- data/lib/fog/openstack/models/orchestration/resources.rb +35 -0
- data/lib/fog/openstack/models/orchestration/stack.rb +91 -24
- data/lib/fog/openstack/models/orchestration/stacks.rb +38 -4
- data/lib/fog/openstack/models/orchestration/template.rb +15 -0
- data/lib/fog/openstack/models/orchestration/templates.rb +44 -0
- data/lib/fog/openstack/orchestration.rb +48 -2
- data/lib/fog/openstack/requests/baremetal/create_chassis.rb +44 -0
- data/lib/fog/openstack/requests/baremetal/create_node.rb +54 -0
- data/lib/fog/openstack/requests/baremetal/create_port.rb +46 -0
- data/lib/fog/openstack/requests/baremetal/delete_chassis.rb +25 -0
- data/lib/fog/openstack/requests/baremetal/delete_node.rb +25 -0
- data/lib/fog/openstack/requests/baremetal/delete_port.rb +25 -0
- data/lib/fog/openstack/requests/baremetal/get_chassis.rb +24 -0
- data/lib/fog/openstack/requests/baremetal/get_driver.rb +24 -0
- data/lib/fog/openstack/requests/baremetal/get_driver_properties.rb +40 -0
- data/lib/fog/openstack/requests/baremetal/get_node.rb +24 -0
- data/lib/fog/openstack/requests/baremetal/get_port.rb +24 -0
- data/lib/fog/openstack/requests/baremetal/list_chassis.rb +48 -0
- data/lib/fog/openstack/requests/baremetal/list_chassis_detailed.rb +31 -0
- data/lib/fog/openstack/requests/baremetal/list_drivers.rb +24 -0
- data/lib/fog/openstack/requests/baremetal/list_nodes.rb +40 -0
- data/lib/fog/openstack/requests/baremetal/list_nodes_detailed.rb +31 -0
- data/lib/fog/openstack/requests/baremetal/list_ports.rb +48 -0
- data/lib/fog/openstack/requests/baremetal/list_ports_detailed.rb +31 -0
- data/lib/fog/openstack/requests/baremetal/patch_chassis.rb +42 -0
- data/lib/fog/openstack/requests/baremetal/patch_node.rb +41 -0
- data/lib/fog/openstack/requests/baremetal/patch_port.rb +41 -0
- data/lib/fog/openstack/requests/compute/create_server.rb +1 -0
- data/lib/fog/openstack/requests/orchestration/abandon_stack.rb +15 -0
- data/lib/fog/openstack/requests/orchestration/build_info.rb +15 -0
- data/lib/fog/openstack/requests/orchestration/create_stack.rb +31 -12
- data/lib/fog/openstack/requests/orchestration/delete_stack.rb +28 -5
- data/lib/fog/openstack/requests/orchestration/get_stack_template.rb +20 -0
- data/lib/fog/openstack/requests/orchestration/list_resource_events.rb +23 -0
- data/lib/fog/openstack/requests/orchestration/list_resource_types.rb +26 -0
- data/lib/fog/openstack/requests/orchestration/list_resources.rb +23 -0
- data/lib/fog/openstack/requests/orchestration/list_stack_data.rb +27 -0
- data/lib/fog/openstack/requests/orchestration/list_stack_events.rb +23 -0
- data/lib/fog/openstack/requests/orchestration/preview_stack.rb +16 -0
- data/lib/fog/openstack/requests/orchestration/show_event_details.rb +26 -0
- data/lib/fog/openstack/requests/orchestration/show_resource_data.rb +26 -0
- data/lib/fog/openstack/requests/orchestration/show_resource_metadata.rb +26 -0
- data/lib/fog/openstack/requests/orchestration/show_resource_schema.rb +15 -0
- data/lib/fog/openstack/requests/orchestration/show_resource_template.rb +20 -0
- data/lib/fog/openstack/requests/orchestration/show_stack_details.rb +26 -0
- data/lib/fog/openstack/requests/orchestration/update_stack.rb +34 -7
- data/lib/fog/openstack/requests/orchestration/validate_template.rb +16 -0
- data/lib/fog/openstack/volume.rb +0 -1
- data/lib/fog/ovirt/compute.rb +6 -0
- data/lib/fog/ovirt/models/compute/server.rb +10 -0
- data/lib/fog/ovirt/models/compute/template.rb +1 -0
- data/lib/fog/ovirt/models/compute/volumes.rb +1 -2
- data/lib/fog/ovirt/requests/compute/attach_volume.rb +22 -0
- data/lib/fog/ovirt/requests/compute/detach_volume.rb +22 -0
- data/lib/fog/ovirt/requests/compute/list_volumes.rb +19 -0
- data/lib/fog/ovirt/requests/compute/mock_files/disks.xml +58 -0
- data/lib/fog/vcloud_director/models/compute/task.rb +2 -2
- data/lib/fog/version.rb +1 -1
- data/lib/fog/vsphere/compute.rb +3 -0
- data/lib/fog/vsphere/requests/compute/cloudinit_to_customspec.rb +20 -11
- data/lib/fog/vsphere/requests/compute/get_compute_resource.rb +41 -0
- data/lib/fog/vsphere/requests/compute/get_network.rb +35 -6
- data/lib/fog/vsphere/requests/compute/get_resource_pool.rb +1 -1
- data/lib/fog/vsphere/requests/compute/get_virtual_machine.rb +19 -13
- data/lib/fog/vsphere/requests/compute/list_compute_resources.rb +92 -0
- data/lib/fog/vsphere/requests/compute/list_virtual_machines.rb +16 -11
- data/lib/fog/vsphere/requests/compute/vm_clone.rb +6 -5
- data/lib/fog/xenserver/requests/compute/create_sr.rb +3 -4
- data/lib/tasks/changelog_task.rb +1 -0
- data/tests/helper.rb +3 -3
- data/tests/helpers/mock_helper.rb +0 -4
- data/tests/openstack/requests/baremetal/chassis_tests.rb +48 -0
- data/tests/openstack/requests/baremetal/driver_tests.rb +40 -0
- data/tests/openstack/requests/baremetal/node_tests.rb +65 -0
- data/tests/openstack/requests/baremetal/port_tests.rb +56 -0
- data/tests/openstack/requests/compute/server_tests.rb +2 -0
- data/tests/openstack/requests/orchestration/stack_tests.rb +2 -2
- data/tests/vsphere/requests/compute/get_network_tests.rb +48 -0
- metadata +88 -23
- data/lib/fog/aws.rb +0 -23
- data/lib/fog/bin/riakcs.rb +0 -25
- data/lib/fog/openstack/requests/orchestration/list_stacks.rb +0 -47
- data/lib/fog/riakcs.rb +0 -2
- data/lib/fog/riakcs/core.rb +0 -121
- data/lib/fog/riakcs/provisioning.rb +0 -98
- data/lib/fog/riakcs/requests/provisioning/create_user.rb +0 -77
- data/lib/fog/riakcs/requests/provisioning/disable_user.rb +0 -23
- data/lib/fog/riakcs/requests/provisioning/enable_user.rb +0 -23
- data/lib/fog/riakcs/requests/provisioning/get_user.rb +0 -41
- data/lib/fog/riakcs/requests/provisioning/list_users.rb +0 -43
- data/lib/fog/riakcs/requests/provisioning/regrant_secret.rb +0 -23
- data/lib/fog/riakcs/requests/provisioning/update_user.rb +0 -23
- data/lib/fog/riakcs/requests/usage/get_usage.rb +0 -68
- data/lib/fog/riakcs/usage.rb +0 -62
- data/tests/riakcs/requests/provisioning/provisioning_tests.rb +0 -174
- data/tests/riakcs/requests/usage/usage_tests.rb +0 -29
data/lib/fog/aws.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
require 'fog/aws/service_mapper'
|
2
|
-
require 'fog/aws/auto_scaling'
|
3
|
-
require 'fog/aws/beanstalk'
|
4
|
-
require 'fog/aws/cdn'
|
5
|
-
require 'fog/aws/cloud_formation'
|
6
|
-
require 'fog/aws/cloud_watch'
|
7
|
-
require 'fog/aws/compute'
|
8
|
-
require 'fog/aws/data_pipeline'
|
9
|
-
require 'fog/aws/dns'
|
10
|
-
require 'fog/aws/dynamodb'
|
11
|
-
require 'fog/aws/elasticache'
|
12
|
-
require 'fog/aws/elb'
|
13
|
-
require 'fog/aws/emr'
|
14
|
-
require 'fog/aws/glacier'
|
15
|
-
require 'fog/aws/iam'
|
16
|
-
require 'fog/aws/rds'
|
17
|
-
require 'fog/aws/redshift'
|
18
|
-
require 'fog/aws/ses'
|
19
|
-
require 'fog/aws/simpledb'
|
20
|
-
require 'fog/aws/sns'
|
21
|
-
require 'fog/aws/sqs'
|
22
|
-
require 'fog/aws/storage'
|
23
|
-
require 'fog/aws/sts'
|
data/lib/fog/bin/riakcs.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
class RiakCS < Fog::Bin
|
2
|
-
class << self
|
3
|
-
def class_for(key)
|
4
|
-
case key
|
5
|
-
when :provisioning
|
6
|
-
Fog::RiakCS::Provisioning
|
7
|
-
when :usage
|
8
|
-
Fog::RiakCS::Usage
|
9
|
-
else
|
10
|
-
raise ArgumentError, "Unrecognized service: #{key}"
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
def [](service)
|
15
|
-
@@connections ||= Hash.new do |hash, key|
|
16
|
-
hash[key] = class_for(key)
|
17
|
-
end
|
18
|
-
@@connections[service]
|
19
|
-
end
|
20
|
-
|
21
|
-
def services
|
22
|
-
Fog::RiakCS.services
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
@@ -1,47 +0,0 @@
|
|
1
|
-
module Fog
|
2
|
-
module Orchestration
|
3
|
-
class OpenStack
|
4
|
-
class Real
|
5
|
-
# List stacks.
|
6
|
-
#
|
7
|
-
# @param options [Hash]
|
8
|
-
#
|
9
|
-
# @return [Excon::Response]
|
10
|
-
# * body [Hash]:
|
11
|
-
# * stacks [Array] - Matching stacks
|
12
|
-
# * stack [Hash]:
|
13
|
-
# * id [String] -
|
14
|
-
# * stack_name [String] -
|
15
|
-
# * description [String]
|
16
|
-
# * links [Array]
|
17
|
-
# * stack_status [String] -
|
18
|
-
# * stack_status_reason [String]
|
19
|
-
# * creation_time [Time] -
|
20
|
-
# * updated_time [Time] -
|
21
|
-
#
|
22
|
-
#
|
23
|
-
# @see http://docs.aws.amazon.com/AWSCloudFormation/latest/APIReference/API_ListStacks.html
|
24
|
-
|
25
|
-
def list_stacks(options = {})
|
26
|
-
request(
|
27
|
-
:expects => 200,
|
28
|
-
:path => 'stacks',
|
29
|
-
:method => 'GET',
|
30
|
-
:query => options
|
31
|
-
)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
class Mock
|
36
|
-
def list_stacks(options = {})
|
37
|
-
stacks = self.data[:stacks].values
|
38
|
-
|
39
|
-
Excon::Response.new(
|
40
|
-
:body => { 'stacks' => stacks },
|
41
|
-
:status => 200
|
42
|
-
)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
data/lib/fog/riakcs.rb
DELETED
data/lib/fog/riakcs/core.rb
DELETED
@@ -1,121 +0,0 @@
|
|
1
|
-
require 'fog/core'
|
2
|
-
require 'fog/json'
|
3
|
-
|
4
|
-
module Fog
|
5
|
-
module RiakCS
|
6
|
-
module MultipartUtils
|
7
|
-
require 'net/http'
|
8
|
-
|
9
|
-
class Headers
|
10
|
-
include Net::HTTPHeader
|
11
|
-
|
12
|
-
def initialize
|
13
|
-
initialize_http_header({})
|
14
|
-
end
|
15
|
-
|
16
|
-
# Parse a single header line into its key and value
|
17
|
-
# @param [String] chunk a single header line
|
18
|
-
def self.parse(chunk)
|
19
|
-
line = chunk.strip
|
20
|
-
# thanks Net::HTTPResponse
|
21
|
-
return [nil,nil] if chunk =~ /\AHTTP(?:\/(\d+\.\d+))?\s+(\d\d\d)\s*(.*)\z/in
|
22
|
-
m = /\A([^:]+):\s*/.match(line)
|
23
|
-
[m[1], m.post_match] rescue [nil, nil]
|
24
|
-
end
|
25
|
-
|
26
|
-
# Parses a header line and adds it to the header collection
|
27
|
-
# @param [String] chunk a single header line
|
28
|
-
def parse(chunk)
|
29
|
-
key, value = self.class.parse(chunk)
|
30
|
-
add_field(key, value) if key && value
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
def parse(data, boundary)
|
35
|
-
contents = data.match(end_boundary_regex(boundary)).pre_match rescue ""
|
36
|
-
contents.split(inner_boundary_regex(boundary)).reject(&:empty?).map do |part|
|
37
|
-
parse_multipart_section(part)
|
38
|
-
end.compact
|
39
|
-
end
|
40
|
-
|
41
|
-
def extract_boundary(header_string)
|
42
|
-
$1 if header_string =~ /boundary=([A-Za-z0-9\'()+_,-.\/:=?]+)/
|
43
|
-
end
|
44
|
-
|
45
|
-
private
|
46
|
-
def end_boundary_regex(boundary)
|
47
|
-
/\r?\n--#{Regexp.escape(boundary)}--\r?\n?/
|
48
|
-
end
|
49
|
-
|
50
|
-
def inner_boundary_regex(boundary)
|
51
|
-
/\r?\n--#{Regexp.escape(boundary)}\r?\n/
|
52
|
-
end
|
53
|
-
|
54
|
-
def parse_multipart_section(part)
|
55
|
-
headers = Headers.new
|
56
|
-
if md = part.match(/\r?\n\r?\n/)
|
57
|
-
body = md.post_match
|
58
|
-
md.pre_match.split(/\r?\n/).each do |line|
|
59
|
-
headers.parse(line)
|
60
|
-
end
|
61
|
-
|
62
|
-
if headers["content-type"] =~ /multipart\/mixed/
|
63
|
-
boundary = extract_boundary(headers.to_hash["content-type"].first)
|
64
|
-
parse(body, boundary)
|
65
|
-
else
|
66
|
-
{:headers => headers.to_hash, :body => body}
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
module UserUtils
|
73
|
-
def update_riakcs_user(key_id, user)
|
74
|
-
response = @s3_connection.put_object('riak-cs', "user/#{key_id}", Fog::JSON.encode(user), { 'Content-Type' => 'application/json' })
|
75
|
-
if !response.body.empty?
|
76
|
-
response.body = Fog::JSON.decode(response.body)
|
77
|
-
end
|
78
|
-
response
|
79
|
-
end
|
80
|
-
|
81
|
-
def update_mock_user(key_id, user)
|
82
|
-
if data[key_id]
|
83
|
-
if status = user[:status]
|
84
|
-
data[key_id][:status] = status
|
85
|
-
end
|
86
|
-
|
87
|
-
if user[:new_key_secret]
|
88
|
-
data[key_id][:key_secret] = rand(100).to_s
|
89
|
-
end
|
90
|
-
|
91
|
-
Excon::Response.new.tap do |response|
|
92
|
-
response.status = 200
|
93
|
-
response.body = data[key_id]
|
94
|
-
end
|
95
|
-
else
|
96
|
-
Excon::Response.new.tap do |response|
|
97
|
-
response.status = 403
|
98
|
-
end
|
99
|
-
end
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
module Utils
|
104
|
-
def configure_uri_options(options = {})
|
105
|
-
@host = options[:host] || 'localhost'
|
106
|
-
@persistent = options[:persistent] || true
|
107
|
-
@port = options[:port] || 8080
|
108
|
-
@scheme = options[:scheme] || 'http'
|
109
|
-
end
|
110
|
-
|
111
|
-
def riakcs_uri
|
112
|
-
"#{@scheme}://#{@host}:#{@port}"
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
extend Fog::Provider
|
117
|
-
|
118
|
-
service(:provisioning, 'Provisioning')
|
119
|
-
service(:usage, 'Usage')
|
120
|
-
end
|
121
|
-
end
|
@@ -1,98 +0,0 @@
|
|
1
|
-
require 'fog/riakcs/core'
|
2
|
-
|
3
|
-
module Fog
|
4
|
-
module RiakCS
|
5
|
-
class Provisioning < Fog::Service
|
6
|
-
class UserAlreadyExists < Fog::RiakCS::Provisioning::Error; end
|
7
|
-
class ServiceUnavailable < Fog::RiakCS::Provisioning::Error; end
|
8
|
-
|
9
|
-
requires :riakcs_access_key_id, :riakcs_secret_access_key
|
10
|
-
recognizes :host, :path, :port, :scheme, :persistent, :path_style
|
11
|
-
|
12
|
-
request_path 'fog/riakcs/requests/provisioning'
|
13
|
-
request :create_user
|
14
|
-
request :update_user
|
15
|
-
request :disable_user
|
16
|
-
request :enable_user
|
17
|
-
request :list_users
|
18
|
-
request :get_user
|
19
|
-
request :regrant_secret
|
20
|
-
|
21
|
-
class Mock
|
22
|
-
include Utils
|
23
|
-
|
24
|
-
def self.data
|
25
|
-
@data ||= Hash.new({})
|
26
|
-
end
|
27
|
-
|
28
|
-
def self.reset
|
29
|
-
@data = nil
|
30
|
-
end
|
31
|
-
|
32
|
-
def initialize(options = {})
|
33
|
-
configure_uri_options(options)
|
34
|
-
end
|
35
|
-
|
36
|
-
def data
|
37
|
-
self.class.data[riakcs_uri]
|
38
|
-
end
|
39
|
-
|
40
|
-
def reset_data
|
41
|
-
self.class.data.delete(riakcs_uri)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
class Real
|
46
|
-
include Utils
|
47
|
-
|
48
|
-
def initialize(options = {})
|
49
|
-
configure_uri_options(options)
|
50
|
-
@riakcs_access_key_id = options[:riakcs_access_key_id]
|
51
|
-
@riakcs_secret_access_key = options[:riakcs_secret_access_key]
|
52
|
-
@connection_options = options[:connection_options] || {}
|
53
|
-
@persistent = options[:persistent] || false
|
54
|
-
@path_style = options[:path_style] || false
|
55
|
-
|
56
|
-
@raw_connection = Fog::XML::Connection.new(riakcs_uri, @persistent, @connection_options)
|
57
|
-
|
58
|
-
@s3_connection = Fog::Storage.new(
|
59
|
-
:provider => 'AWS',
|
60
|
-
:aws_access_key_id => @riakcs_access_key_id,
|
61
|
-
:aws_secret_access_key => @riakcs_secret_access_key,
|
62
|
-
:host => @host,
|
63
|
-
:port => @port,
|
64
|
-
:scheme => @scheme,
|
65
|
-
:path_style => @path_style,
|
66
|
-
:connection_options => @connection_options
|
67
|
-
)
|
68
|
-
end
|
69
|
-
|
70
|
-
def request(params, parse_response = true, &block)
|
71
|
-
begin
|
72
|
-
response = @raw_connection.request(params.merge({
|
73
|
-
:host => @host,
|
74
|
-
:path => "#{@path}/#{params[:path]}",
|
75
|
-
}), &block)
|
76
|
-
rescue Excon::Errors::HTTPStatusError => error
|
77
|
-
if match = error.message.match(/<Code>(.*?)<\/Code>(?:.*<Message>(.*?)<\/Message>)?/m)
|
78
|
-
case match[1]
|
79
|
-
when 'UserAlreadyExists'
|
80
|
-
raise Fog::RiakCS::Provisioning.const_get(match[1]).new
|
81
|
-
when 'ServiceUnavailable'
|
82
|
-
raise Fog::RiakCS::Provisioning.const_get(match[1]).new
|
83
|
-
else
|
84
|
-
raise error
|
85
|
-
end
|
86
|
-
else
|
87
|
-
raise error
|
88
|
-
end
|
89
|
-
end
|
90
|
-
if !response.body.empty? && parse_response
|
91
|
-
response.body = Fog::JSON.decode(response.body)
|
92
|
-
end
|
93
|
-
response
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
@@ -1,77 +0,0 @@
|
|
1
|
-
module Fog
|
2
|
-
module RiakCS
|
3
|
-
class Provisioning
|
4
|
-
class Real
|
5
|
-
def create_user(email, name, options = {})
|
6
|
-
payload = Fog::JSON.encode({ :email => email, :name => name })
|
7
|
-
headers = { 'Content-Type' => 'application/json' }
|
8
|
-
|
9
|
-
if(options[:anonymous])
|
10
|
-
request(
|
11
|
-
:expects => [201],
|
12
|
-
:method => 'POST',
|
13
|
-
:path => 'user',
|
14
|
-
:body => payload,
|
15
|
-
:headers => headers
|
16
|
-
)
|
17
|
-
else
|
18
|
-
begin
|
19
|
-
response = @s3_connection.put_object('riak-cs', 'user', payload, headers)
|
20
|
-
if !response.body.empty?
|
21
|
-
case response.headers['Content-Type']
|
22
|
-
when 'application/json'
|
23
|
-
response.body = Fog::JSON.decode(response.body)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
response
|
27
|
-
rescue Excon::Errors::Conflict => e
|
28
|
-
raise Fog::RiakCS::Provisioning::UserAlreadyExists.new
|
29
|
-
rescue Excon::Errors::BadRequest => e
|
30
|
-
raise Fog::RiakCS::Provisioning::ServiceUnavailable.new
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
class Mock
|
37
|
-
def invalid_email?(email)
|
38
|
-
!email.include?('@')
|
39
|
-
end
|
40
|
-
|
41
|
-
def user_exists?(email)
|
42
|
-
data.find do |key, value|
|
43
|
-
value[:email] == email
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
def create_user(email, name, options = {})
|
48
|
-
if invalid_email?(email)
|
49
|
-
raise Fog::RiakCS::Provisioning::ServiceUnavailable, "The email address you provided is not a valid."
|
50
|
-
end
|
51
|
-
|
52
|
-
if user_exists?(email)
|
53
|
-
raise Fog::RiakCS::Provisioning::UserAlreadyExists, "User with email #{email} already exists."
|
54
|
-
end
|
55
|
-
|
56
|
-
key_id = rand(1000).to_s
|
57
|
-
key_secret = rand(1000).to_s
|
58
|
-
data[key_id] = { :email => email, :name => name, :status => 'enabled', :key_secret => key_secret }
|
59
|
-
|
60
|
-
Excon::Response.new.tap do |response|
|
61
|
-
response.status = 200
|
62
|
-
response.headers['Content-Type'] = 'application/json'
|
63
|
-
response.body = {
|
64
|
-
"email" => data[:email],
|
65
|
-
"display_name" => data[:name],
|
66
|
-
"name" => "user123",
|
67
|
-
"key_id" => key_id,
|
68
|
-
"key_secret" => key_secret,
|
69
|
-
"id" => "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
|
70
|
-
"status" => "enabled"
|
71
|
-
}
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
module Fog
|
2
|
-
module RiakCS
|
3
|
-
class Provisioning
|
4
|
-
class Real
|
5
|
-
include Utils
|
6
|
-
include UserUtils
|
7
|
-
include MultipartUtils
|
8
|
-
|
9
|
-
def disable_user(key_id)
|
10
|
-
update_riakcs_user(key_id, { :status => 'disabled' })
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
class Mock
|
15
|
-
include UserUtils
|
16
|
-
|
17
|
-
def disable_user(key_id)
|
18
|
-
update_mock_user(key_id, { :status => 'disabled' })
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
module Fog
|
2
|
-
module RiakCS
|
3
|
-
class Provisioning
|
4
|
-
class Real
|
5
|
-
include Utils
|
6
|
-
include UserUtils
|
7
|
-
include MultipartUtils
|
8
|
-
|
9
|
-
def enable_user(key_id)
|
10
|
-
update_riakcs_user(key_id, { :status => 'enabled' })
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
class Mock
|
15
|
-
include UserUtils
|
16
|
-
|
17
|
-
def enable_user(key_id)
|
18
|
-
update_mock_user(key_id, { :status => 'enabled' })
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|