'Set up a SnapMirror relationship b/w two FlexVols (cinder pools)
1. Create SnapMirror relationship
2. Initialize data transfer asynchronously
If a SnapMirror relationship already exists and is broken off or
quiesced, resume and re-sync the mirror.'

def create_snapmirror(self, src_backend_name, dest_backend_name, src_flexvol_name, dest_flexvol_name):

    dest_backend_config = config_utils.get_backend_configuration(dest_backend_name)
    dest_vserver = dest_backend_config.netapp_vserver
    dest_client = config_utils.get_client_for_backend(dest_backend_name, vserver_name=dest_vserver)
    source_backend_config = config_utils.get_backend_configuration(src_backend_name)
    src_vserver = source_backend_config.netapp_vserver
    if (not dest_client.flexvol_exists(dest_flexvol_name)):
        self.create_destination_flexvol(src_backend_name, dest_backend_name, src_flexvol_name, dest_flexvol_name)
    existing_mirrors = dest_client.get_snapmirrors(src_vserver, src_flexvol_name, dest_vserver, dest_flexvol_name)
    msg_payload = {'src_vserver': src_vserver, 'src_volume': src_flexvol_name, 'dest_vserver': dest_vserver, 'dest_volume': dest_flexvol_name}
    if (not existing_mirrors):
        msg = 'Creating    a    SnapMirror    relationship    between    %(src_vserver)s:%(src_volume)s    and    %(dest_vserver)s:%(dest_volume)s.'
        LOG.debug(msg, msg_payload)
        dest_client.create_snapmirror(src_vserver, src_flexvol_name, dest_vserver, dest_flexvol_name, schedule='hourly')
        msg = 'Initializing    SnapMirror    transfers    between    %(src_vserver)s:%(src_volume)s    and    %(dest_vserver)s:%(dest_volume)s.'
        LOG.debug(msg, msg_payload)
        dest_client.initialize_snapmirror(src_vserver, src_flexvol_name, dest_vserver, dest_flexvol_name)
    else:
        snapmirror = existing_mirrors[0]
        if (snapmirror.get('mirror-state') != 'snapmirrored'):
            try:
                msg = "SnapMirror    between    %(src_vserver)s:%(src_volume)s    and    %(dest_vserver)s:%(dest_volume)s    is    in    '%(state)s'    state.    Attempting    to    repair    it."
                msg_payload['state'] = snapmirror.get('mirror-state')
                LOG.debug(msg, msg_payload)
                dest_client.resume_snapmirror(src_vserver, src_flexvol_name, dest_vserver, dest_flexvol_name)
                dest_client.resync_snapmirror(src_vserver, src_flexvol_name, dest_vserver, dest_flexvol_name)
            except netapp_api.NaApiError:
                LOG.exception('Could    not    re-sync    SnapMirror.')
