'Generate command to be sent to VPSA.'

def _generate_vpsa_cmd(self, cmd, **kwargs):

    def _joined_params(params):
        param_str = []
        for (k, v) in params.items():
            param_str.append(('%s=%s' % (k, v)))
        return '&'.join(param_str)
    vpsa_commands = {'login': ('POST', '/api/users/login.xml', {'user': self.conf.zadara_user, 'password': self.conf.zadara_password}), 'create_volume': ('POST', '/api/volumes.xml', {'name': kwargs.get('name'), 'capacity': kwargs.get('size'), 'pool': self.conf.zadara_vpsa_poolname, 'thin': 'YES', 'crypt': ('YES' if self.conf.zadara_vol_encrypt else 'NO'), 'attachpolicies': ('NO' if (not self.conf.zadara_default_snap_policy) else 'YES')}), 'delete_volume': ('DELETE', ('/api/volumes/%s.xml' % kwargs.get('vpsa_vol')), {'force': 'YES'}), 'expand_volume': ('POST', ('/api/volumes/%s/expand.xml' % kwargs.get('vpsa_vol')), {'capacity': kwargs.get('size')}), 'create_snapshot': ('POST', ('/api/consistency_groups/%s/snapshots.xml' % kwargs.get('cg_name')), {'display_name': kwargs.get('snap_name')}), 'delete_snapshot': ('DELETE', ('/api/snapshots/%s.xml' % kwargs.get('snap_id')), {}), 'create_clone_from_snap': ('POST', ('/api/consistency_groups/%s/clone.xml' % kwargs.get('cg_name')), {'name': kwargs.get('name'), 'snapshot': kwargs.get('snap_id')}), 'create_clone': ('POST', ('/api/consistency_groups/%s/clone.xml' % kwargs.get('cg_name')), {'name': kwargs.get('name')}), 'create_server': ('POST', '/api/servers.xml', {'display_name': kwargs.get('initiator'), 'iqn': kwargs.get('initiator')}), 'attach_volume': ('POST', ('/api/servers/%s/volumes.xml' % kwargs.get('vpsa_srv')), {'volume_name[]': kwargs.get('vpsa_vol'), 'force': 'NO'}), 'detach_volume': ('POST', ('/api/volumes/%s/detach.xml' % kwargs.get('vpsa_vol')), {'server_name[]': kwargs.get('vpsa_srv'), 'force': 'NO'}), 'list_volumes': ('GET', '/api/volumes.xml', {}), 'list_pools': ('GET', '/api/pools.xml', {}), 'list_controllers': ('GET', '/api/vcontrollers.xml', {}), 'list_servers': ('GET', '/api/servers.xml', {}), 'list_vol_attachments': ('GET', ('/api/volumes/%s/servers.xml' % kwargs.get('vpsa_vol')), {}), 'list_vol_snapshots': ('GET', ('/api/consistency_groups/%s/snapshots.xml' % kwargs.get('cg_name')), {})}
    if (cmd not in vpsa_commands):
        raise exception.UnknownCmd(cmd=cmd)
    else:
        (method, url, params) = vpsa_commands[cmd]
    if (method == 'GET'):
        params.update(dict(access_key=self.access_key, page=1, start=0, limit=0))
        url += ('?' + _joined_params(params))
        body = ''
    elif (method == 'DELETE'):
        params.update(dict(access_key=self.access_key))
        url += ('?' + _joined_params(params))
        body = ''
    elif (method == 'POST'):
        if self.access_key:
            params.update(dict(access_key=self.access_key))
        body = _joined_params(params)
    else:
        msg = (_('Method    %(method)s    is    not    defined') % {'method': method})
        LOG.error(msg)
        raise AssertionError(msg)
    return (method, url, body)
