コード例 #1
0
def addfrom(archiveselection_name, inputfile, outputfile, p5_connection=None):
    """
    Syntax: ArchiveSelection <name> addfrom <input file> <output file>
    Description: Loads the Archive Selection entries from the external file
    <input file>. The file must be formatted with one entry per line, each
    entry in the format of:
    <path>TAB<key1>TAB<value1>TAB<key2>TAB<value2>...
    The <path> needs to be resolvable on the client for which the selection is
    created and the <input file> needs to reside on that client.
    The <path> may be followed by zero or more key/value pairs representing
    metadata that will be assigned to the file. All keys must be known in the
    index referenced by the archive selection. Unknown keys will be silently
    skipped.
    The <output file> is created by this command, it contains all accepted
    files with their ArchiveEntry handles used to reference the files later.
    The file format is one file per line in the format of:
    <path>TAB<handle>
    Note that unlike ArchiveSelection addentry, this method will add folders as
    empty nodes. This means:
        - folders are added without content, metadata in that case is assigned
        only to the folder
        - If files are added into a non existing folder in the archive, the
        folder is created without attributes or metadata.
    Return Values:
    -On Success:    the number of added key/value pairs
    """
    method_name = "addfrom"
    return exec_nsdchat([
        module_name, archiveselection_name, method_name, inputfile, outputfile
    ], p5_connection)
コード例 #2
0
 def create(client, relocate=None, as_object=True, p5_connection=None):
     """
     Syntax: RestoreSelection create <client> [<relocate>]
     Description: Creates a new temporary restore selection resource. The
     resource will be automatically deleted after the associated archive job
     has been submitted.
     The <client> must be one of the registered client computers on the
     current P5 server. Restored files will be placed on the named client.
     You can get the list of client computers with the Client names CLI
     command.
     The <relocate> overrides default restore location. If this option is
     given, it must point to a directory on the <client> file system. All
     files will be placed in this directory instead of their original
     location. The <relocate> directory must exist on the client.
     Return Values:
     -On Success:    the name of the new resource. Use this name to
                     address the resource in all other methods.
     """
     method_name = "create"
     result = exec_nsdchat([module_name, method_name, client, relocate],
                           p5_connection)
     if not as_object:
         return result
     else:
         return resourcelist(result, RestoreSelection, p5_connection)
コード例 #3
0
 def create(client,
            plan,
            indexroot=None,
            as_object=True,
            p5_connection=None):
     """
     Syntax: ArchiveSelection create <client> <plan> [<indexroot>]
     Description: Creates a new temporary archive selection resource. The
     resource will be automatically deleted after the associated archive job
     has been submitted.
     The <client> must be the one of the registered client computers on the
     current P5 server. You can get the list of client computers with the
     Client names CLI command. All files added with the addentry method
     (below) must reside on this client.
     The <plan> must be one of the registered archive plans. You can get the
     list of archive plans with the ArchivePlan names CLI command.
     The optional <indexroot> argument, if given, will force all files in
     the archive selection to be indexed under the <indexroot> path.
     Return Values:
     -On Success:    the name of the new resource. Use this name to
                     address this resource in all other methods.
     """
     method_name = "create"
     result = exec_nsdchat(
         [module_name, method_name, client, plan, indexroot], p5_connection)
     if not as_object:
         return result
     else:
         return resourcelist(result, ArchiveSelection, p5_connection)
コード例 #4
0
def submit(syncselection_name, now=True, as_object=False, p5_connection=None):
    """
    Syntax: SyncSelection <name> submit [<now>]
    Description: Submits the sync selection for execution. You can optionally
    override plan execution times by giving the <now> as one of the strings
    "1", "t", "true", "True", "y", "yes", or "Yes".
    This command implicitly destroys the SyncSelection object for the user and
    transfers the ownership of the internal underlying object to the job
    scheduler. You should not attempt to use the <name> afterwards.
    Return Values:
    -On Success:    the sync job ID. Use this job ID to query the
                    status of the job by using Job resource.
                    Please see the Job resource description for details.
    """
    method_name = "submit"
    now_option = ""
    if now is True:
        now_option = "1"
    result = exec_nsdchat(
        [module_name, syncselection_name, method_name, now_option],
        p5_connection)
    if not as_object:
        return result
    else:
        return resourcelist(result, Job, p5_connection)
コード例 #5
0
def adddirectory(archiveselection_name,
                 path,
                 key_value_list=None,
                 as_object=False,
                 p5_connection=None):
    """
    Syntax: ArchiveSelection <name> adddirectory <path>
            [<key> <value> [<key> <value>].. ]
    Description: Adds a new directory <path> to the archive selection <name>.
    It expects the absolute path to the directory to be archived. The directory
    must be located on the client <client> given at the resource creation time
    (see the create method).
    The path will be stripped of the leading directory part and the name will
    be inserted into the index at the indexroot destination as defined in
    create.
    Note that this method will only add the directory node to the archive
    selection and that only a directory node itself will be archived. If you
    want to archive both the directory and its contents recursively, use the
    ArchiveSelection addentry method.
    See the addentry method description for explanation of other method
    arguments.
    Return Values:
    -On Success:    see the addentry description for return values
    """
    method_name = "adddirectory"
    result = exec_nsdchat([
        module_name, archiveselection_name, method_name, path, key_value_list
    ], p5_connection)
    if not as_object:
        return result
    else:
        return resourcelist(result, ArchiveEntry, p5_connection)
コード例 #6
0
def addkey(archiveindex_name,
           key,
           key_type,
           attr_value_list=None,
           p5_connection=None):
    """
    Syntax: ArchiveIndex <name> addkey <key> <type> [<attr> <value>...]
    Description: Adds a user-defined key in the given index. The <key>
    identifier must not contain blanks, special punctuation characters nor any
    national characters. The length of the <key> identifier must not exceed 15
    characters. The <type> designates the data type reserved for the <key>. It
    must be one of:
            C       character key
            N       numeric key

    This command also accepts a variable number of user defined attributes and
    their values attached to the <key>.  Both <attr> and <value> may contain
    any characters, but the length of each of them is limited to 15 characters.
    These entries are optional and are not interpreted by P5 in any way, except
    for being stored in the key definition in the archive index.
    Return Values:
    -On Success:    the names of all the configured keys
    """
    method_name = "addkey"
    return exec_nsdchat([
        module_name, archiveindex_name, method_name, key, key_type,
        attr_value_list
    ], p5_connection)
コード例 #7
0
ファイル: server.py プロジェクト: ThomasWaldinger/py_awp5
 def configure(host,
               port,
               user_name,
               password,
               template=None,
               p5_connection=None):
     """
     Syntax: Server configure <host> <port> <user name> <password>
     [<template>]
     Description: Creates new (or reuses existing) server resource and
     configures the required connection parameter in a single call.
     If the optional <template> argument is set, it forces the selection of
     the given template on the server, otherwise the default template is
     used.
     Return Values:
     -On Success:    name/ID of the created server resource
     -On Failure:    a negative integer as a string:
                     "-1": Network connection problem (bad host or port)
                     "-2": Wrong user name or password (log in denied)
                     "-3": The template cannot be set
                            (it is disabled or cannot be found)
     """
     method_name = "configure"
     return exec_nsdchat([
         module_name, method_name, host, port, user_name, password, template
     ], p5_connection)
コード例 #8
0
 def configure(hostname,
               port,
               username,
               password,
               template="",
               p5_connection=None):
     """
     Syntax: Workstation configure <hostname> <port> <username> <password>
     [<template>]
     Description: Run this command on the P5 Backup2Go Server.
     Using the passed connection parameters <hostname> and <port>, tries to
     establish the connection to the remote workstation and, based on it's
     host ID, create or reuse the workstation record on the server.
     For the purpose of logging in to the server, the workstation will be
     seeded with a unique token, shared by the workstation and the server.
     This eliminates the need for storing the <username> and/or <password>
     for accessing the server on the workstation.
     If the optional <template> is given, the workstation is set to use the
     given template. Otherwise the workstation is set to use the generic
     template.
     Return Values:
     -On Success:    a positive integer as a string
                     (the name of the new local workstation)
     -On Failure:    the string "-3": the template could not be set
                     the string "-2": a wrong user name/password is given
                     the string "-1": there is a network connection problem
                                                 (bad address and/or port)
     """
     method_name = "configure"
     return exec_nsdchat([
         module_name, method_name, hostname, port, username, password,
         template
     ], p5_connection)
コード例 #9
0
def addfileabs(archiveselection_name,
               path,
               key_value_list=None,
               as_object=False,
               p5_connection=None):
    """
    Syntax: ArchiveSelection <name> addfileabs <path>
            [<key> <value> [<key> <value>].. ]
    Description: Adds a new file <path> to the archive selection <name>. It
    expects the absolute path to the file to be archived. The file must be
    located on the client <client> given at the resource creation time (see the
    create method).
    The directory path will be added 1:1 into the index. Any prefixes and
    alternative index destinations are ignored.
    See the addentry method description for explanation of other method
    arguments.
    Return Values:
    -On Success:    see the addentry method for return values
    """
    method_name = "addfileabs"
    result = exec_nsdchat([
        module_name, archiveselection_name, method_name, path, key_value_list
    ], p5_connection)
    if not as_object:
        return result
    else:
        return resourcelist(result, ArchiveEntry, p5_connection)
コード例 #10
0
def onjobactivation(syncselection_name, command=None, p5_connection=None):
    """
    Syntax: SyncSelection <name> onjobactivation [<command>]
    Description: Registers the <command> to be executed just before the job is
    started by the submit method. The command itself can be any valid OS
    command plus variable number of arguments.
    The very first argument of the command (the program itself) can be
    prepended with the name of the P5 client where the command is to be
    executed on. If omitted, the command will be executed on the client which
    the SyncSelecttion object is created for.

    Examples:
    SyncSelection SyncSelection.0 onjobactivation "mickey:/var/myscript arg"
    will execute /var//myscript on the client "mickey" regardless what client
    the SyncSelection is created for. The program will be passed one argument:
    arg.
    SyncSelection SyncSelection.0 onjobactivation "/var/scripts/myscript"
    will execute /var/scripts/myscript on the client the SyncSelection is
    created for.
    SyncSelection SyncSelection.0 onjobactivation
                                             "localhost:/var/scripts/myscript"
    will execute /var/scripts/myscript on the P5 server.
    Return Values:
    -On Success:    the command string
    """
    method_name = "onjobactivation"
    return exec_nsdchat(
        [module_name, syncselection_name, method_name, command], p5_connection)
コード例 #11
0
def copyof(volume_name, p5_connection=None):
    """Syntax: Volume <name> copyof
    Description: Returns the volume name of the clone of this volume
    Return Values:
    -On Success:    the clone name or 0 (zero) if no clone exists
    """
    method_name = "copyof"
    return exec_nsdchat([module_name, volume_name, method_name], p5_connection)
コード例 #12
0
def version(p5_connection=None):
    """
    Syntax: srvinfo version
    Description: Returns the version of the P5 application server.
    Return Values:
    -On Success: The application server version string as X.Y number
    """
    method_name = "version"
    return exec_nsdchat([module_name, method_name], p5_connection)
コード例 #13
0
def port(p5_connection=None):
    """
    Syntax: srvinfo port
    Description: Returns the TCP port of the P5 server
    Return Values:
    -On Success: The TCP port number
    """
    method_name = "port"
    return exec_nsdchat([module_name, method_name], p5_connection)
コード例 #14
0
def platform(p5_connection=None):
    """
    Syntax: srvinfo platform
    Description: Returns the OS platform of the P5 host
    Return Values:
    -On Success: One of: linux, solaris, windows or macosx
    """
    method_name = "platform"
    return exec_nsdchat([module_name, method_name], p5_connection)
コード例 #15
0
def lexxvers(p5_connection=None):
    """
    Syntax: srvinfo lexxvers
    Description: Returns the P5 application version
    Return Values:
    -On Success: The application version string as X.Y.Z number
    """
    method_name = "lexxvers"
    return exec_nsdchat([module_name, method_name], p5_connection)
コード例 #16
0
def usecount(volume_name, p5_connection=None):
    """
    Syntax: Volume <name> usecount
    Description: Returns the number of uses for read and/or write operations.
    Return Values:
    -On Success:    the number of uses
    """
    method_name = "usecount"
    return exec_nsdchat([module_name, volume_name, method_name], p5_connection)
コード例 #17
0
def hostid(p5_connection=None):
    """
    Syntax: srvinfo hostid
    Description: Returns the host ID of the P5 host (as shown in the about box)
    Return Values:
    -On Success: The host ID
    """
    method_name = "hostid"
    return exec_nsdchat([module_name, method_name], p5_connection)
コード例 #18
0
ファイル: server.py プロジェクト: ThomasWaldinger/py_awp5
def disabled(server_name, p5_connection=None):
    """
    Syntax: Server <name> disabled
    Description: Queries the server Disabled status
    Return Values:
    -On Success:    the string "1" (disabled) or "0" (not disabled)
    """
    method_name = "disabled"
    return exec_nsdchat([module_name, server_name, method_name], p5_connection)
コード例 #19
0
def uptime(p5_connection=None):
    """
    Syntax: srvinfo uptime
    Description: Returns the time in seconds since the P5 server was started
    Return Values:
    -On Success: The uptime in seconds
    """
    method_name = "uptime"
    return exec_nsdchat([module_name, method_name], p5_connection)
コード例 #20
0
def disable(volume_name, p5_connection=None):
    """
    Syntax: Volume <name> disable
    Description: Sets the volume to Disabled
    Return Values:
    -On Success:    the string "0"
    """
    method_name = "disable"
    return exec_nsdchat([module_name, volume_name, method_name], p5_connection)
コード例 #21
0
def dateused(volume_name, p5_connection=None):
    """Syntax: Volume <name> dateused
    Description: Returns the date when the volume was last used (for reading or
    for writing) in seconds since Jan 01, 1970 (Posix time).
    Return Values:
    -On Success:    the date in seconds (Posix time)
    """
    method_name = "dateused"
    return exec_nsdchat([module_name, volume_name, method_name], p5_connection)
コード例 #22
0
def dateexpires(volume_name, p5_connection=None):
    """Syntax: Volume <name> dateexpires
    Description: Returns the date when the volume will exxpire and can be
    relabeled in seconds since Jan 01, 1970 (Posix time).
    Return Values:
    -On Success:    the date in seconds (Posix time)
    """
    method_name = "dateexpires"
    return exec_nsdchat([module_name, volume_name, method_name], p5_connection)
コード例 #23
0
def buildstamp(p5_connection=None):
    """
    Syntax: srvinfo buildstamp
    Description: Returns the build time-stamp of the P5 release
    Return Values:
    -On Success: The build time-stamp
    """
    method_name = "buildstamp"
    return exec_nsdchat([module_name, method_name], p5_connection)
コード例 #24
0
def hostname(p5_connection=None):
    """
    Syntax: srvinfo hostname
    Description: Returns the host name of the P5 host
    Return Values:
    -On Success: The host name as returned with the hostname shell command
    """
    method_name = "hostname"
    return exec_nsdchat([module_name, method_name], p5_connection)
コード例 #25
0
def address(p5_connection=None):
    """
    Syntax: srvinfo address
    Description: Returns the IP address of the P5 host
    Return Values:
    -On Success: The IP address in standard dot notation
    """
    method_name = "address"
    return exec_nsdchat([module_name, method_name], p5_connection)
コード例 #26
0
def enabled(volume_name, p5_connection=None):
    """
    Syntax: Volume <name> enabled
    Description: Queries the volume Enabled status.
    Return Values:
    -On Success:    the string "1" (enabled) or "0" (not enabled)
    """
    method_name = "enabled"
    return exec_nsdchat([module_name, volume_name, method_name], p5_connection)
コード例 #27
0
ファイル: server.py プロジェクト: ThomasWaldinger/py_awp5
def enabled(server_name, p5_connection=None):
    """
    Syntax: Server <name> enabled
    Description: Queries the server Enabled status.
    Return Values:
    -On Success:    the string “1" (enabled) or "0" (not enabled)
    """
    method_name = "enabled"
    return exec_nsdchat([module_name, server_name, method_name], p5_connection)
コード例 #28
0
ファイル: server.py プロジェクト: ThomasWaldinger/py_awp5
def delete(server_name, p5_connection=None):
    """
    Syntax: Server <name> delete
    Description: Deletes server resource, automatically stopping any scheduled
    job. If any jobs are running, the resource will not be deleted
    Return Values:
    -On Success:    the string "1" if deleted or "0" if not
    """
    method_name = "delete"
    return exec_nsdchat([module_name, server_name, method_name], p5_connection)
コード例 #29
0
ファイル: server.py プロジェクト: ThomasWaldinger/py_awp5
def lastbegin(server_name, p5_connection=None):
    """
    Syntax: Server <name> lastbegin
    Description: Returns the absolute time in seconds (Posix time) of the
    beginning of the last backup operation on the server <name>
    Return Values:
    -On Success:    the time in seconds (Posix time)
    """
    method_name = "lastbegin"
    return exec_nsdchat([module_name, server_name, method_name], p5_connection)
コード例 #30
0
ファイル: server.py プロジェクト: ThomasWaldinger/py_awp5
 def password(self, value):
     """
     Syntax: Server <name> password <value>
     Description: Stores the given argument as the new password.
     Return Values:
     -On Success:    the password
     """
     method_name = "password"
     return exec_nsdchat([module_name, server_name, method_name, value],
                         p5_connection)