mirror of https://github.com/docker/compose.git
Cleanup some project logic.
Signed-off-by: Daniel Nephin <dnephin@gmail.com>
This commit is contained in:
parent
e801981fed
commit
08ba857807
|
@ -87,8 +87,14 @@ class Project(object):
|
||||||
volumes_from = project.get_volumes_from(service_dict)
|
volumes_from = project.get_volumes_from(service_dict)
|
||||||
net = project.get_net(service_dict)
|
net = project.get_net(service_dict)
|
||||||
|
|
||||||
project.services.append(Service(client=client, project=name, links=links, net=net,
|
project.services.append(
|
||||||
volumes_from=volumes_from, **service_dict))
|
Service(
|
||||||
|
client=client,
|
||||||
|
project=name,
|
||||||
|
links=links,
|
||||||
|
net=net,
|
||||||
|
volumes_from=volumes_from,
|
||||||
|
**service_dict))
|
||||||
return project
|
return project
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -184,30 +190,26 @@ class Project(object):
|
||||||
return volumes_from
|
return volumes_from
|
||||||
|
|
||||||
def get_net(self, service_dict):
|
def get_net(self, service_dict):
|
||||||
if 'net' in service_dict:
|
net = service_dict.pop('net', None)
|
||||||
net_name = get_service_name_from_net(service_dict.get('net'))
|
if not net:
|
||||||
|
return
|
||||||
|
|
||||||
|
net_name = get_service_name_from_net(net)
|
||||||
|
if not net_name:
|
||||||
|
return net
|
||||||
|
|
||||||
if net_name:
|
|
||||||
try:
|
try:
|
||||||
net = self.get_service(net_name)
|
return self.get_service(net_name)
|
||||||
except NoSuchService:
|
except NoSuchService:
|
||||||
|
pass
|
||||||
try:
|
try:
|
||||||
net = Container.from_id(self.client, net_name)
|
return Container.from_id(self.client, net_name)
|
||||||
except APIError:
|
except APIError:
|
||||||
raise ConfigurationError(
|
raise ConfigurationError(
|
||||||
'Service "%s" is trying to use the network of "%s", '
|
'Service "%s" is trying to use the network of "%s", '
|
||||||
'which is not the name of a service or container.' % (
|
'which is not the name of a service or container.' % (
|
||||||
service_dict['name'],
|
service_dict['name'],
|
||||||
net_name))
|
net_name))
|
||||||
else:
|
|
||||||
net = service_dict['net']
|
|
||||||
|
|
||||||
del service_dict['net']
|
|
||||||
|
|
||||||
else:
|
|
||||||
net = None
|
|
||||||
|
|
||||||
return net
|
|
||||||
|
|
||||||
def start(self, service_names=None, **options):
|
def start(self, service_names=None, **options):
|
||||||
for service in self.get_services(service_names):
|
for service in self.get_services(service_names):
|
||||||
|
|
Loading…
Reference in New Issue