MAPI - Replication management

This class allows to query HCP for replication links, their settings and state. It also allows to trigger a replication link failover anf failback.

Note

To be able to use this class, HCP needs to run at least version 7.0.

Classes

Replication

class hcpsdk.mapi.Replication(target, debuglevel=0)[source]

Access replication link information, modify the replication link state.

Parameters:
  • target – an hcpsdk.Target object
  • debuglevel – 0..9 (used in http.client)

Class constants:

Link types:

R_ACTIVE_ACTIVE

Active/Active link

R_OUTBOUND

Outbound link (active/passive)

R_INBOUND

Inbound link (active/passive)

Link activities:

R_SUSPEND

Suspend a link (all link types)

R_RESUME

Resume a suspended link (all link types)

R_RESTORE

Restore a link (all link types)

R_FAILOVER

Initiate a failover (all link types)

R_FAILBACK

Initiate a failback (ACTIVE/ACTIVE links only)

R_BEGINRECOVERY

Begin recovery (INBOUND links only)

R_COMPLETERECOVERY

Complete recovery (INBOUND links only)

Class methodes:

getreplicationsettings()[source]

Query MAPI for the general settings of the replication service.

Returns:a dict containing the settings
Raises:HcpsdkError
returned dictionary (example):
{'allowTenantsToMonitorNamespaces': 'true',
 'enableDNSFailover': 'true',
 'enableDomainAndCertificateSynchronization': 'true',
 'network': '[hcp_system]'}

Query MAPI for a list of replication links.

Returns:a list with the names of replication links
Raises:HcpsdkError
returned list (example):
['hcp1-a-a-hcp2']
getlinkdetails(link)[source]

Query MAPI for the details of a replication link.

Parameters:link – the name of the link as retrieved by getlinklist()
Returns:a dict holding the details
Raises:HcpsdkError
the returned dictionary (example):
{'compression': 'false',
 'Connection': {'localHost': '192.168.0.52, 192.168.0.53, 192.168.0.54, '
                             '192.168.0.55',
                'localPort': '5748',
                'remoteHost': '192.168.0.56, 192.168.0.57, 192.168.0.58, '
                              '192.168.0.59',
                'remotePort': '5748'},
 'description': 'active/active link between HCP1 and HCP2',
 'encryption': 'false',
 'failoverSettings': {'local': {'autoFailover': 'false',
                                'autoFailoverMinutes': '120'},
                      'remote': {'autoFailover': 'false',
                                 'autoFailoverMinutes': '120'}},
 'id': 'b9c488db-f641-486e-a8b4-56810faf23cd',
 'name': 'hcp1-a-a-hcp2',
 'priority': 'OLDEST_FIRST',
 'statistics': {'bytesPending': '0',
                'bytesPendingRemote': '0',
                'bytesPerSecond': '0.0',
                'bytesReplicated': '0',
                'errors': '0',
                'errorsPerSecond': '0.0',
                'objectsPending': '0',
                'objectsPendingRemote': '0',
                'objectsReplicated': '0',
                'operationsPerSecond': '0.0',
                'upToDateAsOfMillis': '1419975449113',
                'upToDateAsOfString': '2014-12-30T22:37:29+0100'},
 'status': 'GOOD',
 'statusMessage': 'Synchronizing data',
 'suspended': 'false',
 'type': 'ACTIVE_ACTIVE'}
setreplicationlinkstate(linkname, action, linktype=None)[source]

Alter the state of a replication link.

Parameters:
  • linkname – name of the link to change the state
  • linktype – one of [R_ACTIVE_ACTIVE, R_OUTBOUND, R_INBOUND]; not required for [R_SUSPEND, R_RESUME, R_RESTORE]
  • action – one of [R_SUSPEND, R_RESUME, R_RESTORE, R_FAILOVER, R_FAILBACK, R_BEGINRECOVERY, R_COMPLETERECOVERY]
Raises:

HcpsdkError

Exceptions

exception hcpsdk.mapi.ReplicationSettingsError(reason)[source]

Indicate an invalid action for the given link type (R_BEGINRECOVERY or R_COMPLETERECOVERY on a R_ACTIVE_ACTIVE link, R_FAILBACK on an R_OUTBOUND or R_INBOUND link).

Parameters:reason – An error description

Example

>>> import hcpsdk.mapi
>>> from pprint import pprint
>>>
>>> auth = hcpsdk.NativeAuthorization('service', 'service01')
>>> t = hcpsdk.Target('admin.hcp1.snomis.local', auth, port=9090)
>>> r = hcpsdk.mapi.Replication(t)
>>> l = r.getlinklist()
>>> l
['hcp1--<-->--hcp2']
>>> d = r.getlinkdetails(l[0])
>>> pprint(d)
{'compression': 'false',
 'connection': {'localHost': '192.168.0.52, 192.168.0.53, '
                             '192.168.0.54, 192.168.0.55',
                'localPort': '5748',
                'remoteHost': '192.168.0.56, 192.168.0.57, '
                              '192.168.0.58, 192.168.0.59',
                'remotePort': '5748'},
 'description': 'active/active replication between HCP1 and HCP2',
 'encryption': 'false',
 'failoverSettings': {'local': {'autoFailover': 'false',
                                'autoFailoverMinutes': '120'},
                      'remote': {'autoFailover': 'false',
                                 'autoFailoverMinutes': '120'}},
 'id': '81b6df01-2bda-4094-aed8-0c47e68bd820',
 'name': 'hcp1--<-->--hcp2',
 'priority': 'OLDEST_FIRST',
 'statistics': {'bytesPending': '0',
                'bytesPendingRemote': '0',
                'bytesPerSecond': '0.0',
                'bytesReplicated': '0',
                'errors': '0',
                'errorsPerSecond': '0.0',
                'objectsPending': '0',
                'objectsPendingRemote': '0',
                'objectsReplicated': '0',
                'operationsPerSecond': '0.0',
                'upToDateAsOfMillis': '1422701963994',
                'upToDateAsOfString': '2015-01-31T11:59:23+0100'},
 'status': 'GOOD',
 'statusMessage': 'Synchronizing data',
 'suspended': 'false',
 'type': 'ACTIVE_ACTIVE'}
>>>