Skip to content

Commit 195bb3a

Browse files
author
David Pickle
committed
Update file/block ordering to support storage_as_a_service package
**Includes updates to logic for ordering volumes, replicas, and snapshot space. The storage_as_a_service package is used as a default for new volume orders, but customers can specify older packages for use. The package associated with the existing primary volume is used in replica and snapshot orders. **Also includes a refactoring of a number of the unit tests for File and Block manager functions.
1 parent 172964c commit 195bb3a

14 files changed

Lines changed: 4673 additions & 2557 deletions

File tree

SoftLayer/CLI/block/order.py

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,40 +48,48 @@
4848
help='Optional parameter for ordering snapshot '
4949
'space along with endurance block storage; specifies '
5050
'the size (in GB) of snapshot space to order')
51+
@click.option('--service-offering',
52+
help='The service offering package to use for placing '
53+
'the order [optional, default is \'storage_as_a_service\'',
54+
type=click.Choice([
55+
'storage_as_a_service',
56+
'enterprise',
57+
'performance']))
5158
@environment.pass_env
5259
def cli(env, storage_type, size, iops, tier, os_type,
53-
location, snapshot_size):
60+
location, snapshot_size, service_offering):
5461
"""Order a block storage volume."""
5562
block_manager = SoftLayer.BlockStorageManager(env.client)
5663
storage_type = storage_type.lower()
5764

65+
if service_offering is None:
66+
service_offering = 'storage_as_a_service'
67+
5868
if storage_type == 'performance':
5969
if iops is None:
6070
raise exceptions.CLIAbort(
6171
'Option --iops required with Performance')
6272

63-
if iops < 100 or iops > 6000:
64-
raise exceptions.CLIAbort(
65-
'Option --iops must be between 100 and 6000, inclusive')
66-
6773
if iops % 100 != 0:
6874
raise exceptions.CLIAbort(
6975
'Option --iops must be a multiple of 100'
7076
)
7177

72-
if snapshot_size is not None:
78+
if service_offering == 'performance' and snapshot_size is not None:
7379
raise exceptions.CLIAbort(
74-
'Option --snapshot-size not allowed for performance volumes.'
75-
'Snapshots are only available for endurance storage.'
80+
'--snapshot-size is not available for performance volumes '
81+
'ordered with the \'performance\' service offering option'
7682
)
7783

7884
try:
7985
order = block_manager.order_block_volume(
80-
storage_type='performance_storage_iscsi',
86+
storage_type=storage_type,
8187
location=location,
8288
size=int(size),
8389
iops=iops,
84-
os_type=os_type
90+
os_type=os_type,
91+
snapshot_size=snapshot_size,
92+
service_offering=service_offering
8593
)
8694
except ValueError as ex:
8795
raise exceptions.ArgumentError(str(ex))
@@ -95,12 +103,13 @@ def cli(env, storage_type, size, iops, tier, os_type,
95103

96104
try:
97105
order = block_manager.order_block_volume(
98-
storage_type='storage_service_enterprise',
106+
storage_type=storage_type,
99107
location=location,
100108
size=int(size),
101109
tier_level=float(tier),
102110
os_type=os_type,
103-
snapshot_size=snapshot_size
111+
snapshot_size=snapshot_size,
112+
service_offering=service_offering
104113
)
105114
except ValueError as ex:
106115
raise exceptions.ArgumentError(str(ex))

SoftLayer/CLI/block/snapshot/order.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@
1515
required=True)
1616
@click.option('--tier',
1717
help='Endurance Storage Tier (IOPS per GB) of the block'
18-
' volume for which space is ordered [optional]',
19-
type=click.Choice(['0.25', '2', '4']))
18+
' volume for which space is ordered [optional, and only'
19+
' valid for endurance storage volumes]',
20+
type=click.Choice(['0.25', '2', '4', '10']))
2021
@click.option('--upgrade',
2122
type=bool,
2223
help='Flag to indicate that the order is an upgrade',

SoftLayer/CLI/file/order.py

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,39 +36,47 @@
3636
help='Optional parameter for ordering snapshot '
3737
'space along with endurance file storage; specifies '
3838
'the size (in GB) of snapshot space to order')
39+
@click.option('--service-offering',
40+
help='The service offering package to use for placing '
41+
'the order [optional, default is \'storage_as_a_service\'',
42+
type=click.Choice([
43+
'storage_as_a_service',
44+
'enterprise',
45+
'performance']))
3946
@environment.pass_env
4047
def cli(env, storage_type, size, iops, tier,
41-
location, snapshot_size):
48+
location, snapshot_size, service_offering):
4249
"""Order a file storage volume."""
4350
file_manager = SoftLayer.FileStorageManager(env.client)
4451
storage_type = storage_type.lower()
4552

53+
if service_offering is None:
54+
service_offering = 'storage_as_a_service'
55+
4656
if storage_type == 'performance':
4757
if iops is None:
4858
raise exceptions.CLIAbort(
4959
'Option --iops required with Performance')
5060

51-
if iops < 100 or iops > 6000:
52-
raise exceptions.CLIAbort(
53-
'Option --iops must be between 100 and 6000, inclusive')
54-
5561
if iops % 100 != 0:
5662
raise exceptions.CLIAbort(
5763
'Option --iops must be a multiple of 100'
5864
)
5965

60-
if snapshot_size is not None:
66+
if service_offering == 'performance' and snapshot_size is not None:
6167
raise exceptions.CLIAbort(
62-
'Option --snapshot-size not allowed for performance volumes.'
63-
' Snapshots are only available for endurance storage.'
68+
'--snapshot-size is not available for performance volumes '
69+
'ordered with the \'performance\' service offering option'
6470
)
6571

6672
try:
6773
order = file_manager.order_file_volume(
68-
storage_type='performance_storage_nfs',
74+
storage_type=storage_type,
6975
location=location,
7076
size=size,
71-
iops=iops
77+
iops=iops,
78+
snapshot_size=snapshot_size,
79+
service_offering=service_offering
7280
)
7381
except ValueError as ex:
7482
raise exceptions.ArgumentError(str(ex))
@@ -82,11 +90,12 @@ def cli(env, storage_type, size, iops, tier,
8290

8391
try:
8492
order = file_manager.order_file_volume(
85-
storage_type='storage_service_enterprise',
93+
storage_type=storage_type,
8694
location=location,
8795
size=size,
8896
tier_level=float(tier),
89-
snapshot_size=snapshot_size
97+
snapshot_size=snapshot_size,
98+
service_offering=service_offering
9099
)
91100
except ValueError as ex:
92101
raise exceptions.ArgumentError(str(ex))

SoftLayer/CLI/file/snapshot/order.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@
1515
required=True)
1616
@click.option('--tier',
1717
help='Endurance Storage Tier (IOPS per GB) of the file'
18-
' volume for which space is ordered [optional]',
19-
type=click.Choice(['0.25', '2', '4']))
18+
' volume for which space is ordered [optional, and only'
19+
' valid for endurance storage volumes]',
20+
type=click.Choice(['0.25', '2', '4', '10']))
2021
@click.option('--upgrade',
2122
type=bool,
2223
help='Flag to indicate that the order is an upgrade',

SoftLayer/fixtures/SoftLayer_Network_Storage.py

Lines changed: 83 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
DUPLICATABLE_VOLUME = {
1+
SAAS_TEST_VOLUME = {
22
'accountId': 1234,
33
'activeTransactions': None,
44
'activeTransactionCount': 0,
@@ -9,10 +9,12 @@
99
'cancellationDate': '',
1010
}],
1111
'cancellationDate': '',
12+
'categoryCode': 'storage_as_a_service',
1213
'id': 454,
1314
'location': {'id': 449500}
1415
},
1516
'capacityGb': 500,
17+
'hasEncryptionAtRest': 1,
1618
'id': 102,
1719
'iops': 1000,
1820
'lunId': 2,
@@ -21,117 +23,125 @@
2123
'parentVolume': {'snapshotSizeBytes': 1024},
2224
'provisionedIops': '1000',
2325
'replicationPartnerCount': 0,
26+
'schedules': [{
27+
'id': 978,
28+
'type': {'keyname': 'SNAPSHOT_WEEKLY'},
29+
}],
2430
'serviceResource': {'datacenter': {'id': 449500, 'name': 'dal05'}},
2531
'serviceResourceBackendIpAddress': '10.1.2.3',
2632
'snapshotCapacityGb': '10',
33+
'staasVersion': '2',
2734
'storageTierLevel': 'READHEAVY_TIER',
2835
'storageType': {'keyName': 'ENDURANCE_BLOCK_STORAGE'},
2936
'username': 'duplicatable_volume_username'
3037
}
3138

3239
getObject = {
3340
'accountId': 1234,
34-
'billingItem': {
35-
'id': 449,
36-
'cancellationDate': '',
37-
'categoryCode': 'storage_service_enterprise',
38-
'activeChildren': [{
39-
'categoryCode': 'storage_snapshot_space',
40-
'id': 123,
41-
'cancellationDate': '',
42-
}],
43-
'location': {'id': 449500}
44-
},
45-
'capacityGb': 20,
46-
'createDate': '2015:50:15-04:00',
47-
'guestId': '',
48-
'hardwareId': '',
49-
'hostId': '',
50-
'id': 100,
51-
'nasType': 'ISCSI',
52-
'notes': """{'status': 'available'}""",
53-
'password': '',
54-
'serviceProviderId': 1,
55-
'iops': 1000,
56-
'storageTierLevel': 'READHEAVY_TIER',
57-
'snapshotCapacityGb': '10',
58-
'parentVolume': {'snapshotSizeBytes': 1024},
59-
'osType': {'keyName': 'LINUX'},
60-
'originalSnapshotName': 'test-origin-snapshot-name',
61-
'originalVolumeName': 'test-origin-volume-name',
62-
'originalVolumeSize': '20',
63-
'schedules': [{
64-
'id': 978,
65-
'type': {'keyname': 'SNAPSHOT_WEEKLY'},
66-
}],
67-
'serviceResource': {'datacenter': {'id': 449500, 'name': 'dal05'}},
68-
'serviceResourceBackendIpAddress': '10.1.2.3',
69-
'fileNetworkMountAddress': '127.0.0.1:/TEST',
70-
'serviceResourceName': 'Storage Type 01 Aggregate staaspar0101_pc01',
71-
'username': 'username',
72-
'storageType': {'keyName': 'ENDURANCE_STORAGE'},
73-
'bytesUsed': 0,
74-
'activeTransactions': None,
7541
'activeTransactionCount': 0,
76-
'allowedVirtualGuests': [{
77-
'id': 1234,
78-
'hostname': 'test-server',
79-
'domain': 'example.com',
80-
'primaryBackendIpAddress': '10.0.0.1',
42+
'activeTransactions': None,
43+
'allowedHardware': [{
8144
'allowedHost': {
82-
'name': 'test-server',
8345
'credential': {'username': 'joe', 'password': '12345'},
46+
'name': 'test-server',
8447
},
85-
}],
86-
'lunId': 2,
87-
'allowedHardware': [{
88-
'id': 1234,
89-
'hostname': 'test-server',
9048
'domain': 'example.com',
49+
'hostname': 'test-server',
50+
'id': 1234,
9151
'primaryBackendIpAddress': '10.0.0.2',
52+
}],
53+
'allowedIpAddresses': [{
9254
'allowedHost': {
93-
'name': 'test-server',
9455
'credential': {'username': 'joe', 'password': '12345'},
56+
'name': 'test-server',
9557
},
58+
'id': 1234,
59+
'ipAddress': '10.0.0.1',
60+
'note': 'backend ip',
9661
}],
9762
'allowedSubnets': [{
98-
'id': 1234,
99-
'networkIdentifier': '10.0.0.1',
100-
'cidr': '24',
101-
'note': 'backend subnet',
10263
'allowedHost': {
103-
'name': 'test-server',
10464
'credential': {'username': 'joe', 'password': '12345'},
65+
'name': 'test-server',
10566
},
106-
}],
107-
'allowedIpAddresses': [{
67+
'cidr': '24',
10868
'id': 1234,
109-
'ipAddress': '10.0.0.1',
110-
'note': 'backend ip',
69+
'networkIdentifier': '10.0.0.1',
70+
'note': 'backend subnet',
71+
}],
72+
'allowedVirtualGuests': [{
11173
'allowedHost': {
112-
'name': 'test-server',
11374
'credential': {'username': 'joe', 'password': '12345'},
75+
'name': 'test-server',
11476
},
77+
'domain': 'example.com',
78+
'hostname': 'test-server',
79+
'id': 1234,
80+
'primaryBackendIpAddress': '10.0.0.1',
11581
}],
116-
'replicationStatus': 'Replicant Volume Provisioning has completed.',
82+
'billingItem': {
83+
'activeChildren': [{
84+
'cancellationDate': '',
85+
'categoryCode': 'storage_snapshot_space',
86+
'id': 123,
87+
}],
88+
'cancellationDate': '',
89+
'categoryCode': 'storage_service_enterprise',
90+
'id': 449,
91+
'location': {'id': 449500}
92+
},
93+
'bytesUsed': 0,
94+
'capacityGb': 20,
95+
'createDate': '2015:50:15-04:00',
96+
'fileNetworkMountAddress': '127.0.0.1:/TEST',
97+
'guestId': '',
98+
'hardwareId': '',
99+
'hasEncryptionAtRest': 0,
100+
'hostId': '',
101+
'id': 100,
102+
'iops': 1000,
103+
'lunId': 2,
104+
'nasType': 'ISCSI',
105+
'notes': """{'status': 'available'}""",
106+
'originalSnapshotName': 'test-origin-snapshot-name',
107+
'originalVolumeName': 'test-origin-volume-name',
108+
'originalVolumeSize': '20',
109+
'osType': {'keyName': 'LINUX'},
110+
'parentVolume': {'snapshotSizeBytes': 1024},
111+
'password': '',
112+
'provisionedIops': '1000',
117113
'replicationPartnerCount': 1,
118114
'replicationPartners': [{
115+
'createDate': '2017:50:15-04:00',
119116
'id': 1784,
120-
'username': 'TEST_REP_1',
121-
'serviceResourceBackendIpAddress': '10.3.174.79',
122117
'nasType': 'ISCSI_REPLICANT',
123-
'createDate': '2017:50:15-04:00',
124-
'serviceResource': {'datacenter': {'name': 'wdc01'}},
125118
'replicationSchedule': {'type': {'keyname': 'REPLICATION_HOURLY'}},
119+
'serviceResource': {'datacenter': {'name': 'wdc01'}},
120+
'serviceResourceBackendIpAddress': '10.3.174.79',
121+
'username': 'TEST_REP_1',
126122
}, {
123+
'createDate': '2017:50:15-04:00',
127124
'id': 1785,
128-
'username': 'TEST_REP_2',
129-
'serviceResourceBackendIpAddress': '10.3.177.84',
130125
'nasType': 'ISCSI_REPLICANT',
131-
'createDate': '2017:50:15-04:00',
132-
'serviceResource': {'datacenter': {'name': 'dal01'}},
133126
'replicationSchedule': {'type': {'keyname': 'REPLICATION_DAILY'}},
127+
'serviceResource': {'datacenter': {'name': 'dal01'}},
128+
'serviceResourceBackendIpAddress': '10.3.177.84',
129+
'username': 'TEST_REP_2',
130+
}],
131+
'replicationStatus': 'Replicant Volume Provisioning has completed.',
132+
'schedules': [{
133+
'id': 978,
134+
'type': {'keyname': 'SNAPSHOT_WEEKLY'},
134135
}],
136+
'serviceProviderId': 1,
137+
'serviceResource': {'datacenter': {'id': 449500, 'name': 'dal05'}},
138+
'serviceResourceBackendIpAddress': '10.1.2.3',
139+
'serviceResourceName': 'Storage Type 01 Aggregate staaspar0101_pc01',
140+
'snapshotCapacityGb': '10',
141+
'staasVersion': '1',
142+
'storageTierLevel': 'READHEAVY_TIER',
143+
'storageType': {'keyName': 'ENDURANCE_STORAGE'},
144+
'username': 'username',
135145
}
136146

137147
getSnapshots = [{

0 commit comments

Comments
 (0)