def add_host_server(self, hackathon, args): """ create a docker host DB object for a hackathon and insert record into the database. param-"args" contain all necessary infos to new a docker_host :return: return True if succeed, otherwise return False :rtype: bool """ host_server = DockerHostServer(vm_name=args.vm_name, public_dns=args.public_dns, public_ip=args.public_ip, public_docker_api_port=args.public_docker_api_port, private_ip=args.private_ip, private_docker_api_port=args.private_docker_api_port, container_count=0, container_max_count=args.container_max_count, is_auto=False, disabled=args.get("disabled", False), hackathon=hackathon) if self.docker.ping(host_server): host_server.state = DockerHostServerStatus.DOCKER_READY else: host_server.state = DockerHostServerStatus.UNAVAILABLE host_server.save() return host_server.dic()
def add_host_server(self, hackathon, args): """ create a docker host DB object for a hackathon and insert record into the database. param-"args" contain all necessary infos to new a docker_host :return: return True if succeed, otherwise return False :rtype: bool """ host_server = DockerHostServer( vm_name=args.vm_name, public_dns=args.public_dns, public_ip=args.public_ip, public_docker_api_port=args.public_docker_api_port, private_ip=args.private_ip, private_docker_api_port=args.private_docker_api_port, container_count=0, container_max_count=args.container_max_count, is_auto=False, disabled=args.get("disabled", False), hackathon=hackathon) if self.docker.ping(host_server): host_server.state = DockerHostServerStatus.DOCKER_READY else: host_server.state = DockerHostServerStatus.UNAVAILABLE host_server.save() return host_server.dic()
def __create_default_data_for_local(self, hackathon): """ create test data for new hackathon. It's for local development only :param hackathon: :return: """ try: # test docker host server host = DockerHostServer(vm_name="localhost", public_dns="localhost", public_ip="127.0.0.1", public_docker_api_port=4243, private_ip="127.0.0.1", private_docker_api_port=4243, container_count=0, container_max_count=100, disabled=False, state=DockerHostServerStatus.DOCKER_READY, hackathon=hackathon) host.save() except Exception as e: self.log.error(e) self.log.warn("fail to create test data")
def __create_default_data_for_local(self, hackathon): """ create test data for new hackathon. It's for local development only :param hackathon: :return: """ try: # test docker host server host = DockerHostServer(vm_name="localhost", public_dns="localhost", public_ip="127.0.0.1", public_docker_api_port=4243, private_ip="127.0.0.1", private_docker_api_port=4243, container_count=0, container_max_count=100, disabled=False, state=DockerHostServerStatus.DOCKER_READY, hackathon=hackathon) host.save() except Exception as e: self.log.error(e) self.log.warn("fail to create test data")