SwiftStorage

class playback.swift_storage.SwiftStorage(user='ubuntu', hosts=None, key_filename=None, password=None, parallel=True, *args, **kwargs)

Bases: playback.common.Common

Deploy swift storage node

Parameters:
  • user(str) – the user for remote server to login
  • hosts(list) – this is a second param
  • key_filename(str) – the ssh private key to used, default None
  • password(str) – the password for remote server
  • parallel(bool) – paralleler execute on remote server, default True
Returns:

None

Examples:
# create storage instances
swift_storage1 = SwiftStorage(user='ubuntu', hosts=['compute1'])
swift_storage2 = SwiftStorage(user='ubuntu', hosts=['compute2'])

# prepare disks on storage nodes
swift_storage1.prepare_disks('sdb,sdc,sdd,sde')
swift_storage2.prepare_disks('sdb,sdc,sdd,sde')

# install swift storage
swift_storage1.install(
    address='192.168.1.11'
    bind_ip='192.168.1.11'
)
swift_storage2.install(
    address='192.168.1.12'
    bind_ip='192.168.1.12'
)

# create a ring instance
ring = SwiftStorage(user='ubuntu', hosts=['controller1'])

# create account ring
ring.create_account_builder_file(
    partitions=10,
    replicas=3,
    moving=1
)
ring.account_builder_add(
    region=1,
    zone=1,
    ip='192.168.1.11',
    device='sdb',
    weight=100
)
ring.account_builder_add(
    region=1,
    zone=1,
    ip='192.168.1.11',
    device='sdc',
    weight=100
)
ring.account_builder_add(
    region=1,
    zone=1,
    ip='192.168.1.11',
    device='sdd',
    weight=100
)
ring.account_builder_add(
    region=1,
    zone=1,
    ip='192.168.1.11',
    device='sde',
    weight=100
)
ring.account_builder_add(
    region=1,
    zone=1,
    ip='192.168.1.12',
    device='sdb',
    weight=100
)
ring.account_builder_add(
    region=1,
    zone=1,
    ip='192.168.1.12',
    device='sdc',
    weight=100
)
ring.account_builder_add(
    region=1,
    zone=1,
    ip='192.168.1.12',
    device='sdd',
    weight=100
)
ring.account_builder_add(
    region=1,
    zone=1,
    ip='192.168.1.12',
    device='sde',
    weight=100
)
ring.account_builder_rebalance()

# create container ring
ring.create_container_builder_file(
    partitions=10,
    replicas=3,
    moving=1
)
ring.container_builder_add(
    region=1,
    zone=1,
    ip='192.168.1.11',
    device='sdb',
    weight=100
)
ring.container_builder_add(
    region=1,
    zone=1,
    ip='192.168.1.11',
    device='sdc',
    weight=100
)
ring.container_builder_add(
    region=1,
    zone=1,
    ip='192.168.1.11',
    device='sdd',
    weight=100
)
ring.container_builder_add(
    region=1,
    zone=1,
    ip='192.168.1.11',
    device='sde',
    weight=100
)
ring.container_builder_add(
    region=1,
    zone=1,
    ip='192.168.1.12',
    device='sdb',
    weight=100
)
ring.container_builder_add(
    region=1,
    zone=1,
    ip='192.168.1.12',
    device='sdc',
    weight=100
)
ring.container_builder_add(
    region=1,
    zone=1,
    ip='192.168.1.12',
    device='sdd',
    weight=100
)
ring.container_builder_add(
    region=1,
    zone=1,
    ip='192.168.1.12',
    device='sde',
    weight=100
)
ring.container_builder_rebalance()

# create object ring
ring.create_object_builder_file(
    partitions=10,
    replicas=3,
    moving=1
)
ring.object_builder_add(
    region=1,
    zone=1,
    ip='192.168.1.11',
    device='sdb',
    weight=100
)
ring.object_builder_add(
    region=1,
    zone=1,
    ip='192.168.1.11',
    device='sdc',
    weight=100
)
ring.object_builder_add(
    region=1,
    zone=1,
    ip='192.168.1.11',
    device='sdd',
    weight=100
)
ring.object_builder_add(
    region=1,
    zone=1,
    ip='192.168.1.11',
    device='sde',
    weight=100
)
ring.object_builder_add(
    region=1,
    zone=1,
    ip='192.168.1.12',
    device='sdb',
    weight=100
)
ring.object_builder_add(
    region=1,
    zone=1,
    ip='192.168.1.12',
    device='sdc',
    weight=100
)
ring.object_builder_add(
    region=1,
    zone=1,
    ip='192.168.1.12',
    device='sdd',
    weight=100
)
ring.object_builder_add(
    region=1,
    zone=1,
    ip='192.168.1.12',
    device='sde',
    weight=100
)
ring.object_builder_rebalance()

# sync the builder file from controller node to each storage node and other any proxy node
ring.sync_builder_file(
    hosts=['controller2', 'compute1', 'compute2']
)

# finalize installation on all nodes
from playback.swift import Swift
finalize = Swift(user='ubuntu', hosts=['controller1','controller2', 'compute1', 'compute2'])
finalize.finalize_install(
    swift_hash_path_suffix='changeme',
    swift_hash_path_prefix='changeme'
)
account_builder_add(*args, **kwargs)

Add each storage node to the account ring

Parameters:
  • region – swift storage region e.g. 1
  • zone – swift storage zone e.g. 1
  • ip – the IP address of the management network on the each storage node e.g. STORAGE_NODE_IP
  • device – a storage device name on the same storage node e.g. sdb
  • weight – the storage device weight e.g. 100
Returns:

None

account_builder_rebalance()

Rebalance account builder

Returns:None
container_builder_add(*args, **kwargs)

Add each storage node to the container ring

Parameters:
  • region – swift storage region e.g. 1
  • zone – swift storage zone e.g. 1
  • ip – the IP address of the management network on the storage node e.g. STORAGE_NODE_IP
  • device – a storage device name on the same storage node e.g. sdb
  • weight – the storage device weight e.g. 100
Returns:

None

container_builder_rebalance()

Rebalance container builder

Returns:None
create_account_builder_file(*args, **kwargs)

Create account ring

Parameters:
  • partitions – 2^10 (1024) maximum partitions e.g. 10
  • replicas – 3 replicas of each object e.g. 3
  • moving – 1 hour minimum time between moving a partition more than once e.g. 1
Returns:

None

create_container_builder_file(*args, **kwargs)

Create container ring

Parameters:
  • partitions – 2^10 (1024) maximum partitions e.g. 10
  • replicas – 3 replicas of each object e.g. 3
  • moving – 1 hour minimum time between moving a partition more than once e.g. 1
Returns:

None

create_object_builder_file(*args, **kwargs)

Create object ring

Parameters:
  • partitions – 2^10 (1024) maximum partitions e.g. 10
  • replicas – 3 replicas of each object e.g. 3
  • moving – 1 hour minimum time between moving a partition more than once e.g. 1
Returns:

None

get_builder_file()

Copy *.ring.gz to local

Returns:None
install(*args, **kwargs)

Install swift storage

Parameters:
  • address – the management interface ip for rsync
  • bind_ip – the management interface ip for swift storage binding
Returns:

None

object_builder_add(*args, **kwargs)

Add each storage node to the object ring

Parameters:
  • region – swift storage region e.g. 1
  • zone – swift storage zone e.g. 1
  • ip – the IP address of the management network on the storage node e.g. STORAGE_NODE_IP
  • device – a storage device name on the same storage node e.g. sdb
  • weight – the storage device weight e.g. 100
Returns:

None

object_builder_rebalance()

Rebalance object builder

Returns:None
prepare_disks(*args, **kwargs)

Prepare the disks for storage

Parameters:disks_name – the device name, e.g. sdb,sdc
Returns:None
sync_builder_file(hosts)

Copy the account.ring.gz, container.ring.gz, and object.ring.gz files from local to the /etc/swift directory on each storage node and any additional nodes running the proxy service

Returns:None