Skip to content

Commit 0e06b79

Browse files
Merge pull request #1231 from kremlin-/vdr-integration
bring in convert/refresh funcs
2 parents 2587d41 + 833700c commit 0e06b79

File tree

13 files changed

+173
-0
lines changed

13 files changed

+173
-0
lines changed

SoftLayer/CLI/block/convert.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
"""Convert a dependent duplicate volume to an independent volume."""
2+
# :license: MIT, see LICENSE for more details.
3+
4+
import click
5+
import SoftLayer
6+
from SoftLayer.CLI import environment
7+
8+
9+
@click.command()
10+
@click.argument('volume_id')
11+
@environment.pass_env
12+
def cli(env, volume_id):
13+
"""Convert a dependent duplicate volume to an independent volume."""
14+
block_manager = SoftLayer.BlockStorageManager(env.client)
15+
resp = block_manager.convert_dep_dupe(volume_id)
16+
17+
click.echo(resp)

SoftLayer/CLI/block/refresh.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
"""Refresh a dependent duplicate volume with a snapshot from its parent."""
2+
# :license: MIT, see LICENSE for more details.
3+
4+
import click
5+
import SoftLayer
6+
from SoftLayer.CLI import environment
7+
8+
9+
@click.command()
10+
@click.argument('volume_id')
11+
@click.argument('snapshot_id')
12+
@environment.pass_env
13+
def cli(env, volume_id, snapshot_id):
14+
""""Refresh a dependent duplicate volume with a snapshot from its parent."""
15+
block_manager = SoftLayer.BlockStorageManager(env.client)
16+
resp = block_manager.refresh_dep_dupe(volume_id, snapshot_id)
17+
18+
click.echo(resp)

SoftLayer/CLI/file/convert.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
"""Convert a dependent duplicate volume to an independent volume."""
2+
# :license: MIT, see LICENSE for more details.
3+
4+
import click
5+
import SoftLayer
6+
from SoftLayer.CLI import environment
7+
8+
9+
@click.command()
10+
@click.argument('volume_id')
11+
@environment.pass_env
12+
def cli(env, volume_id):
13+
"""Convert a dependent duplicate volume to an independent volume."""
14+
file_manager = SoftLayer.FileStorageManager(env.client)
15+
resp = file_manager.convert_dep_dupe(volume_id)
16+
17+
click.echo(resp)

SoftLayer/CLI/file/refresh.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
"""Refresh a dependent duplicate volume with a snapshot from its parent."""
2+
# :license: MIT, see LICENSE for more details.
3+
4+
import click
5+
import SoftLayer
6+
from SoftLayer.CLI import environment
7+
8+
9+
@click.command()
10+
@click.argument('volume_id')
11+
@click.argument('snapshot_id')
12+
@environment.pass_env
13+
def cli(env, volume_id, snapshot_id):
14+
""""Refresh a dependent duplicate volume with a snapshot from its parent."""
15+
file_manager = SoftLayer.FileStorageManager(env.client)
16+
resp = file_manager.refresh_dep_dupe(volume_id, snapshot_id)
17+
18+
click.echo(resp)

SoftLayer/CLI/routes.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@
106106
('block:volume-order', 'SoftLayer.CLI.block.order:cli'),
107107
('block:volume-set-lun-id', 'SoftLayer.CLI.block.lun:cli'),
108108
('block:volume-limits', 'SoftLayer.CLI.block.limit:cli'),
109+
('block:volume-refresh', 'SoftLayer.CLI.block.refresh:cli'),
110+
('block:volume-convert', 'SoftLayer.CLI.block.convert:cli'),
109111

110112
('event-log', 'SoftLayer.CLI.event_log'),
111113
('event-log:get', 'SoftLayer.CLI.event_log.get:cli'),
@@ -137,6 +139,8 @@
137139
('file:volume-modify', 'SoftLayer.CLI.file.modify:cli'),
138140
('file:volume-order', 'SoftLayer.CLI.file.order:cli'),
139141
('file:volume-limits', 'SoftLayer.CLI.file.limit:cli'),
142+
('file:volume-refresh', 'SoftLayer.CLI.file.refresh:cli'),
143+
('file:volume-convert', 'SoftLayer.CLI.file.convert:cli'),
140144

141145
('firewall', 'SoftLayer.CLI.firewall'),
142146
('firewall:add', 'SoftLayer.CLI.firewall.add:cli'),

SoftLayer/fixtures/SoftLayer_Network_Storage.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@
157157
'storageTierLevel': 'READHEAVY_TIER',
158158
'storageType': {'keyName': 'ENDURANCE_STORAGE'},
159159
'username': 'username',
160+
'dependentDuplicate': 1,
160161
}
161162

162163
getSnapshots = [{
@@ -232,3 +233,11 @@
232233
'maximumAvailableCount': 300,
233234
'provisionedCount': 100
234235
}
236+
237+
refreshDependentDuplicate = {
238+
'dependentDuplicate': 1
239+
}
240+
241+
convertCloneDependentToIndependent = {
242+
'dependentDuplicate': 1
243+
}

SoftLayer/managers/storage.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,3 +414,18 @@ def cancel_volume(self, volume_id, reason='No longer needed', immediate=False):
414414
immediate = True
415415

416416
return self.client.call('SoftLayer_Billing_Item', 'cancelItem', immediate, True, reason, id=billing_item_id)
417+
418+
def refresh_dep_dupe(self, volume_id, snapshot_id):
419+
""""Refresh a dependent duplicate volume with a snapshot from its parent.
420+
421+
:param integer volume_id: The id of the volume
422+
:param integer snapshot_id: The id of the snapshot
423+
"""
424+
return self.client.call('Network_Storage', 'refreshDependentDuplicate', snapshot_id, id=volume_id)
425+
426+
def convert_dep_dupe(self, volume_id):
427+
"""Convert a dependent duplicate volume to an independent volume.
428+
429+
:param integer volume_id: The id of the volume.
430+
"""
431+
return self.client.call('Network_Storage', 'convertCloneDependentToIndependent', id=volume_id)

docs/cli/block.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,13 @@ Block Commands
111111
:prog: block volume-limits
112112
:show-nested:
113113

114+
.. click:: SoftLayer.CLI.block.refresh:cli
115+
:prog block volume-refresh
116+
:show-nested:
117+
118+
.. click:: SoftLayer.CLI.block.convert:cli
119+
:prog block volume-convert
120+
:show-nested:
114121

115122
.. click:: SoftLayer.CLI.block.subnets.list:cli
116123
:prog: block subnets-list

docs/cli/file.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,14 @@ File Commands
9999
:prog: file volume-limits
100100
:show-nested:
101101

102+
.. click:: SoftLayer.CLI.file.refresh:cli
103+
:prog file volume-refresh
104+
:show-nested:
105+
106+
.. click:: SoftLayer.CLI.file.convert:cli
107+
:prog file volume-convert
108+
:show-nested:
109+
102110
.. click:: SoftLayer.CLI.file.snapshot.schedule_list:cli
103111
:prog: file snapshot-schedule-list
104112
:show-nested:

tests/CLI/modules/block_tests.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -716,3 +716,13 @@ def test_volume_limit(self, list_mock):
716716

717717
result = self.run_command(['block', 'volume-limits'])
718718
self.assert_no_fail(result)
719+
720+
def test_dep_dupe_refresh(self):
721+
result = self.run_command(['block', 'volume-refresh', '102', '103'])
722+
723+
self.assert_no_fail(result)
724+
725+
def test_dep_dupe_convert(self):
726+
result = self.run_command(['block', 'volume-convert', '102'])
727+
728+
self.assert_no_fail(result)

0 commit comments

Comments
 (0)