ocd.docker_mysql
– The ocd mysql
command¶
Subcommand to start, stop and manage a docker container running a mysql server
-
ocd.docker_mysql.
docker_subcommand
(subparsers)[source]¶ Add a subcommand “docker_mysql” to handle the configuration file.
Parameters: - subparsers : argparse subparsers object
subparser to use to generate new parsers
Returns: - parser :
argparse.ArgumentParser
modified parser
-
ocd.docker_mysql.
docker_up_parser
(subsubparser)[source]¶ Add the
docker_mysql up
parser.Parameters: - subsubparsers : argparse subparsers object
subparser to use to generate new parsers
Returns: - subsubparsers : argparse subparsers object
modified subparser
-
ocd.docker_mysql.
docker_down_parser
(subsubparser)[source]¶ Add the
docker_mysql up
parser.Parameters: - subsubparsers : argparse subparsers object
subparser to use to generate new parsers
Returns: - subsubparsers : argparse subparsers object
modified subparser
-
ocd.docker_mysql.
docker_info_parser
(subsubparser)[source]¶ Add the
docker_mysql up
parser.Parameters: - subsubparsers : argparse subparsers object
subparser to use to generate new parsers
Returns: - subsubparsers : argparse subparsers object
modified subparser
-
ocd.docker_mysql.
docker_up
(args)[source]¶ Function implementing the
ocd docker_mysql up
commandParameters: - args :
Namespace
parsed command line arguments
- args :
-
ocd.docker_mysql.
docker_down
(args)[source]¶ Stop and remove the mysql docker container
Parameters: - args :
Namespace
parsed command line arguments
- args :
-
ocd.docker_mysql.
docker_info
(args)[source]¶ Stop and remove the mysql docker container
Parameters: - args :
Namespace
parsed command line arguments
- args :
-
ocd.docker_mysql.
container_ip_port
(container)[source]¶ Get the IP of the container and the port that it exposes. They can be used to connect to the mysql server.
Note
The port is 3306
Parameters: - container :
docker.models.containers.Container
started container
Returns: - ip, port : string
IP address allocated for the container and the exposed port
- container :
-
ocd.docker_mysql.
get_container
(container_name)[source]¶ Get the container running the mysql server
Parameters: - container_name : string
name of the container to get
Returns: docker.models.containers.Container
started container
-
ocd.docker_mysql.
wait_for_connection
(conf, max_attempts=20, sleep=1)[source]¶ Wait until a connection with the mysql server can be made.
Any exception of type
pymysql.err.OperationalError
with error code different from2003
is re-raisedParameters: - conf :
pyhetdex.tools.configuration.ConfigParser
configuration
- max_attempts : int, optional
maximum number of attempts before giving up
- sleep : float, optional
time to wait before attempting again the connection
Returns: - bool
True
if the connection happens,False
otherwise
- conf :
-
ocd.docker_mysql.
_docker_run
(conf)[source]¶ Run the mysql docker image
Parameters: - client :
docker.client.DockerClient
docker client
- conf :
pyhetdex.tools.configuration.ConfigParser
configuration
Returns: - container :
docker.models.containers.Container
started container
- client :
-
ocd.docker_mysql.
_docker_stop_rm
(container_name, v=True)[source]¶ Stop and remove mysql docker the container.
Parameters: - container_name : string
name of the container to get
- v : bool, optional
remove the volumes associated with the container
Returns: - container :
docker.models.containers.Container
started container