Class: Fog::Network::Softlayer::Mock

Inherits:
Object
  • Object
show all
Defined in:
lib/fog/softlayer/network.rb,
lib/fog/softlayer/requests/network/get_subnet.rb,
lib/fog/softlayer/requests/network/get_network.rb,
lib/fog/softlayer/requests/network/list_subnets.rb,
lib/fog/softlayer/requests/network/create_subnet.rb,
lib/fog/softlayer/requests/network/list_networks.rb,
lib/fog/softlayer/requests/network/create_network.rb,
lib/fog/softlayer/requests/network/delete_network.rb,
lib/fog/softlayer/requests/network/get_ip_address.rb,
lib/fog/softlayer/requests/network/get_datacenters.rb,
lib/fog/softlayer/requests/network/route_global_ip.rb,
lib/fog/softlayer/requests/network/get_ip_addresses.rb,
lib/fog/softlayer/requests/network/get_network_tags.rb,
lib/fog/softlayer/requests/network/unroute_global_ip.rb,
lib/fog/softlayer/requests/network/create_network_tags.rb,
lib/fog/softlayer/requests/network/delete_network_tags.rb,
lib/fog/softlayer/requests/network/get_global_ip_address.rb,
lib/fog/softlayer/requests/network/get_global_ip_records.rb,
lib/fog/softlayer/requests/network/get_subnet_package_id.rb,
lib/fog/softlayer/requests/network/get_subnet_price_code.rb,
lib/fog/softlayer/requests/network/get_datacenter_routers.rb,
lib/fog/softlayer/requests/network/delete_global_ip_address.rb,
lib/fog/softlayer/requests/network/get_public_vlan_price_code.rb,
lib/fog/softlayer/requests/network/get_references_by_tag_name.rb,
lib/fog/softlayer/requests/network/get_private_vlan_price_code.rb,
lib/fog/softlayer/requests/network/get_portable_subnet_package_id.rb,
lib/fog/softlayer/requests/network/get_portable_subnet_price_code.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Mock

Returns a new instance of Mock.



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/fog/softlayer/network.rb', line 79

def initialize(options={})
  @softlayer_api_key = options[:softlayer_api_key]
  @softlayer_username = options[:softlayer_username]

  @networks = []
  @datacenters = [
      {"id"=>265592, "longName"=>"Amsterdam 1", "name"=>"ams01"},
      {"id"=>358698, "longName"=>"Ashburn, VA 3", "name"=>"wdc03"},
      {"id"=>3, "longName"=>"Dallas 1", "name"=>"dal01"},
      {"id"=>154770, "longName"=>"Dallas 2", "name"=>"dal02"},
      {"id"=>167092, "longName"=>"Dallas 4", "name"=>"dal04"},
      {"id"=>138124, "longName"=>"Dallas 5", "name"=>"dal05"},
      {"id"=>154820, "longName"=>"Dallas 6", "name"=>"dal06"},
      {"id"=>142776, "longName"=>"Dallas 7", "name"=>"dal07"},
      {"id"=>352494, "longName"=>"Hong Kong 2", "name"=>"hkg02"},
      {"id"=>142775, "longName"=>"Houston 2", "name"=>"hou02"},
      {"id"=>358694, "longName"=>"London 2", "name"=>"lon02"},
      {"id"=>168642, "longName"=>"San Jose 1", "name"=>"sjc01"},
      {"id"=>18171, "longName"=>"Seattle", "name"=>"sea01"},
      {"id"=>224092, "longName"=>"Singapore 1", "name"=>"sng01"},
      {"id"=>448994, "longName"=>"Toronto 1", "name"=>"tor01"},
      {"id"=>37473, "longName"=>"Washington, DC 1", "name"=>"wdc01"}
  ]
  @tags = []
end

Class Method Details

.resetObject

Fog::Mock.random_ip,



75
76
77
# File 'lib/fog/softlayer/network.rb', line 75

def self.reset
  @data = nil
end

Instance Method Details

#create_network(order) ⇒ Object

Raises:

  • (ArgumentError)


13
14
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
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
298
299
300
301
302
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
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
# File 'lib/fog/softlayer/requests/network/create_network.rb', line 13

def create_network(order)
  raise ArgumentError, "Order argument for #{self.class.name}##{__method__} must be Hash." unless order.is_a?(Hash)
  # TODO: make this better, this will never fail...
  @networks << {
    'accountId' => Fog::Softlayer.,
    'id' => Fog::Mock.random_numbers(6).to_i,
    'modifyDate' => Time.now.iso8601,
    'name' => order['name'],
    'networkVrfId' => nil,
    'primarySubnetId' => Fog::Mock.random_numbers(6).to_i,
    'vlanNumber' => Fog::Mock.random_numbers(4).to_i,
    'networkSpace' => 'PRIVATE',
    'primaryRouter' =>
      {
        'bareMetalInstanceFlag' => 0,
        'domain' => 'softlayer.com',
        'fullyQualifiedDomainName' => order['router'] << '.softlayer.com',
        'hostname' => order['router'],
        'id' => order['routerId'],
        'notes' => '',
        'serviceProviderId' => 1,
        'serviceProviderResourceId' => Fog::Mock.random_numbers(6).to_i,
        'datacenter' => {'id' => order['location'], 'longName' => 'Lilliput 4', 'name' => 'llp04'},
        'primaryIpAddress' => Fog::Mock.random_ip
      },
    'subnets' =>
    [
      {
        'broadcastAddress' => Fog::Mock.random_ip,
        'cidr' => 30,
        'gateway' => Fog::Mock.random_ip,
        'id' => Fog::Mock.random_numbers(6).to_i,
        'isCustomerOwned' => false,
        'isCustomerRoutable' => false,
        'modifyDate' => Time.now.iso8601,
        'netmask' => '255.255.255.0',
        'networkIdentifier' => Fog::Mock.random_ip,
        'networkVlanId' => Fog::Mock.random_numbers(6).to_i,
        'sortOrder' => '4',
        'subnetType' => 'PRIMARY',
        'totalIpAddresses' => 4,
        'usableIpAddressCount' => 1,
        'version' => 4
      }
    ],
    'tagReferences' => [],
    'type' =>
    {
      'description' => 'Standard network VLAN',
      'id' => 1,
      'keyName' => 'STANDARD',
      'name' => 'Standard'
    }
  }

  response = Excon::Response.new
  response.status = 200
  response.body = {
      'orderDate' => Time.now.iso8601,
      'orderDetails' =>
          {
              'bigDataOrderFlag' => false,
              'billingInformation' =>
                  {
                      'billingAddressLine1' => '42 Haviture Way.',
                      'billingCity' => 'Glover',
                      'billingCountryCode' => 'US',
                      'billingEmail' => '[email protected]',
                      'billingNameCompany' => 'SLayer\'s Inc.',
                      'billingNameFirst' => 'Mr.',
                      'billingNameLast' => 'Rogers',
                      'billingPhoneVoice' => '123.456.7890',
                      'billingPostalCode' => '90210',
                      'billingState' => 'VT',
                      'cardExpirationMonth' => nil,
                      'cardExpirationYear' => nil,
                      'taxExempt' => 0
                  },
              'billingOrderItemId' => nil,
              'containerSplHash' => '00000000000000000000000000000000',
              'currencyShortName' => 'USD',
              'extendedHardwareTesting' => nil,
              'imageTemplateId' => nil,
              'isManagedOrder' => 0,
              'itemCategoryQuestionAnswers' => [],
              'location' => Fog::Mock.random_numbers(6).to_i,
              'locationObject' =>
                  {
                      'id' => Fog::Mock.random_numbers(6).to_i,
                      'longName' => 'Amsterdam 1',
                      'name' => 'ams01',
                      'activePresaleEvents' => []},
              'packageId' => 0,
              'paymentType' => 'PAYPAL',
              'postTaxRecurring' => '0',
              'postTaxRecurringHourly' => '0',
              'postTaxRecurringMonthly' => '0',
              'postTaxSetup' => '0',
              'preTaxRecurring' => '0',
              'preTaxRecurringHourly' => '0',
              'preTaxRecurringMonthly' => '0',
              'preTaxSetup' => '0',
              'presetId' => nil,
              'prices' =>
                  [
                      {
                          'currentPriceFlag' => nil,
                          'hourlyRecurringFee' => '0',
                          'id' => Fog::Mock.random_numbers(4).to_i,
                          'itemId' => Fog::Mock.random_numbers(4).to_i,
                          'laborFee' => '0',
                          'onSaleFlag' => nil,
                          'oneTimeFee' => '0',
                          'oneTimeFeeTax' => '0',
                          'proratedRecurringFee' => '0',
                          'proratedRecurringFeeTax' => '0',
                          'quantity' => nil,
                          'recurringFee' => '0',
                          'recurringFeeTax' => '0',
                          'setupFee' => '0',
                          'sort' => 0,
                          'categories' =>
                              [
                                  {
                                      'categoryCode' => 'network_vlan',
                                      'id' => 113,
                                      'name' => 'Network Vlan',
                                      'quantityLimit' => 0}],
                          'item' =>
                              {
                                  'capacity' => '0',
                                  'description' => 'Private Network Vlan',
                                  'id' => Fog::Mock.random_numbers(4).to_i,
                                  'softwareDescriptionId' => nil,
                                  'units' => 'N/A',
                                  'upgradeItemId' => nil,
                                  'bundle' => [],
                                  'itemCategory' =>
                                      {
                                          'categoryCode' => 'network_vlan',
                                          'id' => 113,
                                          'name' => 'Network Vlan',
                                          'quantityLimit' => 0}}},
                      {
                          'currentPriceFlag' => nil,
                          'hourlyRecurringFee' => '0',
                          'id' => Fog::Mock.random_numbers(4).to_i,
                          'itemId' => 577,
                          'laborFee' => '0',
                          'onSaleFlag' => nil,
                          'oneTimeFee' => '0',
                          'oneTimeFeeTax' => '0',
                          'proratedRecurringFee' => '0',
                          'proratedRecurringFeeTax' => '0',
                          'quantity' => nil,
                          'recurringFee' => '0',
                          'recurringFeeTax' => '0',
                          'setupFee' => '0',
                          'sort' => 0,
                          'categories' =>
                              [
                                  {
                                      'categoryCode' => 'static_sec_ip_addresses',
                                      'id' => 53,
                                      'name' => 'Public Secondary Static IP Addresses',
                                      'quantityLimit' => 0}],
                          'item' =>
                              {
                                  'capacity' => '4',
                                  'description' => '4 Static Public IP Addresses',
                                  'id' => 577,
                                  'softwareDescriptionId' => nil,
                                  'upgradeItemId' => nil,
                                  'bundle' => [],
                                  'itemCategory' =>
                                      {
                                          'categoryCode' => 'static_sec_ip_addresses',
                                          'id' => 53,
                                          'name' => 'Public Secondary Static IP Addresses',
                                          'quantityLimit' => 0
                                      }
                              }
                      }
                  ],
              'primaryDiskPartitionId' => nil,
              'privateCloudOrderFlag' => false,
              'properties' => [],
              'proratedInitialCharge' => '0',
              'proratedOrderTotal' => '0',
              'quantity' => 1,
              'resourceGroupId' => nil,
              'resourceGroupTemplateId' => nil,
              'sendQuoteEmailFlag' => nil,
              'serverCoreCount' => nil,
              'sourceVirtualGuestId' => nil,
              'sshKeys' => [],
              'stepId' => nil,
              'storageGroups' => [],
              'totalRecurringTax' => '0',
              'totalSetupTax' => '0',
              'useHourlyPricing' => false,
              'id' => nil,
              'name' => 'foobar',
              'router' =>
                  {
                      'bareMetalInstanceFlag' => 0,
                      'domain' => 'softlayer.com',
                      'fullyQualifiedDomainName' => order['router'] << '.softlayer.com',
                      'hostname' => order['router'],
                      'id' => Fog::Mock.random_numbers(6).to_i,
                      'notes' => '',
                      'serviceProviderId' => 1,
                      'serviceProviderResourceId' => Fog::Mock.random_numbers(6).to_i,
                      'datacenter' => {'id' => order['location'], 'longName' => 'Lilliput 4', 'name' => 'llp04'}
                  },
              'routerId' => order['routerId'],
              'vlanNumber' => nil
          },
      'orderId' => Fog::Mock.random_numbers(7).to_i,
      'placedOrder' =>
          {
              'accountId' => Fog::Mock.random_numbers(6).to_i,
              'createDate' => Time.now.iso8601,
              'id' => Fog::Mock.random_numbers(7).to_i,
              'impersonatingUserRecordId' => nil,
              'modifyDate' => nil,
              'orderQuoteId' => nil,
              'orderTypeId' => 4,
              'presaleEventId' => nil,
              'privateCloudOrderFlag' => false,
              'status' => 'PENDING_AUTO_APPROVAL',
              'userRecordId' => Fog::Mock.random_numbers(6).to_i,
              'account' =>
                  {
                      'accountStatusId' => Fog::Mock.random_numbers(4).to_i,
                      'address1' => '4849 Alpha Rd.',
                      'allowedPptpVpnQuantity' => 1,
                      'brandId' => 2,
                      'city' => 'Dallas',
                      'claimedTaxExemptTxFlag' => false,
                      'companyName' => 'SoftLayer Internal - Development Community',
                      'country' => 'US',
                      'createDate' => Time.now.iso8601,
                      'email' => '[email protected]',
                      'firstName' => 'Phil',
                      'id' => Fog::Mock.random_numbers(6).to_i,
                      'isReseller' => 0,
                      'lastName' => 'Jackson',
                      'lateFeeProtectionFlag' => nil,
                      'modifyDate' => Time.now.iso8601,
                      'officePhone' => '281.714.3156',
                      'postalCode' => '75244',
                      'state' => 'TX',
                      'statusDate' => nil,
                      'hardwareCount' => 7,
                      'canOrderAdditionalVlansFlag' => true,
                      'hasPendingOrder' => 3},
              'items' =>
                  [
                      {
                          'categoryCode' => 'network_vlan',
                          'description' => 'Private Network Vlan',
                          'id' => Fog::Mock.random_numbers(8).to_i,
                          'itemId' => Fog::Mock.random_numbers(4).to_i,
                          'itemPriceId' => '2019',
                          'laborFee' => '0',
                          'laborFeeTaxRate' => '.066',
                          'oneTimeFee' => '0',
                          'oneTimeFeeTaxRate' => '.066',
                          'parentId' => nil,
                          'promoCodeId' => nil,
                          'quantity' => nil,
                          'recurringFee' => '0',
                          'setupFee' => '0',
                          'setupFeeDeferralMonths' => 12,
                          'setupFeeTaxRate' => '.066',
                          'bundledItems' => [],
                          'category' =>
                              {
                                  'categoryCode' => 'network_vlan',
                                  'id' => 113,
                                  'name' => 'Network Vlan',
                                  'quantityLimit' => 0},
                          'children' =>
                              [
                                  {
                                      'categoryCode' => 'static_sec_ip_addresses',
                                      'description' => '4 Static Public IP Addresses',
                                      'id' => Fog::Mock.random_numbers(8).to_i,
                                      'itemId' => 577,
                                      'itemPriceId' => '1084',
                                      'laborFee' => '0',
                                      'laborFeeTaxRate' => '.066',
                                      'oneTimeFee' => '0',
                                      'oneTimeFeeTaxRate' => '.066',
                                      'parentId' => Fog::Mock.random_numbers(8).to_i,
                                      'promoCodeId' => nil,
                                      'quantity' => nil,
                                      'recurringFee' => '0',
                                      'setupFee' => '0',
                                      'setupFeeDeferralMonths' => 12,
                                      'setupFeeTaxRate' => '.066',
                                      'bundledItems' => [],
                                      'category' =>
                                          {
                                              'categoryCode' => 'static_sec_ip_addresses',
                                              'id' => 53,
                                              'name' => 'Public Secondary Static IP Addresses',
                                              'quantityLimit' => 0},
                                      'children' => [],
                                      'order' => nil,
                                      'storageGroups' => []
                                  }
                              ],
                          'location' => {'id' => Fog::Mock.random_numbers(6).to_i, 'longName' => 'Amsterdam 1', 'name' => 'ams01'},
                          'order' => nil,
                          'storageGroups' => []},
                      {
                          'categoryCode' => 'static_sec_ip_addresses',
                          'description' => '4 Static Public IP Addresses',
                          'id' => Fog::Mock.random_numbers(8).to_i,
                          'itemId' => 577,
                          'itemPriceId' => '1084',
                          'laborFee' => '0',
                          'laborFeeTaxRate' => '.066',
                          'oneTimeFee' => '0',
                          'oneTimeFeeTaxRate' => '.066',
                          'parentId' => Fog::Mock.random_numbers(8).to_i,
                          'promoCodeId' => nil,
                          'quantity' => nil,
                          'recurringFee' => '0',
                          'setupFee' => '0',
                          'setupFeeDeferralMonths' => 12,
                          'setupFeeTaxRate' => '.066',
                          'bundledItems' => [],
                          'category' =>
                              {
                                  'categoryCode' => 'static_sec_ip_addresses',
                                  'id' => 53,
                                  'name' => 'Public Secondary Static IP Addresses',
                                  'quantityLimit' => 0},
                          'children' => [],
                          'order' => nil,
                          'storageGroups' => []
                      }
                  ],
              'orderTopLevelItems' =>
                  [
                      {
                          'categoryCode' => 'network_vlan',
                          'description' => 'Private Network Vlan',
                          'id' => Fog::Mock.random_numbers(8).to_i,
                          'itemId' => Fog::Mock.random_numbers(4).to_i,
                          'itemPriceId' => '2019',
                          'laborFee' => '0',
                          'laborFeeTaxRate' => '.066',
                          'oneTimeFee' => '0',
                          'oneTimeFeeTaxRate' => '.066',
                          'parentId' => nil,
                          'promoCodeId' => nil,
                          'quantity' => nil,
                          'recurringFee' => '0',
                          'setupFee' => '0',
                          'setupFeeDeferralMonths' => 12,
                          'setupFeeTaxRate' => '.066',
                          'bundledItems' => [],
                          'category' =>
                              {
                                  'categoryCode' => 'network_vlan',
                                  'id' => 113,
                                  'name' => 'Network Vlan',
                                  'quantityLimit' => 0},
                          'children' =>
                              [
                                  {
                                      'categoryCode' => 'static_sec_ip_addresses',
                                      'description' => '4 Static Public IP Addresses',
                                      'id' => Fog::Mock.random_numbers(8).to_i,
                                      'itemId' => 577,
                                      'itemPriceId' => '1084',
                                      'laborFee' => '0',
                                      'laborFeeTaxRate' => '.066',
                                      'oneTimeFee' => '0',
                                      'oneTimeFeeTaxRate' => '.066',
                                      'parentId' => Fog::Mock.random_numbers(8).to_i,
                                      'promoCodeId' => nil,
                                      'quantity' => nil,
                                      'recurringFee' => '0',
                                      'setupFee' => '0',
                                      'setupFeeDeferralMonths' => 12,
                                      'setupFeeTaxRate' => '.066',
                                      'bundledItems' => [],
                                      'category' =>
                                          {
                                              'categoryCode' => 'static_sec_ip_addresses',
                                              'id' => 53,
                                              'name' => 'Public Secondary Static IP Addresses',
                                              'quantityLimit' => 0},
                                      'children' => [],
                                      'order' => nil,
                                      'storageGroups' => []
                                  }
                              ],
                          'location' => {'id' => 265592, 'longName' => 'Amsterdam 1', 'name' => 'ams01'},
                          'order' => nil,
                          'storageGroups' => []
                      }
                  ],
              'userRecord' =>
                  {
                      'accountId' => Fog::Mock.random_numbers(6).to_i,
                      'address1' => '315 Capitol Street',
                      'authenticationToken' =>
                          {
                              'hash' => 'd83e82b1c9a04befe6ac48368d9b61f3',
                              'user' => nil,
                              'userId' => 184064
                          },
                      'city' => 'Houston',
                      'companyName' => 'SLayer\'s Inc.',
                      'country' => 'US',
                      'createDate' => Time.now.iso8601,
                      'daylightSavingsTimeFlag' => true,
                      'denyAllResourceAccessOnCreateFlag' => false,
                      'displayName' => 'PulseL',
                      'email' => '[email protected]',
                      'firstName' => 'Mr.',
                      'forumPasswordHash' => '000000000000000000000000000000000000000000',
                      'id' => Fog::Mock.random_numbers(6).to_i,
                      'lastName' => 'Rogers',
                      'localeId' => 1,
                      'modifyDate' => Time.now.iso8601,
                      'parentId' => Fog::Mock.random_numbers(6).to_i,
                      'passwordExpireDate' => nil,
                      'permissionSystemVersion' => 2,
                      'postalCode' => '77002',
                      'pptpVpnAllowedFlag' => false,
                      'savedId' => Fog::Mock.random_numbers(6).to_i,
                      'secondaryLoginManagementFlag' => nil,
                      'secondaryLoginRequiredFlag' => nil,
                      'secondaryPasswordModifyDate' => Time.now.iso8601,
                      'secondaryPasswordTimeoutDays' => 0,
                      'sslVpnAllowedFlag' => false,
                      'state' => 'TX',
                      'statusDate' => nil,
                      'timezoneId' => 113,
                      'userStatusId' => Fog::Mock.random_numbers(4).to_i,
                      'username' => 'sl307608-meldridge',
                      'vpnManualConfig' => false,
                      'hasFullHardwareAccessFlag' => true,
                      'timezone' =>
                          {
                              'id' => 113,
                              'longName' => '(GMT-06:00) America/Chicago - CST',
                              'name' => 'America/Chicago',
                              'offset' => '-0600',
                              'shortName' => 'CST'
                          }
                  }
          }
  }
  response


end

#create_network_tags(id, tags = []) ⇒ Object

Raises:

  • (ArgumentError)


13
14
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
# File 'lib/fog/softlayer/requests/network/create_network_tags.rb', line 13

def create_network_tags(id, tags = [])
  raise ArgumentError, "Tags argument for #{self.class.name}##{__method__} must be Array." unless tags.is_a?(Array)
  response = Excon::Response.new
  response.status = self.get_network(id).status

  if response.status == 200
    tags.each do |tag|
      @tags << {
          'empRecordId' => nil,
          'id' => Fog::Mock.random_numbers(7),
          'resourceTableId' => id,
          'tagId' => tagId = Fog::Mock.random_numbers(5),
          'tagTypeId' => 1,
          'usrRecordId' => 123456,
          'tag' => { 'accountId' => 987654, 'id' => tagId, 'internal' => 0, 'name' => tag },
          'tagType'=>{'description'=>'Vlan', 'keyName'=>'NETWORK_VLAN'}
      }
    end
    response.body = true
  else
    response.body = {
        "error"=>"Unable to find object with id of '#{id}'.",
        "code"=>"SoftLayer_Exception_ObjectNotFound"
    }
  end
  response
end

#create_subnet(order) ⇒ Object

Raises:

  • (ArgumentError)


13
14
15
16
# File 'lib/fog/softlayer/requests/network/create_subnet.rb', line 13

def create_subnet(order)
  raise ArgumentError, "Order argument for #{self.class.name}##{__method__} must be Hash." unless order.is_a?(Hash)
  # TODO: more than a stub
end

#credentialsObject



105
106
107
108
109
110
# File 'lib/fog/softlayer/network.rb', line 105

def credentials
  { :provider           => 'softlayer',
    :softlayer_username => @softlayer_username,
    :softlayer_api_key  => @softlayer_api_key
  }
end

#delete_global_ip_address(id) ⇒ Object

Raises:

  • (Fog::Errors::MockNotImplemented)


14
15
16
17
# File 'lib/fog/softlayer/requests/network/delete_global_ip_address.rb', line 14

def delete_global_ip_address(id)
  # TODO: Implement.
  raise Fog::Errors::MockNotImplemented
end

#delete_network(id) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/fog/softlayer/requests/network/delete_network.rb', line 14

def delete_network(id)
  response = Excon::Response.new
  response.status = 200
  if @networks.reject! { |vlan| vlan['id'] == id }.nil?
    response.status = 404
    response.body = "{\"error\":\"Unable to find object with id of '#{id}'.\",\"code\":\"SoftLayer_Exception_ObjectNotFound\"}"
  else
    response.body = true
  end
  response
end

#delete_network_tags(id, tags = []) ⇒ Object

Raises:

  • (ArgumentError)


14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/fog/softlayer/requests/network/delete_network_tags.rb', line 14

def delete_network_tags(id, tags = [])
  raise ArgumentError, "Tags argument for #{self.class.name}##{__method__} must be Array." unless tags.is_a?(Array)
  response = Excon::Response.new
  response.status = self.get_network(id).status

  if response.status == 200
    @tags = @tags.reject do |tag|
      tag['resourceTableId'] == id and tags.include?(tag['tag']['name'])
    end
    response.body = true
  else
    response.body = {
        "error"=>"Unable to find object with id of '#{id}'.",
        "code"=>"SoftLayer_Exception_ObjectNotFound"
    }
  end
  response
end

#get_datacenter_routers(id) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/fog/softlayer/requests/network/get_datacenter_routers.rb', line 14

def get_datacenter_routers(id)
  response = Excon::Response.new
  response.status = 200
  dc = @datacenters.select { |dc| dc['id'] == id }.first
  if dc.nil?
    response.status = 404
    response.body = "{\"error\":\"Unable to find object with id of '#{id}'.\",\"code\":\"SoftLayer_Exception_ObjectNotFound\"}"
  else
    response.body = [
      { "hostname" => "bcr01a.#{dc['name']}", "id" => Fog::Mock.random_numbers(6).to_i },
      { "hostname" => "bcr02a.#{dc['name']}", "id" => Fog::Mock.random_numbers(6).to_i },
      { "hostname" => "fcr01a.#{dc['name']}", "id" => Fog::Mock.random_numbers(6).to_i },
      { "hostname" => "fcr02a.#{dc['name']}", "id" => Fog::Mock.random_numbers(6).to_i },
    ]
  end
  response
end

#get_datacentersObject



14
15
16
17
18
19
# File 'lib/fog/softlayer/requests/network/get_datacenters.rb', line 14

def get_datacenters
  response = Excon::Response.new
  response.status = 200
  response.body = @datacenters
  response
end

#get_global_ip_address(id) ⇒ Object

Raises:

  • (Fog::Errors::MockNotImplemented)


14
15
16
17
# File 'lib/fog/softlayer/requests/network/get_global_ip_address.rb', line 14

def get_global_ip_address(id)
  # TODO: Implement.
  raise Fog::Errors::MockNotImplemented
end

#get_global_ip_recordsObject

Raises:

  • (Fog::Errors::MockNotImplemented)


14
15
16
17
# File 'lib/fog/softlayer/requests/network/get_global_ip_records.rb', line 14

def get_global_ip_records
  # TODO: Implement.
  raise Fog::Errors::MockNotImplemented
end

#get_ip_address(id) ⇒ Object

Raises:

  • (Fog::Errors::MockNotImplemented)


14
15
16
17
# File 'lib/fog/softlayer/requests/network/get_ip_address.rb', line 14

def get_ip_address(id)
  # TODO: Implement.
  raise Fog::Errors::MockNotImplemented
end

#get_ip_addressesObject

Raises:

  • (Fog::Errors::MockNotImplemented)


14
15
16
17
# File 'lib/fog/softlayer/requests/network/get_ip_addresses.rb', line 14

def get_ip_addresses
  # TODO: Implement.
  raise Fog::Errors::MockNotImplemented
end

#get_network(id) ⇒ Object



14
15
16
17
18
19
20
21
22
23
# File 'lib/fog/softlayer/requests/network/get_network.rb', line 14

def get_network(id)
  response = Excon::Response.new
  response.status = 200
  response.body = @networks.select { |vlan| vlan['id'] == id }.first
  if response.body.nil?
    response.status = 404
    response.body = "{\"error\":\"Unable to find object with id of '#{id}'.\",\"code\":\"SoftLayer_Exception_ObjectNotFound\"}"
  end
  response
end

#get_network_tags(id) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/fog/softlayer/requests/network/get_network_tags.rb', line 14

def get_network_tags(id)
  response = Excon::Response.new

  response.status = self.get_network(id).status

  net = self.get_network(id).body
  unless net['error']
    tags = @tags.map do |tag|
      tag if tag['resourceTableId'] == id
    end.compact
  end

  net['tagReferences'] = tags if net.is_a?(Hash)
  response.body = net

  if response.status == 404
    response.body = {
        "error"=>"Unable to find object with id of '#{id}'.",
        "code"=>"SoftLayer_Exception_ObjectNotFound"
    }
  end
  response
end

#get_portable_subnet_package_id(address_space) ⇒ Object

Raises:

  • (ArgumentError)


14
15
16
17
18
# File 'lib/fog/softlayer/requests/network/get_portable_subnet_package_id.rb', line 14

def get_portable_subnet_package_id(address_space)
  address_space.downcase!; err_msg = "Argument for #{self.class.name}##{__method__} must be 'PRIVATE' or 'PUBLIC'."
  raise ArgumentError, err_msg unless %{private public}.include?(address_space)
  42
end

#get_portable_subnet_price_code(address_count, public = true) ⇒ Object



14
15
16
# File 'lib/fog/softlayer/requests/network/get_portable_subnet_price_code.rb', line 14

def get_portable_subnet_price_code(address_count, public=true)
  42
end

#get_private_vlan_price_codeObject



14
15
16
# File 'lib/fog/softlayer/requests/network/get_private_vlan_price_code.rb', line 14

def get_private_vlan_price_code
  42
end

#get_public_vlan_price_codeObject



14
15
16
# File 'lib/fog/softlayer/requests/network/get_public_vlan_price_code.rb', line 14

def get_public_vlan_price_code
  42
end

#get_references_by_tag_name(tag_list) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/fog/softlayer/requests/network/get_references_by_tag_name.rb', line 14

def get_references_by_tag_name(tag_list)
  response = Excon::Response.new
  response.status = 200

  response.body = tag_list.split(',').map do |tag|
    refs = @tags.select { |ref| ref['tag']['name'] == tag }
    unless refs.empty?
      {
          'accountId' =>  Fog::Softlayer.,
          'id'=>Fog::Mock.random_numbers(7),
          'internal' => 0,
          'name' => tag,
          'references' => refs
      }
    end
  end.compact
  response
end

#get_subnet(id) ⇒ Object

Raises:

  • (Fog::Errors::MockNotImplemented)


14
15
16
17
# File 'lib/fog/softlayer/requests/network/get_subnet.rb', line 14

def get_subnet(id)
  # TODO: Implement.
  raise Fog::Errors::MockNotImplemented
end

#get_subnet_package_id(address_space) ⇒ Object

Raises:

  • (ArgumentError)


14
15
16
17
18
# File 'lib/fog/softlayer/requests/network/get_subnet_package_id.rb', line 14

def get_subnet_package_id(address_space)
  address_space.downcase!; err_msg = "Argument for #{self.class.name}##{__method__} must be 'PRIVATE' or 'PUBLIC'."
  raise ArgumentError, err_msg unless %{private public}.include?(address_space)
  42
end

#get_subnet_price_code(address_count, public = true) ⇒ Object



14
15
16
# File 'lib/fog/softlayer/requests/network/get_subnet_price_code.rb', line 14

def get_subnet_price_code(address_count, public=true)
  42
end

#list_networksObject



14
15
16
17
18
19
# File 'lib/fog/softlayer/requests/network/list_networks.rb', line 14

def list_networks
  response = Excon::Response.new
  response.body = @networks
  response.status = 200
  response
end

#list_subnetsObject

Raises:

  • (Fog::Errors::MockNotImplemented)


14
15
16
17
# File 'lib/fog/softlayer/requests/network/list_subnets.rb', line 14

def list_subnets
  # TODO: Implement.
  raise Fog::Errors::MockNotImplemented
end

#route_global_ip(global_ip, destination_ip) ⇒ Object

Raises:

  • (Fog::Errors::MockNotImplemented)


14
15
16
17
# File 'lib/fog/softlayer/requests/network/route_global_ip.rb', line 14

def route_global_ip(global_ip, destination_ip)
  # TODO: Implement.
  raise Fog::Errors::MockNotImplemented
end

#unroute_global_ip(global_ip_id) ⇒ Object

Raises:

  • (Fog::Errors::MockNotImplemented)


14
15
16
17
# File 'lib/fog/softlayer/requests/network/unroute_global_ip.rb', line 14

def unroute_global_ip(global_ip_id)
  # TODO: Implement.
  raise Fog::Errors::MockNotImplemented
end