Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 26 additions & 2 deletions SoftLayer/fixtures/SoftLayer_Account.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,8 +323,32 @@
'subnetType': 'PRIMARY',
'ipAddressCount': 10,
'virtualGuests': [],
'hardware': []
}]
'hardware': [],
"podName": "dal05.pod04",
"networkVlan": {
"accountId": 123,
"id": 2581232,
"modifyDate": "2019-07-17T01:09:51+08:00",
"vlanNumber": 795
}
},
{
"gateway": "5.111.11.111",
"id": '111',
"modifyDate": "2018-07-24T17:14:57+08:00",
'networkIdentifier': '10.0.0.1',
'ipAddressCount': 10,
'cidr': '/24',
'virtualGuests': [],
'hardware': [],
"networkVlanId": 22222,
"sortOrder": "2",
"subnetType": "SECONDARY_ON_VLAN",
"totalIpAddresses": "8",
"usableIpAddressCount": "5",
"version": 4
}
]

getSshKeys = [{'id': '100', 'label': 'Test 1'},
{'id': '101', 'label': 'Test 2',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,45 @@
'longName': 'Dallas 9',
'name': 'dal09',
},
"networkVlans": [
{
"accountId": 11111,
"id": 33333,
"modifyDate": "2019-07-17T01:09:38+08:00",
"name": "FirewallTesting",
"primarySubnetId": 91111,
"vlanNumber": 1711
},
{
"accountId": 11111,
"id": 862222,
"modifyDate": "2019-07-17T01:09:42+08:00",
"primarySubnetId": 502211,
"vlanNumber": 722
}
],
'password': {
'password': 'aaaaa',
'username': 'root'
},
"subnets": [
{
"broadcastAddress": "",
"cidr": 32,
"gateway": "",
"id": 74222,
"modifyDate": "2016-10-26T23:39:12+08:00",
"netmask": "255.255.255.255",
"networkIdentifier": "159.253.111.111",
"networkVlanId": 3611111,
"sortOrder": "4",
"subnetType": "STATIC_IP_ROUTED",
"totalIpAddresses": "2",
"usableIpAddressCount": "2",
"version": 4,
"addressSpace": "PUBLIC"
}
],
'type': {
'keyName': 'NETSCALER_VPX',
'name': 'NetScaler VPX'
Expand Down
20 changes: 20 additions & 0 deletions SoftLayer/fixtures/SoftLayer_Network_LBaaS_LoadBalancer.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,26 @@
],
}
getAllObjects = [getObject]

getLoadBalancer = {
"accountId": 3071234,
"createDate": "2019-08-12T21:49:43+08:00",
"id": 81234,
"isPublic": 0,
"locationId": 265592,
"modifyDate": "2019-08-14T06:26:06+08:00",
"name": "dcabero-01",
"uuid": "0a2da082-4474-4e16-9f02-4de11111",
"datacenter": {
"id": 265592,
"longName": "Amsterdam 1",
"name": "ams01",
"statusId": 2
}
}

cancelLoadBalancer = True

getLoadBalancerMemberHealth = [
{
'poolUuid': '1c5f3ba6-ec7d-4cf8-8815-9bb174224a76',
Expand Down
123 changes: 123 additions & 0 deletions SoftLayer/fixtures/SoftLayer_Product_Package.py
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,44 @@
'sortOrder': 10}],
'subDescription': 'Bare Metal Server',
'unitSize': 1,
"itemPrices": [
{
"hourlyRecurringFee": ".027",
"id": 205911,
"laborFee": "0",
"locationGroupId": 505,
"item": {
"capacity": "0",
"description": "Load Balancer Uptime",
"id": 10785,
"keyName": "LOAD_BALANCER_UPTIME",
}
},
{
"hourlyRecurringFee": "0",
"id": 199467,
"laborFee": "0",
"locationGroupId": '',
"recurringFee": "0",
"item": {
"capacity": "0",
"description": "Load Balancer Bandwidth",
"id": 10051,
"keyName": "LOAD_BALANCER_BANDWIDTH",
}
},
{
"hourlyRecurringFee": ".028",
"id": 205913,
"laborFee": "0",
"locationGroupId": 507,
"item": {
"capacity": "0",
"description": "Load Balancer Uptime",
"id": 10785,
"keyName": "LOAD_BALANCER_UPTIME",
}
}]
}]

getItems = [
Expand Down Expand Up @@ -1144,6 +1182,91 @@
'quantity': 1
}

itemsLoadbal = [
{
"capacity": "0",
"description": "Load Balancer as a Service",
"id": 10043,
"keyName": "LOAD_BALANCER_AS_A_SERVICE",
"itemCategory": {
"categoryCode": "load_balancer_as_a_service",
"id": 1116,
"name": "Load Balancer As A Service",
},
"prices": [
{
"hourlyRecurringFee": "0",
"id": 199447,
"locationGroupId": '',
"recurringFee": "0",
}
]
},
{
"capacity": "0",
"description": "Load Balancer Uptime",
"id": 10785,
"keyName": "LOAD_BALANCER_UPTIME",
"itemCategory": {
"categoryCode": "load_balancer_uptime",
"id": 1119,
"name": "Load Balancer Uptime",
},
"prices": [
{
"hourlyRecurringFee": ".028",
"id": 205913,
"locationGroupId": 507,
}]}
]

regionsLoadbal = [{'description': 'WDC01 - Washington, DC - East Coast U.S.',
'keyname': 'WASHINGTON_DC',
'location': {'location': {'id': 37473,
'longName': 'Washington 1',
'name': 'wdc01',
"groups": [
{
"description": "Location Group 4",
"id": 507,
"locationGroupTypeId": 82,
"name": "Location Group 4",
"locationGroupType": {
"name": "PRICING"
}
},
{
"description": "COS Cross Region - EU",
"id": 1303,
"locationGroupTypeId": 82,
"name": "eu",
"locationGroupType": {
"name": "PRICING"
}
},
{
"description": "COS Regional Frankfurt",
"id": 1783,
"locationGroupTypeId": 82,
"name": "eu-de",
"locationGroupType": {
"name": "PRICING"
}
}
]
}},
'sortOrder': 10}]

getAllObjectsLoadbal = [
{
"id": 805,
"keyName": "LBAAS",
"name": "Load Balancer As A Service (LBaaS)",
"items": itemsLoadbal,
"regions": regionsLoadbal
}
]

getAllObjectsDH = [{
"subDescription": "Dedicated Host",
"name": "Dedicated Host",
Expand Down
79 changes: 79 additions & 0 deletions tests/CLI/modules/loadbal_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from SoftLayer.CLI.exceptions import ArgumentError
from SoftLayer import exceptions
from SoftLayer.fixtures import SoftLayer_Network_LBaaS_LoadBalancer
from SoftLayer.fixtures import SoftLayer_Product_Package
from SoftLayer import testing


Expand Down Expand Up @@ -214,3 +215,81 @@ def test_lb_health_update_fails(self, update_lb_health_monitors):
def test_lb_detail(self):
result = self.run_command(['lb', 'detail', '1111111'])
self.assert_no_fail(result)

def test_order(self):
result = self.run_command(['loadbal', 'order', '--name', 'test', '--datacenter', 'par01', '--label',
'labeltest', '--subnet', '759282'])

self.assert_no_fail(result)

def test_order_with_frontend(self):
result = self.run_command(['loadbal', 'order', '--name', 'test', '--datacenter', 'par01', '--label',
'labeltest', '--frontend', 'TCP:80', '--backend', 'TCP:80', '--subnet', '759282'])

self.assert_no_fail(result)

def test_order_with_backend(self):
result = self.run_command(['loadbal', 'order', '--name', 'test', '--datacenter', 'par01', '--label',
'labeltest', '--backend', 'HTTP:80', '--subnet', '759282'])

self.assert_no_fail(result)

def test_order_backend_fail(self):
result = self.run_command(['loadbal', 'order', '--name', 'test', '--datacenter', 'par01', '--label',
'labeltest', '--backend', 'HTTP', '--subnet', '759282'])

self.assertEqual(result.exit_code, 2)
self.assertIsInstance(result.exception, ArgumentError)

def test_verify_order(self):
result = self.run_command(['loadbal', 'order', '--verify', '--name', 'test', '--datacenter', 'par01', '--label',
'labeltest', '--subnet', '759282'])

self.assert_no_fail(result)

def test_order_options(self):
mock = self.set_mock('SoftLayer_Product_Package', 'getAllObjects')
mock.return_value = SoftLayer_Product_Package.getAllObjectsLoadbal
result = self.run_command(['loadbal', 'order-options'])

self.assert_no_fail(result)

def test_order_options_with_datacenter(self):
mock = self.set_mock('SoftLayer_Product_Package', 'getAllObjects')
mock.return_value = SoftLayer_Product_Package.getAllObjectsLoadbal
result = self.run_command(['loadbal', 'order-options', '--datacenter', 'ams03'])

self.assert_no_fail(result)

def test_cancel(self):
result = self.run_command(['loadbal', 'cancel', '11111'])

self.assert_no_fail(result)
self.assert_called_with('SoftLayer_Network_LBaaS_LoadBalancer', 'cancelLoadBalancer')

@mock.patch('SoftLayer.LoadBalancerManager.cancel_lbaas')
def test_cancel_fail(self, cancel_lbaas):
fault_string = 'Id must be string'
cancel_lbaas.side_effect = exceptions.SoftLayerAPIError(mock.ANY, fault_string)
result = self.run_command(['loadbal', 'cancel', '11111'])

self.assertIn("ERROR: {}".format(fault_string),
result.output)

def test_ns_list(self):
result = self.run_command(['loadbal', 'ns-list'])

self.assert_no_fail(result)

def test_ns_list_empty(self):
mock = self.set_mock('SoftLayer_Account', 'getApplicationDeliveryControllers')
mock.return_value = []

result = self.run_command(['loadbal', 'ns-list'])

self.assert_no_fail(result)

def test_ns_detail(self):
result = self.run_command(['loadbal', 'ns-detail', '11111'])

self.assert_no_fail(result)
2 changes: 1 addition & 1 deletion tests/managers/network_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ def test_resolve_global_ip_ids_no_results(self):

def test_resolve_subnet_ids(self):
_id = self.network.resolve_subnet_ids('10.0.0.1/29')
self.assertEqual(_id, ['100'])
self.assertEqual(_id, ['100', '111'])

def test_resolve_subnet_ids_no_results(self):
mock = self.set_mock('SoftLayer_Account', 'getSubnets')
Expand Down