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
4 changes: 2 additions & 2 deletions SoftLayer/CLI/block/order.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def cli(env, storage_type, size, iops, tier, os_type,
order = block_manager.order_block_volume(
storage_type='performance_storage_iscsi',
location=location,
size=size,
size=int(size),
iops=iops,
os_type=os_type
)
Expand All @@ -97,7 +97,7 @@ def cli(env, storage_type, size, iops, tier, os_type,
order = block_manager.order_block_volume(
storage_type='storage_service_enterprise',
location=location,
size=size,
size=int(size),
tier_level=float(tier),
os_type=os_type,
snapshot_size=snapshot_size
Expand Down
49 changes: 49 additions & 0 deletions SoftLayer/CLI/block/replication/locations.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
"""List suitable replication datacenters for the given volume."""
# :license: MIT, see LICENSE for more details.

import click
import SoftLayer
from SoftLayer.CLI import columns as column_helper
from SoftLayer.CLI import environment
from SoftLayer.CLI import formatting

COLUMNS = [
column_helper.Column('ID', ('id',), mask="id"),
column_helper.Column('Long Name', ('longName',), mask="longName"),
column_helper.Column('Short Name', ('name',), mask="name"),
]

DEFAULT_COLUMNS = [
'ID',
'Long Name',
'Short Name',
]


@click.command()
@click.argument('volume-id')
@click.option('--sortby', help='Column to sort by', default='Long Name')
@click.option('--columns',
callback=column_helper.get_formatter(COLUMNS),
help='Columns to display. Options: {0}'.format(
', '.join(column.name for column in COLUMNS)),
default=','.join(DEFAULT_COLUMNS))
@environment.pass_env
def cli(env, columns, sortby, volume_id):
"""List suitable replication datacenters for the given volume."""
block_storage_manager = SoftLayer.BlockStorageManager(env.client)

legal_centers = block_storage_manager.get_replication_locations(
volume_id
)

if not legal_centers:
click.echo("No data centers compatible for replication.")
else:
table = formatting.KeyValueTable(columns.columns)
table.sortby = sortby
for legal_center in legal_centers:
table.add_row([value or formatting.blank()
for value in columns.row(legal_center)])

env.fout(table)
57 changes: 57 additions & 0 deletions SoftLayer/CLI/block/replication/partners.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
"""List existing replicant volumes for a block volume."""
# :license: MIT, see LICENSE for more details.

import click
import SoftLayer
from SoftLayer.CLI import columns as column_helper
from SoftLayer.CLI import environment
from SoftLayer.CLI import formatting

COLUMNS = [
column_helper.Column('ID', ('id',)),
column_helper.Column('Username', ('username',), mask="username"),
column_helper.Column('Account ID', ('accountId',), mask="accountId"),
column_helper.Column('Capacity (GB)', ('capacityGb',), mask="capacityGb"),
column_helper.Column('Hardware ID', ('hardwareId',), mask="hardwareId"),
column_helper.Column('Guest ID', ('guestId',), mask="guestId"),
column_helper.Column('Host ID', ('hostId',), mask="hostId"),
]

DEFAULT_COLUMNS = [
'ID',
'Username',
'Account ID',
'Capacity (GB)',
'Hardware ID',
'Guest ID',
'Host ID'
]


@click.command()
@click.argument('volume-id')
@click.option('--sortby', help='Column to sort by', default='Username')
@click.option('--columns',
callback=column_helper.get_formatter(COLUMNS),
help='Columns to display. Options: {0}'.format(
', '.join(column.name for column in COLUMNS)),
default=','.join(DEFAULT_COLUMNS))
@environment.pass_env
def cli(env, columns, sortby, volume_id):
"""List existing replicant volumes for a block volume."""
block_storage_manager = SoftLayer.BlockStorageManager(env.client)

legal_volumes = block_storage_manager.get_replication_partners(
volume_id
)

if not legal_volumes:
click.echo("There are no replication partners for the given volume.")
else:
table = formatting.Table(columns.columns)
table.sortby = sortby
for legal_volume in legal_volumes:
table.add_row([value or formatting.blank()
for value in columns.row(legal_volume)])

env.fout(table)
49 changes: 49 additions & 0 deletions SoftLayer/CLI/file/replication/locations.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
"""List suitable replication datacenters for the given volume."""
# :license: MIT, see LICENSE for more details.

import click
import SoftLayer
from SoftLayer.CLI import columns as column_helper
from SoftLayer.CLI import environment
from SoftLayer.CLI import formatting

COLUMNS = [
column_helper.Column('ID', ('id',), mask="id"),
column_helper.Column('Long Name', ('longName',), mask="longName"),
column_helper.Column('Short Name', ('name',), mask="name"),
]

DEFAULT_COLUMNS = [
'ID',
'Long Name',
'Short Name',
]


@click.command()
@click.argument('volume-id')
@click.option('--sortby', help='Column to sort by', default='Long Name')
@click.option('--columns',
callback=column_helper.get_formatter(COLUMNS),
help='Columns to display. Options: {0}'.format(
', '.join(column.name for column in COLUMNS)),
default=','.join(DEFAULT_COLUMNS))
@environment.pass_env
def cli(env, columns, sortby, volume_id):
"""List suitable replication datacenters for the given volume."""
file_storage_manager = SoftLayer.FileStorageManager(env.client)

legal_centers = file_storage_manager.get_replication_locations(
volume_id
)

if not legal_centers:
click.echo("No data centers compatible for replication.")
else:
table = formatting.KeyValueTable(columns.columns)
table.sortby = sortby
for legal_center in legal_centers:
table.add_row([value or formatting.blank()
for value in columns.row(legal_center)])

env.fout(table)
60 changes: 60 additions & 0 deletions SoftLayer/CLI/file/replication/partners.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
"""List existing replicant volumes for a file volume."""
# :license: MIT, see LICENSE for more details.

import click
import SoftLayer
from SoftLayer.CLI import columns as column_helper
from SoftLayer.CLI import environment
from SoftLayer.CLI import formatting

COLUMNS = [
column_helper.Column('ID', ('id',)),
column_helper.Column('Username', ('username',), mask="username"),
column_helper.Column('Account ID', ('accountId',), mask="accountId"),
column_helper.Column('Capacity (GB)', ('capacityGb',), mask="capacityGb"),
column_helper.Column('Hardware ID', ('hardwareId',), mask="hardwareId"),
column_helper.Column('Guest ID', ('guestId',), mask="guestId"),
column_helper.Column('Host ID', ('hostId',), mask="hostId"),
]

# In-line comment to avoid similarity flag with block version

DEFAULT_COLUMNS = [
'ID',
'Username',
'Account ID',
'Capacity (GB)',
'Hardware ID',
'Guest ID',
'Host ID'
]


@click.command()
@click.argument('volume-id')
@click.option('--sortby', help='Column to sort by', default='Username')
@click.option('--columns',
callback=column_helper.get_formatter(COLUMNS),
help='Columns to display. Options: {0}'.format(
', '.join(column.name for column in COLUMNS)),
default=','.join(DEFAULT_COLUMNS))
@environment.pass_env
def cli(env, columns, sortby, volume_id):
"""List existing replicant volumes for a file volume."""
file_storage_manager = SoftLayer.FileStorageManager(env.client)

legal_volumes = file_storage_manager.get_replication_partners(
volume_id
)

if not legal_volumes:
click.echo("There are no replication partners for the given volume.")
else:
table = formatting.Table(columns.columns)
table.sortby = sortby

for legal_volume in legal_volumes:
table.add_row([value or formatting.blank()
for value in columns.row(legal_volume)])

env.fout(table)
5 changes: 5 additions & 0 deletions SoftLayer/CLI/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@
('block:replica-failback', 'SoftLayer.CLI.block.replication.failback:cli'),
('block:replica-failover', 'SoftLayer.CLI.block.replication.failover:cli'),
('block:replica-order', 'SoftLayer.CLI.block.replication.order:cli'),
('block:replica-partners', 'SoftLayer.CLI.block.replication.partners:cli'),
('block:replica-locations',
'SoftLayer.CLI.block.replication.locations:cli'),
('block:snapshot-cancel', 'SoftLayer.CLI.block.snapshot.cancel:cli'),
('block:snapshot-create', 'SoftLayer.CLI.block.snapshot.create:cli'),
('block:snapshot-delete', 'SoftLayer.CLI.block.snapshot.delete:cli'),
Expand All @@ -83,6 +86,8 @@
('file:replica-failback', 'SoftLayer.CLI.file.replication.failback:cli'),
('file:replica-failover', 'SoftLayer.CLI.file.replication.failover:cli'),
('file:replica-order', 'SoftLayer.CLI.file.replication.order:cli'),
('file:replica-partners', 'SoftLayer.CLI.file.replication.partners:cli'),
('file:replica-locations', 'SoftLayer.CLI.file.replication.locations:cli'),
('file:snapshot-cancel', 'SoftLayer.CLI.file.snapshot.cancel:cli'),
('file:snapshot-create', 'SoftLayer.CLI.file.snapshot.create:cli'),
('file:snapshot-delete', 'SoftLayer.CLI.file.snapshot.delete:cli'),
Expand Down
39 changes: 39 additions & 0 deletions SoftLayer/fixtures/SoftLayer_Network_Storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,16 @@
'id': 1784,
'username': 'TEST_REP_1',
'serviceResourceBackendIpAddress': '10.3.174.79',
'nasType': 'ISCSI_REPLICANT',
'createDate': '2017:50:15-04:00',
'serviceResource': {'datacenter': {'name': 'wdc01'}},
'replicationSchedule': {'type': {'keyname': 'REPLICATION_HOURLY'}},
}, {
'id': 1785,
'username': 'TEST_REP_2',
'serviceResourceBackendIpAddress': '10.3.177.84',
'nasType': 'ISCSI_REPLICANT',
'createDate': '2017:50:15-04:00',
'serviceResource': {'datacenter': {'name': 'dal01'}},
'replicationSchedule': {'type': {'keyname': 'REPLICATION_DAILY'}},
}],
Expand All @@ -102,6 +106,41 @@
'snapshotSizeBytes': '42',
}]

getReplicationPartners = [{
'id': 1784,
'accountId': 3000,
'capacityGb': 20,
'username': 'TEST_REP_1',
'serviceResourceBackendIpAddress': '10.3.174.79',
'nasType': 'ISCSI_REPLICANT',
'hostId': None,
'guestId': None,
'hardwareId': None,
'createDate': '2017:50:15-04:00',
'serviceResource': {'datacenter': {'name': 'wdc01'}},
'replicationSchedule': {'type': {'keyname': 'REPLICATION_HOURLY'}},
}, {
'id': 1785,
'accountId': 3001,
'capacityGb': 20,
'username': 'TEST_REP_2',
'serviceResourceBackendIpAddress': '10.3.177.84',
'nasType': 'ISCSI_REPLICANT',
'hostId': None,
'guestId': None,
'hardwareId': None,
'createDate': '2017:50:15-04:00',
'serviceResource': {'datacenter': {'name': 'dal01'}},
'replicationSchedule': {'type': {'keyname': 'REPLICATION_DAILY'}},
}]

getValidReplicationTargetDatacenterLocations = [{
'id': 12345,
'longName': 'Dallas 05',
'name': 'dal05'
}]


deleteObject = True
allowAccessFromHostList = True
removeAccessFromHostList = True
Expand Down
20 changes: 20 additions & 0 deletions SoftLayer/managers/block.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,26 @@ def deauthorize_host_to_volume(self, volume_id,
return self.client.call('Network_Storage', 'removeAccessFromHostList',
host_templates, id=volume_id, **kwargs)

def get_replication_partners(self, volume_id):
"""Acquires list of replicant volumes pertaining to the given volume.

:param volume_id: The ID of the primary volume to be replicated
:return: Returns an array of SoftLayer_Location objects
"""
return self.client.call('Network_Storage',
'getReplicationPartners',
id=volume_id)

def get_replication_locations(self, volume_id):
"""Acquires list of the datacenters to which a volume can be replicated.

:param volume_id: The ID of the primary volume to be replicated
:return: Returns an array of SoftLayer_Network_Storage objects
"""
return self.client.call('Network_Storage',
'getValidReplicationTargetDatacenterLocations',
id=volume_id)

def order_replicant_volume(self, volume_id, snapshot_schedule,
location, tier=None, os_type=None):
"""Places an order for a replicant block volume.
Expand Down
20 changes: 20 additions & 0 deletions SoftLayer/managers/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,26 @@ def order_replicant_volume(self, volume_id, snapshot_schedule,

return self.client.call('Product_Order', 'placeOrder', order)

def get_replication_partners(self, volume_id):
"""Acquires list of replicant volumes pertaining to the given volume.

:param volume_id: The ID of the primary volume to be replicated
:return: Returns an array of SoftLayer_Location objects
"""
return self.client.call('Network_Storage',
'getReplicationPartners',
id=volume_id)

def get_replication_locations(self, volume_id):
"""Acquires list of the datacenters to which a volume can be replicated.

:param volume_id: The ID of the primary volume to be replicated
:return: Returns an array of SoftLayer_Network_Storage objects
"""
return self.client.call('Network_Storage',
'getValidReplicationTargetDatacenterLocations',
id=volume_id)

def delete_snapshot(self, snapshot_id):
"""Deletes the specified snapshot object.

Expand Down
Loading