class Fog::Network::Softlayer::Mock

Public Class Methods

new(options={}) click to toggle source
# File lib/fog/softlayer/network.rb, line 77
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
reset() click to toggle source

Fog::Mock.random_ip,

# File lib/fog/softlayer/network.rb, line 73
def self.reset
  @data = nil
end

Public Instance Methods

create_network(order) click to toggle source
# 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.mock_account_id,
    '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' => 'donotreply@softlayer.com',
                      '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' => 'pjackson@softlayer.com',
                      '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' => 'noreply@softlayer.com',
                      '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 = []) click to toggle source
# 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) click to toggle source
# 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
credentials() click to toggle source
# File lib/fog/softlayer/network.rb, line 103
def credentials
  { :provider           => 'softlayer',
    :softlayer_username => @softlayer_username,
    :softlayer_api_key  => @softlayer_api_key
  }
end
delete_global_ip_address(id) click to toggle source
# 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) click to toggle source
# 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 = []) click to toggle source
# 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) click to toggle source
# 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_datacenters() click to toggle source
# 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) click to toggle source
# 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_records() click to toggle source
# 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) click to toggle source
# 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_addresses() click to toggle source
# File lib/fog/softlayer/requests/network/get_ip_addresses.rb, line 14
def get_ip_addresses
  # TODO: Implement.
  raise Fog::Errors::MockNotImplemented
end
get_maintenance_windows(location_id, begin_date, end_date, slots_number) click to toggle source
# File lib/fog/softlayer/requests/network/get_maintenance_windows.rb, line 12
def get_maintenance_windows(location_id, begin_date, end_date, slots_number)
  raise ArgumentError, "Arguments for #{self.class.name}##{__method__} must be present." if begin_date.nil? || end_date.nil? || location_id.nil? || slots_number.nil?
  response = Excon::Response.new
  response.status = 200
  response.body = get_windows
  response
end
get_network(id) click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# 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_code() click to toggle source
# 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_code() click to toggle source
# 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) click to toggle source
# 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.mock_account_id,
          'id'=>Fog::Mock.random_numbers(7),
          'internal' => 0,
          'name' => tag,
          'references' => refs
      }
    end
  end.compact
  response
end
get_subnet(id) click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# File lib/fog/softlayer/requests/network/get_subnet_price_code.rb, line 14
def get_subnet_price_code(address_count, public=true)
  42
end
get_windows() click to toggle source
# File lib/fog/softlayer/requests/network/get_maintenance_windows.rb, line 35
def get_windows
  [
    {
      "beginDate"=>"2015-06-01T09:00:00-06:00",
      "dayOfWeek"=>1,
      "endDate"=>"2015-06-01T12:00:00-06:00",
      "id"=>12570,
      "locationId"=>265592,
      "portalTzId"=>201
    },
    {
      "beginDate"=>"2015-06-01T17:00:00-06:00",
      "dayOfWeek"=>2,
      "endDate"=>"2015-06-01T20:00:00-06:00",
      "id"=>12584,
      "locationId"=>265592,
      "portalTzId"=>201
    },
    {
      "beginDate"=>"2015-06-01T17:00:00-06:00",
      "dayOfWeek"=>2,
      "endDate"=>"2015-06-01T20:00:00-06:00",
      "id"=>117748,
      "locationId"=>265592,
      "portalTzId"=>201
    },
    {
      "beginDate"=>"2015-06-02T01:00:00-06:00",
      "dayOfWeek"=>2,
      "endDate"=>"2015-06-02T04:00:00-06:00",
      "id"=>12568,
      "locationId"=>265592,
      "portalTzId"=>201
    },
    {
      "beginDate"=>"2015-06-02T09:00:00-06:00",
      "dayOfWeek"=>2,
      "endDate"=>"2015-06-02T12:00:00-06:00",
      "id"=>12591,
      "locationId"=>265592,
      "portalTzId"=>201
    }
  ]
end
list_networks() click to toggle source
# 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_subnets() click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# 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