-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Aanand Prasad <aanand.prasad@gmail.com>
- Loading branch information
Showing
2 changed files
with
15 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -430,12 +430,16 @@ def start_container(self, container): | |
return container | ||
|
||
def connect_container_to_networks(self, container): | ||
one_off = (container.labels.get(LABEL_ONE_OFF) == "True") | ||
connected_networks = container.get('NetworkSettings.Networks') | ||
|
||
for network in self.networks: | ||
if network in connected_networks: | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
dnephin
|
||
self.client.disconnect_container_from_network( | ||
container.id, network) | ||
|
||
self.client.connect_container_to_network( | ||
container.id, network, | ||
aliases=self._get_aliases(one_off=one_off), | ||
aliases=self._get_aliases(container), | ||
links=self._get_links(False), | ||
) | ||
|
||
|
@@ -507,11 +511,11 @@ def _next_container_number(self, one_off=False): | |
numbers = [c.number for c in containers] | ||
return 1 if not numbers else max(numbers) + 1 | ||
|
||
def _get_aliases(self, one_off): | ||
if one_off: | ||
def _get_aliases(self, container): | ||
if container.labels.get(LABEL_ONE_OFF) == "True": | ||
return [] | ||
|
||
return [self.name] | ||
return [self.name, container.short_id] | ||
|
||
def _get_links(self, link_to_self): | ||
links = {} | ||
|
@@ -618,9 +622,6 @@ def _get_container_create_options( | |
override_options, | ||
one_off=one_off) | ||
|
||
container_options['networking_config'] = self._get_container_networking_config( | ||
one_off=one_off) | ||
|
||
return container_options | ||
|
||
def _get_container_host_config(self, override_options, one_off=False): | ||
|
@@ -655,20 +656,6 @@ def _get_container_host_config(self, override_options, one_off=False): | |
cpu_quota=options.get('cpu_quota'), | ||
) | ||
|
||
def _get_container_networking_config(self, one_off=False): | ||
if self.net.mode in ['host', 'bridge']: | ||
return None | ||
|
||
if self.net.mode not in self.networks: | ||
return None | ||
|
||
return self.client.create_networking_config({ | ||
self.net.mode: self.client.create_endpoint_config( | ||
aliases=self._get_aliases(one_off=one_off), | ||
links=self._get_links(False), | ||
) | ||
}) | ||
|
||
def build(self, no_cache=False, pull=False, force_rm=False): | ||
log.info('Building %s' % self.name) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Any specific reason you are first disconnecting the containers before connecting? This causes a problem with Windows Containers as we don't support disconnecting running containers from the network currently...