The
google.appengine.api.modules
package provides the following functions.
They work in production and also with the
development server
.
- get_current_module_name ()
- Returns the module name of the current instance.
- get_current_version_name ()
- Returns the version name of the current instance.
- get_current_instance_id ()
- If the current instance belongs to a basic or manual scaled module, returns the integer ID of the current instance. If the instance belongs to an automatic scaled module, returns None.
- get_modules ()
- Returns a list of strings containing the names of all the modules belonging to this application. The 'default' module will be included if it exists, as well as the module that is associated with the instance that calls this function.
- get_versions ( module = None )
-
Returns a list of strings containing the names of all the versions associated with a given module.
Raises
InvalidModuleError
if the given module isn't valid, orTransientError
if there is a problem fetching the information. If there is an unexpected problem this method raises a genericError
.Arguments
- module = None
- A string containing the name of a module; if None then the name of the module associated with the current instance will be used.
- get_default_version ( module = None )
-
Returns the name of the default version for a given module.
Raises
InvalidModuleError
if the given module isn't valid, orInvalidVersionError
if no default version can be found. If there is an unexpected problem this method raises a genericError
.Arguments
- module = None
- A string containing the name of a module; if None then the name of the module associated with the current instance will be used.
- get_num_instances ( module = None , version = None )
-
Returns the number of instances that have been set for a given module and version. Valid only for manual or basic scaled modules.
Raises
InvalidVersionError
if the given module/version isn't valid. If there is an unexpected problem this method raises a genericError
.Arguments
- module = None
- A string containing the name of a module; if None then the name of the module associated with the current instance will be used.
- version = None
- A string containing a version name; if None then the name of the version associated with current instance will be used.
- set_num_instances ( instances , module = None , version = None )
-
Sets the number of instances for a given module and version. Valid only for manual scaled modules.
Raises
InvalidVersionError
if the given module/version isn't valid,TypeError
if the type of the instances argument is invalid, orTransientError
if there is a problem making the change. If there is an unexpected problem this method raises a genericError
.Arguments
- instances
- A long or int number specifying how many instances to set for the given module and version.
- module = None
- A string containing the name of a module; if None then the name of the module associated with the current instance will be used.
- version = None
- A string containing a version name; if None then the name of the version associated with current instance will be used.
- start_version ( module , version )
-
Start all instances for a given version of a module. Valid only for manual or basic scaled modules.
Raises
InvalidVersionError
if the given module/version isn't valid,UnexpectedStateError
if the module is already started, or cannot be started, orTransientError
if there is any other problem starting the module. If there is an unexpected problem this method raises a genericError
.Arguments
- module
- A string containing the name of a module.
- version
- A string containing a version name.
- stop_version ( module = None , version = None )
-
Stop all instances for a given version of a module. Valid only for manual or basic scaled modules.
Raises
InvalidVersionError
if the given module/version isn't valid or is automatically scaled,UnexpectedStateError
if the module is already stopped, or cannot be stopped, orTransientError
if there is any other problem stopping the module. If there is an unexpected problem this method raises a genericError
.Arguments
- module = None
- A string containing the name of a module; if None then the name of the module associated with the current instance will be used.
- version = None
- A string containing a version name; if None then the name of the version associated with current instance will be used.
- get_hostname ( module = None , version = None , instance = None )
-
Returns a hostname that can be used to contact a given module, version, and instance.
Raises
InvalidModuleError
if the given module/version isn't valid,InvalidInstancesError
if the given instance isn't valid,TypeError
if the type of the instances argument is invalid, or a general Error if there is a problem determining the hostname. If there is an unexpected problem this method raises a genericError
.Arguments
- module = None
- A string containing the name of a module; if None then the name of the module associated with the current instance will be used.
- version = None
- A string containing a version name; if None then use the name of the version associated with current instance if it's valid for the module, otherwise use the default version of the module assigned to module argument.
- instance = None
- A string containing an instance name; if None, an instance will be selected to create a load-balanced hostname. (An instance can only be specified for manual or basic scaling modules.)