Changeset View
Changeset View
Standalone View
Standalone View
_modules/paas_docker.py
| Show All 23 Lines | if "image" in args: | ||||
| image = args["image"] | image = args["image"] | ||||
| if "version" in args: | if "version" in args: | ||||
| image += ":" + str(args["version"]) | image += ":" + str(args["version"]) | ||||
| return image | return image | ||||
| def list_images(): | |||||
| """ | |||||
| A function to get the list of images used on a Docker engine. | |||||
| Example: | |||||
| salt docker-002 paas_docker.list_images | |||||
| """ | |||||
| images = __pillar__.get("docker_images", []) | |||||
| # Workaround for a merge issue for lists: | |||||
| # Salt Tower concatenates them, a set will dedup them. | |||||
| return set(images) | |||||
| def get_subnets(): | def get_subnets(): | ||||
| """ | """ | ||||
| A function to get the Docker subnets list. | A function to get the Docker subnets list. | ||||
| CLI Example: | CLI Example: | ||||
| salt * paas_docker.get_subnets | salt * paas_docker.get_subnets | ||||
| """ | """ | ||||
| try: | try: | ||||
| networks = __pillar__["docker_networks"][__grains__["id"]] | networks = __pillar__["docker_networks"] | ||||
| except KeyError: | except KeyError: | ||||
| networks = {} | networks = {} | ||||
| # Defined Docker subnet | # Defined Docker subnet | ||||
| subnets = [network["subnet"] for network in networks.values()] | subnets = [network["subnet"] for network in networks.values()] | ||||
| # Default Docker subnet | # Default Docker subnet | ||||
| subnets.append("172.17.0.0/16") | subnets.append("172.17.0.0/16") | ||||
| return subnets | return subnets | ||||
| def _get_containers(): | def _get_containers(): | ||||
| try: | try: | ||||
| return __pillar__["docker_containers"][__grains__["id"]] | return __pillar__["docker_containers"] | ||||
| except KeyError: | except KeyError: | ||||
| return {} | return {} | ||||
| def list_containers(): | def list_containers(): | ||||
| """ | """ | ||||
| A function to list all the containers provisionned on a Docker engine. | A function to list all the containers provisionned on a Docker engine. | ||||
| ▲ Show 20 Lines • Show All 47 Lines • Show Last 20 Lines | |||||
Nasqueron DevCentral · If it had been much bigger the moon would have had a core of ice. · Powered by Phabricator