def manage_docker_opts(opts, remove=False): """ Add or remove docker daemon options. Options here will be merged with configured docker-opts when layer-docker processes a daemon restart. :param opts: Dictionary keys/values; use None value if the key is a flag :param remove: Boolean True to remove the options; False to add them :return: None """ try: docker_opts = DockerOpts() except Exception as e: hookenv.log(e) return for k, v in opts.items(): # Always remove existing option if docker_opts.exists(k): docker_opts.pop(k) if not remove: docker_opts.add(k, v) hookenv.log('DockerOpts daemon options changed. Requesting a restart.') # State will be removed by layer-docker after restart set_state('docker.restart')
def container_sdn_setup(sdn): ''' Receive the information from the SDN plugin, and render the docker engine options. ''' sdn_config = sdn.get_sdn_config() bind_ip = sdn_config['subnet'] mtu = sdn_config['mtu'] if data_changed('bip', bind_ip) or data_changed('mtu', mtu): status_set('maintenance', 'Configuring container runtime with SDN.') opts = DockerOpts() # This is a great way to misconfigure a docker daemon. Remove the # existing bind ip and mtu values of the SDN if opts.exists('bip'): opts.pop('bip') if opts.exists('mtu'): opts.pop('mtu') opts.add('bip', bind_ip) opts.add('mtu', mtu) _remove_docker_network_bridge() set_state('docker.sdn.configured')
def container_sdn_setup(sdn): ''' Receive the information from the SDN plugin, and render the docker engine options. ''' sdn_config = sdn.get_sdn_config() bind_ip = sdn_config['subnet'] mtu = sdn_config['mtu'] if data_changed('bip', bind_ip) or data_changed('mtu', mtu): status_set('maintenance', 'Configuring container runtime with SDN.') opts = DockerOpts() # This is a great way to misconfigure a docker daemon. Remove the # existing bind ip and mtu values of the SDN if opts.exists('bip'): opts.pop('bip') if opts.exists('mtu'): opts.pop('mtu') opts.add('bip', bind_ip) opts.add('mtu', mtu) _remove_docker_network_bridge() set_state('docker.sdn.configured')
def container_sdn_setup(sdn): """ Receive the information from the SDN plugin, and render the docker engine options. :param sdn: SDNPluginProvider :return: None """ sdn_config = sdn.get_sdn_config() bind_ip = sdn_config["subnet"] mtu = sdn_config["mtu"] if data_changed("bip", bind_ip) or data_changed("mtu", mtu): status.maintenance("Configuring container runtime with SDN.") opts = DockerOpts() # This is a great way to misconfigure a docker daemon. Remove the # existing bind ip and mtu values of the SDN if opts.exists("bip"): opts.pop("bip") if opts.exists("mtu"): opts.pop("mtu") opts.add("bip", bind_ip) opts.add("mtu", mtu) _remove_docker_network_bridge() set_state("docker.sdn.configured")
def manage_docker_opts(opts, remove=False): '''Add or remove docker daemon options. Options here will be merged with configured docker-opts when layer-docker processes a daemon restart. :param: dict opts: option keys/values; use None value if the key is a flag :param: bool remove: True to remove the options; False to add them ''' docker_opts = DockerOpts() for k, v in opts.items(): # Always remove existing option if docker_opts.exists(k): docker_opts.pop(k) if not remove: docker_opts.add(k, v) hookenv.log('DockerOpts daemon options changed. Requesting a restart.') # State will be removed by layer-docker after restart set_state('docker.restart')