Class: Fog::SharedFileSystem::OpenStack::Mock

Inherits:
Object
  • Object
show all
Defined in:
lib/fog/shared_file_system/openstack.rb,
lib/fog/shared_file_system/openstack/requests/get_quota.rb,
lib/fog/shared_file_system/openstack/requests/get_share.rb,
lib/fog/shared_file_system/openstack/requests/get_limits.rb,
lib/fog/shared_file_system/openstack/requests/list_shares.rb,
lib/fog/shared_file_system/openstack/requests/create_share.rb,
lib/fog/shared_file_system/openstack/requests/delete_share.rb,
lib/fog/shared_file_system/openstack/requests/extend_share.rb,
lib/fog/shared_file_system/openstack/requests/get_snapshot.rb,
lib/fog/shared_file_system/openstack/requests/shrink_share.rb,
lib/fog/shared_file_system/openstack/requests/update_quota.rb,
lib/fog/shared_file_system/openstack/requests/update_share.rb,
lib/fog/shared_file_system/openstack/requests/list_snapshots.rb,
lib/fog/shared_file_system/openstack/requests/create_snapshot.rb,
lib/fog/shared_file_system/openstack/requests/delete_snapshot.rb,
lib/fog/shared_file_system/openstack/requests/update_snapshot.rb,
lib/fog/shared_file_system/openstack/requests/get_share_network.rb,
lib/fog/shared_file_system/openstack/requests/grant_share_access.rb,
lib/fog/shared_file_system/openstack/requests/list_shares_detail.rb,
lib/fog/shared_file_system/openstack/requests/list_share_networks.rb,
lib/fog/shared_file_system/openstack/requests/revoke_share_access.rb,
lib/fog/shared_file_system/openstack/requests/create_share_network.rb,
lib/fog/shared_file_system/openstack/requests/delete_share_network.rb,
lib/fog/shared_file_system/openstack/requests/get_security_service.rb,
lib/fog/shared_file_system/openstack/requests/update_share_network.rb,
lib/fog/shared_file_system/openstack/requests/list_snapshots_detail.rb,
lib/fog/shared_file_system/openstack/requests/list_security_services.rb,
lib/fog/shared_file_system/openstack/requests/create_security_service.rb,
lib/fog/shared_file_system/openstack/requests/delete_security_service.rb,
lib/fog/shared_file_system/openstack/requests/list_availability_zones.rb,
lib/fog/shared_file_system/openstack/requests/list_share_access_rules.rb,
lib/fog/shared_file_system/openstack/requests/update_security_service.rb,
lib/fog/shared_file_system/openstack/requests/get_share_export_location.rb,
lib/fog/shared_file_system/openstack/requests/list_share_networks_detail.rb,
lib/fog/shared_file_system/openstack/requests/list_share_export_locations.rb,
lib/fog/shared_file_system/openstack/requests/list_security_services_detail.rb,
lib/fog/shared_file_system/openstack/requests/add_security_service_to_share_network.rb,
lib/fog/shared_file_system/openstack/requests/remove_security_service_from_share_network.rb

Overview

rubocop:disable LineLength, Metrics/MethodLength, Metrics/ClassLength, Metrics/AbcSize

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Mock

Returns a new instance of Mock.



303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
# File 'lib/fog/shared_file_system/openstack.rb', line 303

def initialize(options = {})
  @openstack_username = options[:openstack_username]
  @openstack_tenant   = options[:openstack_tenant]
  @openstack_auth_uri = URI.parse(options[:openstack_auth_url])

  @auth_token = Fog::Mock.random_base64(64)
  @auth_token_expiration = (Time.now.utc + 86400).iso8601

  management_url = URI.parse(options[:openstack_auth_url])
  management_url.port = 8786
  management_url.path = '/v2'
  @openstack_management_url = management_url.to_s

  @data ||= {:users => {}}
  unless @data[:users].detect { |u| u['name'] == options[:openstack_username] }
    id = Fog::Mock.random_numbers(6).to_s
    @data[:users][id] = {
      'id'       => id,
      'name'     => options[:openstack_username],
      'email'    => "#{options[:openstack_username]}@mock.com",
      'tenantId' => Fog::Mock.random_numbers(6).to_s,
      'enabled'  => true
    }
  end
end

Class Method Details

.dataObject



86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
# File 'lib/fog/shared_file_system/openstack.rb', line 86

def self.data
  @data ||= Hash.new do |hash, key|
    hash[key] = {
      :shares                   => [
        {
          "id"    => "d94a8548-2079-4be0-b21c-0a887acd31ca",
          "links" => [
            {
              "href" => "http://172.18.198.54:8786/v1/16e1ab15c35a457e9c2b2aa189f544e1/shares/d94a8548-2079-4be0-b21c-0a887acd31ca",
              "rel"  => "self"
            },
            {
              "href" => "http://172.18.198.54:8786/16e1ab15c35a457e9c2b2aa189f544e1/shares/d94a8548-2079-4be0-b21c-0a887acd31ca",
              "rel"  => "bookmark"
            }
          ],
          "name"  => "My_share"
        },
        {
          "id"    => "406ea93b-32e9-4907-a117-148b3945749f",
          "links" => [
            {
              "href" => "http://172.18.198.54:8786/v1/16e1ab15c35a457e9c2b2aa189f544e1/shares/406ea93b-32e9-4907-a117-148b3945749f",
              "rel"  => "self"
            },
            {
              "href" => "http://172.18.198.54:8786/16e1ab15c35a457e9c2b2aa189f544e1/shares/406ea93b-32e9-4907-a117-148b3945749f",
              "rel"  => "bookmark"
            }
          ],
          "name"  => "Share1"
        }
      ],
      :shares_detail            => [
        {
          "links"                       => [
            {
              "href" => "http://172.18.198.54:8786/v2/16e1ab15c35a457e9c2b2aa189f544e1/shares/f45cc5b2-d1bb-4a3e-ba5b-5c4125613adc",
              "rel"  => "self"
            },
            {
              "href" => "http://172.18.198.54:8786/16e1ab15c35a457e9c2b2aa189f544e1/shares/f45cc5b2-d1bb-4a3e-ba5b-5c4125613adc",
              "rel"  => "bookmark"
            }
          ],
          "availability_zone"           => "nova",
          "share_network_id"            => "f9b2e754-ac01-4466-86e1-5c569424754e",
          "export_locations"            => [],
          "share_server_id"             => "87d8943a-f5da-47a4-b2f2-ddfa6794aa82",
          "snapshot_id"                 => '',
          "id"                          => "f45cc5b2-d1bb-4a3e-ba5b-5c4125613adc",
          "size"                        => 1,
          "share_type"                  => "25747776-08e5-494f-ab40-a64b9d20d8f7",
          "share_type_name"             => "default",
          "export_location"             => '',
          "consistency_group_id"        => "9397c191-8427-4661-a2e8-b23820dc01d4",
          "project_id"                  => "16e1ab15c35a457e9c2b2aa189f544e1",
          "metadata"                    => {},
          "status"                      => "available",
          "access_rules_status"         => "active",
          "description"                 => "There is a share description.",
          "host"                        => "manila2@generic1#GENERIC1",
          "task_state"                  => '',
          "is_public"                   => 'true',
          "snapshot_support"            => 'true',
          "name"                        => "my_share4",
          "has_replicas"                => 'false',
          "replication_type"            => '',
          "created_at"                  => "2015-09-16T18:19:50.000000",
          "share_proto"                 => "NFS",
          "volume_type"                 => "default",
          "source_cgsnapshot_member_id" => ''
        }
      ],
      :share_networks           => [
        {
          "id"   => "32763294-e3d4-456a-998d-60047677c2fb",
          "name" => "net_my1"
        },
        {
          "id"   => "713df749-aac0-4a54-af52-10f6c991e80c",
          "name" => "net_my"
        }
      ],
      :share_networks_detail    => [
        {
          "name"              => "net_my1",
          "segmentation_id"   => '',
          "created_at"        => "2015-09-04T14:57:13.000000",
          "neutron_subnet_id" => "53482b62-2c84-4a53-b6ab-30d9d9800d06",
          "updated_at"        => '',
          "id"                => "32763294-e3d4-456a-998d-60047677c2fb",
          "neutron_net_id"    => "998b42ee-2cee-4d36-8b95-67b5ca1f2109",
          "ip_version"        => '',
          "nova_net_id"       => '',
          "cidr"              => '',
          "project_id"        => "16e1ab15c35a457e9c2b2aa189f544e1",
          "network_type"      => '',
          "description"       => "descr"
        }
      ],
      :snapshots                => [
        {
          "id"    => "086a1aa6-c425-4ecd-9612-391a3b1b9375",
          "links" => [
            {
              "href" => "http://172.18.198.54:8786/v1/16e1ab15c35a457e9c2b2aa189f544e1/snapshots/086a1aa6-c425-4ecd-9612-391a3b1b9375",
              "rel"  => "self"
            },
            {
              "href" => "http://172.18.198.54:8786/16e1ab15c35a457e9c2b2aa189f544e1/snapshots/086a1aa6-c425-4ecd-9612-391a3b1b9375",
              "rel"  => "bookmark"
            }
          ],
          "name"  => "snapshot_My_share"
        }
      ],
      :security_services_detail => [
        {
          "status"      => "new",
          "domain"      => "",
          "project_id"  => "16e1ab15c35a457e9c2b2aa189f544e1",
          "name"        => "SecServ1",
          "created_at"  => "2015-09-07T12:19:10.000000",
          "updated_at"  => "",
          "server"      => "",
          "dns_ip"      => "10.0.0.0/24",
          "user"        => "demo",
          "password"    => "supersecret",
          "type"        => "kerberos",
          "id"          => "3c829734-0679-4c17-9637-801da48c0d5f",
          "description" => "Creating my first Security Service"
        }
      ],
      :security_services        => [
        {
          "status" => "new",
          "type"   => "ldap",
          "id"     => "5a1d3a12-34a7-4087-8983-50e9ed03509a",
          "name"   => "SecServ2"
        }
      ],
      :availability_zones => [
          {
              "name"        => "nova",
              "created_at"  => "2015-09-18T09:50:55.000000",
              "updated_at"  => nil,
              "id"          => "388c983d-258e-4a0e-b1ba-10da37d766db"
          }
      ],
      :snapshots_detail      => [
        {
          "status"      => "available",
          "share_id"    => "d94a8548-2079-4be0-b21c-0a887acd31ca",
          "name"        => "snapshot_My_share",
          "links"       => [
            {
              "href" => "http://172.18.198.54:8786/v1/16e1ab15c35a457e9c2b2aa189f544e1/snapshots/086a1aa6-c425-4ecd-9612-391a3b1b9375",
              "rel"  => "self"
            },
            {
              "href" => "http://172.18.198.54:8786/16e1ab15c35a457e9c2b2aa189f544e1/snapshots/086a1aa6-c425-4ecd-9612-391a3b1b9375",
              "rel"  => "bookmark"
            }
          ],
          "created_at"  => "2015-09-07T11:55:09.000000",
          "description" => "Here is a snapshot of share My_share",
          "share_proto" => "NFS",
          "share_size"  => 1,
          "id"          => "086a1aa6-c425-4ecd-9612-391a3b1b9375",
          "size"        => 1
        }
      ],
      :export_locations         => [
        {
          "path"              => "10.254.0.3:/shares/share-e1c2d35e-fe67-4028-ad7a-45f668732b1d",
          "share_instance_id" => "e1c2d35e-fe67-4028-ad7a-45f668732b1d",
          "is_admin_only"     => false,
          "id"                => "b6bd76ce-12a2-42a9-a30a-8a43b503867d",
          "preferred"         => false
        },
        {
          "path"              => "10.0.0.3:/shares/share-e1c2d35e-fe67-4028-ad7a-45f668732b1d",
          "share_instance_id" => "e1c2d35e-fe67-4028-ad7a-45f668732b1d",
          "is_admin_only"     => true,
          "id"                => "6921e862-88bc-49a5-a2df-efeed9acd583",
          "preferred"         => false
        }
      ],
      :access_rules             => [
        {
          "share_id"     => "406ea93b-32e9-4907-a117-148b3945749f",
          "created_at"   => "2015-09-07T09:14:48.000000",
          "updated_at"   => '',
          "access_type"  => "ip",
          "access_to"    => "0.0.0.0/0",
          "access_level" => "rw",
          "access_key"   => '',
          "id"           => "a25b2df3-90bd-4add-afa6-5f0dbbd50452"
        }
      ],
      :quota                    => {
        "gigabytes"          => 1000,
        "shares"             => 50,
        "snapshot_gigabytes" => 1000,
        "snapshots"          => 50,
        "share_networks"     => 10,
        "id"                 => "16e1ab15c35a457e9c2b2aa189f544e1"
      }
    }
  end
end

.resetObject



299
300
301
# File 'lib/fog/shared_file_system/openstack.rb', line 299

def self.reset
  @data = nil
end

Instance Method Details

#add_security_service_to_share_network(_security_service_id, share_network_id) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/fog/shared_file_system/openstack/requests/add_security_service_to_share_network.rb', line 16

def add_security_service_to_share_network(_security_service_id, share_network_id)
  response = Excon::Response.new
  response.status = 200

  share_net = data[:share_network_updated] || data[:share_networks].first
  share_net['id'] = share_network_id
  response.body = {'share_network' => share_net}
  response
end

#create_security_service(type, name, options = {}) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/fog/shared_file_system/openstack/requests/create_security_service.rb', line 29

def create_security_service(type, name, options = {})
  # stringify keys
  options = Hash[options.map { |k, v| [k.to_s, v] }]

  response = Excon::Response.new
  response.status = 200

  security_service = data[:security_services_detail].first.dup

  security_service['type'] = type
  security_service['name'] = name

  response.body = {'security_service' => security_service.merge(options)}
  response
end

#create_share(protocol, size, options = {}) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/fog/shared_file_system/openstack/requests/create_share.rb', line 30

def create_share(protocol, size, options = {})
  # stringify keys
  options = Hash[options.map { |k, v| [k.to_s, v] }]

  response = Excon::Response.new
  response.status = 200

  share = data[:shares_detail].first.dup

  share['share_proto'] = protocol
  share['size']        = size
  share['status']      = 'creating'

  response.body = {'share' => share.merge(options)}
  response
end

#create_share_network(options = {}) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/fog/shared_file_system/openstack/requests/create_share_network.rb', line 26

def create_share_network(options = {})
  # stringify keys
  options = Hash[options.map { |k, v| [k.to_s, v] }]

  response = Excon::Response.new
  response.status = 200

  share_net = data[:share_networks_detail].first.dup

  response.body = {'share_networks' => share_net.merge(options)}
  response
end

#create_snapshot(share_id, options = {}) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/fog/shared_file_system/openstack/requests/create_snapshot.rb', line 28

def create_snapshot(share_id, options = {})
  # stringify keys
  options = Hash[options.map { |k, v| [k.to_s, v] }]

  response = Excon::Response.new
  response.status = 202

  snapshot = data[:snapshots_detail].first.dup

  snapshot['share_id'] = share_id
  snapshot['status']   = 'creating'

  response.body = {'snapshot' => snapshot.merge(options)}
  response
end

#credentialsObject



337
338
339
340
341
342
343
# File 'lib/fog/shared_file_system/openstack.rb', line 337

def credentials
  {:provider                 => 'openstack',
   :openstack_auth_url       => @openstack_auth_uri.to_s,
   :openstack_auth_token     => @auth_token,
   :openstack_region         => @openstack_region,
   :openstack_management_url => @openstack_management_url}
end

#dataObject



329
330
331
# File 'lib/fog/shared_file_system/openstack.rb', line 329

def data
  self.class.data[@openstack_username]
end

#delete_security_service(_id) ⇒ Object



15
16
17
18
19
20
# File 'lib/fog/shared_file_system/openstack/requests/delete_security_service.rb', line 15

def delete_security_service(_id)
  response = Excon::Response.new
  response.status = 202

  response
end

#delete_share(id) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/fog/shared_file_system/openstack/requests/delete_share.rb', line 15

def delete_share(id)
  response = Excon::Response.new
  response.status = 202

  share                  = data[:share_updated] || data[:shares_detail].first.dup
  share['id']            = id
  share['links']['self'] = "https://127.0.0.1:8786/v2/shares/#{id}"

  response.body = {'share' => share}
  response
end

#delete_share_network(id) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/fog/shared_file_system/openstack/requests/delete_share_network.rb', line 15

def delete_share_network(id)
  response = Excon::Response.new
  response.status = 202

  share_net       = data[:share_net_updated] || data[:share_networks_detail].first.dup
  share_net['id'] = id

  response.body = {'share_network' => share_net}
  response
end

#delete_snapshot(id) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/fog/shared_file_system/openstack/requests/delete_snapshot.rb', line 15

def delete_snapshot(id)
  response = Excon::Response.new
  response.status = 202

  snapshot                  = data[:snapshot_updated] || data[:snapshots_detail].first.dup
  snapshot['id']            = id
  snapshot['status']        = 'deleting'
  snapshot['links']['self'] = "https://127.0.0.1:8786/v2/snapshots/#{id}"

  response.body = {'snapshot' => snapshot}
  response
end

#extend_share(_share_id, _new_size) ⇒ Object



16
17
18
19
20
# File 'lib/fog/shared_file_system/openstack/requests/extend_share.rb', line 16

def extend_share(, _new_size)
  response = Excon::Response.new
  response.status = 202
  response
end

#get_limitsObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/fog/shared_file_system/openstack/requests/get_limits.rb', line 15

def get_limits
  absolute_limits = {
    # Max
    'maxTotalShareGigabytes'     => 1000,
    'maxTotalShareNetworks'      => 10,
    'maxTotalShares'             => 50,
    'maxTotalSnapshotGigabytes'  => 1000,
    'maxTotalShareSnapshots'     => 50,

    # Used
    'totalShareNetworksUsed'     => 0,
    'totalSharesUsed'            => 0,
    'totalShareGigabytesUsed'    => 0,
    'totalShareSnapshotsUsed'    => 0,
    'totalSnapshotGigabytesUsed' => 0
  }

  Excon::Response.new(
    :status => 200,
    :body   => {
      'limits' => {
        'rate'     => [],
        'absolute' => absolute_limits
      }
    }
  )
end

#get_quota(project_id) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/fog/shared_file_system/openstack/requests/get_quota.rb', line 15

def get_quota(project_id)
  response = Excon::Response.new
  response.status = 200
  quota_data = data[:quota_updated] || data[:quota]
  quota_data['id'] = project_id
  response.body = {'quota_set' => quota_data}
  response
end

#get_security_service(id) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/fog/shared_file_system/openstack/requests/get_security_service.rb', line 15

def get_security_service(id)
  response = Excon::Response.new
  response.status = 200
  security_service = data[:security_service_updated] || data[:security_services_detail].first
  security_service['id'] = id
  response.body = {'security_service' => security_service}
  response
end

#get_share(id) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/fog/shared_file_system/openstack/requests/get_share.rb', line 15

def get_share(id)
  response = Excon::Response.new
  response.status = 200
  share = data[:share_updated] || data[:shares_detail].first
  share['id'] = id
  response.body = share
  response
end

#get_share_export_location(id) ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/fog/shared_file_system/openstack/requests/get_share_export_location.rb', line 18

def get_share_export_location(id)
  response = Excon::Response.new
  response.status = 200
  share_export_location = data[:export_locations].first
  share_export_location['id'] = id
  response.body = share_export_location
  response
end

#get_share_network(id) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/fog/shared_file_system/openstack/requests/get_share_network.rb', line 15

def get_share_network(id)
  response = Excon::Response.new
  response.status = 200
  share_net = data[:share_network_updated] || data[:share_networks].first
  share_net['id'] = id
  response.body = {'share_network' => share_net}
  response
end

#get_snapshot(id) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/fog/shared_file_system/openstack/requests/get_snapshot.rb', line 15

def get_snapshot(id)
  response = Excon::Response.new
  response.status = 200
  snapshot = data[:snapshot_updated] || data[:snapshots_detail].first
  snapshot['id'] = id
  response.body = snapshot
  response
end

#grant_share_access(share_id, access_to, access_type, access_level) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/fog/shared_file_system/openstack/requests/grant_share_access.rb', line 18

def grant_share_access(share_id, access_to, access_type, access_level)
  response = Excon::Response.new
  response.status = 200

  access                = data[:access_rules].first
  access[:share_id]     = share_id
  access[:access_level] = access_level
  access[:access_type]  = access_type
  access[:access_to]    = access_to

  response.body = {'access' => access}
  response
end

#list_availability_zonesObject



15
16
17
18
19
20
# File 'lib/fog/shared_file_system/openstack/requests/list_availability_zones.rb', line 15

def list_availability_zones()
  response = Excon::Response.new
  response.status = 200
  response.body = {'availability_zones' => data[:availability_zones]}
  response
end

#list_security_services(_options = {}) ⇒ Object



16
17
18
19
20
21
# File 'lib/fog/shared_file_system/openstack/requests/list_security_services.rb', line 16

def list_security_services(_options = {})
  response = Excon::Response.new
  response.status = 200
  response.body = {'security_services' => data[:security_services]}
  response
end

#list_security_services_detail(_options = {}) ⇒ Object



16
17
18
19
20
21
# File 'lib/fog/shared_file_system/openstack/requests/list_security_services_detail.rb', line 16

def list_security_services_detail(_options = {})
  response = Excon::Response.new
  response.status = 200
  response.body = {'security_services' => data[:security_services_detail]}
  response
end

#list_share_access_rules(share_id) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/fog/shared_file_system/openstack/requests/list_share_access_rules.rb', line 14

def list_share_access_rules(share_id)
  response = Excon::Response.new
  response.status = 200

  rules = data[:access_rules]
  rules.each do |rule|
    rule[:share_id] = share_id
  end

  response.body = {'access_list' => rules}
  response
end

#list_share_export_locations(share_id) ⇒ Object



18
19
20
21
22
23
# File 'lib/fog/shared_file_system/openstack/requests/list_share_export_locations.rb', line 18

def list_share_export_locations(share_id)
  response = Excon::Response.new
  response.status = 200
  response.body = {'export_locations' => data[:export_locations]}
  response
end

#list_share_networks(_options = {}) ⇒ Object



16
17
18
19
20
21
# File 'lib/fog/shared_file_system/openstack/requests/list_share_networks.rb', line 16

def list_share_networks(_options = {})
  response = Excon::Response.new
  response.status = 200
  response.body = {'share_networks' => data[:share_networks]}
  response
end

#list_share_networks_detail(_options = {}) ⇒ Object



16
17
18
19
20
21
# File 'lib/fog/shared_file_system/openstack/requests/list_share_networks_detail.rb', line 16

def list_share_networks_detail(_options = {})
  response = Excon::Response.new
  response.status = 200
  response.body = {'share_networks' => data[:share_networks_detail]}
  response
end

#list_shares(_options = {}) ⇒ Object



16
17
18
19
20
21
# File 'lib/fog/shared_file_system/openstack/requests/list_shares.rb', line 16

def list_shares(_options = {})
  response = Excon::Response.new
  response.status = 200
  response.body = {'shares' => data[:shares]}
  response
end

#list_shares_detail(_options = {}) ⇒ Object



16
17
18
19
20
21
# File 'lib/fog/shared_file_system/openstack/requests/list_shares_detail.rb', line 16

def list_shares_detail(_options = {})
  response = Excon::Response.new
  response.status = 200
  response.body = {'shares' => data[:shares_detail]}
  response
end

#list_snapshots(_options = {}) ⇒ Object



16
17
18
19
20
21
# File 'lib/fog/shared_file_system/openstack/requests/list_snapshots.rb', line 16

def list_snapshots(_options = {})
  response = Excon::Response.new
  response.status = 200
  response.body = {'snapshots' => data[:snapshots]}
  response
end

#list_snapshots_detail(_options = {}) ⇒ Object



16
17
18
19
20
21
# File 'lib/fog/shared_file_system/openstack/requests/list_snapshots_detail.rb', line 16

def list_snapshots_detail(_options = {})
  response = Excon::Response.new
  response.status = 200
  response.body = {'snapshots' => data[:snapshots_detail]}
  response
end

#remove_security_service_from_share_network(_security_service_id, share_network_id) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/fog/shared_file_system/openstack/requests/remove_security_service_from_share_network.rb', line 16

def remove_security_service_from_share_network(_security_service_id, share_network_id)
  response = Excon::Response.new
  response.status = 200

  share_net = data[:share_network_updated] || data[:share_networks].first
  share_net['id'] = share_network_id
  response.body = {'share_network' => share_net}
  response
end

#reset_dataObject



333
334
335
# File 'lib/fog/shared_file_system/openstack.rb', line 333

def reset_data
  self.class.data.delete(@openstack_username)
end

#revoke_share_access(_share_id, _access_id) ⇒ Object



16
17
18
19
20
# File 'lib/fog/shared_file_system/openstack/requests/revoke_share_access.rb', line 16

def revoke_share_access(, _access_id)
  response = Excon::Response.new
  response.status = 202
  response
end

#shrink_share(_share_id, _new_size) ⇒ Object



16
17
18
19
20
# File 'lib/fog/shared_file_system/openstack/requests/shrink_share.rb', line 16

def shrink_share(, _new_size)
  response = Excon::Response.new
  response.status = 202
  response
end

#update_quota(project_id, options = {}) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/fog/shared_file_system/openstack/requests/update_quota.rb', line 16

def update_quota(project_id, options = {})
  # stringify keys
  options = Hash[options.map { |k, v| [k.to_s, v] }]
  data[:quota_updated] = data[:quota].merge(options)
  data[:quota_updated]['id'] = project_id

  response = Excon::Response.new
  response.status = 200
  response.body = {'quota_set' => data[:quota_updated]}
  response
end

#update_security_service(id, options = {}) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/fog/shared_file_system/openstack/requests/update_security_service.rb', line 16

def update_security_service(id, options = {})
  # stringify keys
  options = Hash[options.map { |k, v| [k.to_s, v] }]

  data[:security_service_updated]       = data[:security_services_detail].first.merge(options)
  data[:security_service_updated]['id'] = id

  response = Excon::Response.new
  response.status = 200
  response.body = {'security_service' => data[:security_service_updated]}
  response
end

#update_share(id, options = {}) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/fog/shared_file_system/openstack/requests/update_share.rb', line 16

def update_share(id, options = {})
  # stringify keys
  options = Hash[options.map { |k, v| [k.to_s, v] }]

  update_data(id, options)

  response = Excon::Response.new
  response.status = 200
  response.body = {'share' => data[:share_updated]}
  response
end

#update_share_network(id, options = {}) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/fog/shared_file_system/openstack/requests/update_share_network.rb', line 16

def update_share_network(id, options = {})
  # stringify keys
  options = Hash[options.map { |k, v| [k.to_s, v] }]

  data[:share_net_updated]       = data[:share_networks_detail].first.merge(options)
  data[:share_net_updated]['id'] = id

  response = Excon::Response.new
  response.status = 200
  response.body = {'share_network' => data[:share_net_updated]}
  response
end

#update_snapshot(id, options = {}) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/fog/shared_file_system/openstack/requests/update_snapshot.rb', line 16

def update_snapshot(id, options = {})
  # stringify keys
  options = Hash[options.map { |k, v| [k.to_s, v] }]

  data[:snapshot_updated]       = data[:snapshots_detail].first.merge(options)
  data[:snapshot_updated]['id'] = id

  response = Excon::Response.new
  response.status = 200
  response.body = {'snapshot' => data[:snapshot_updated]}
  response
end