Skip to content

Commit

Permalink
fix string formatting + docker-compose networks
Browse files Browse the repository at this point in the history
  • Loading branch information
rmb938 committed Jul 10, 2018
1 parent 38657bc commit a08bf3d
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 21 deletions.
4 changes: 2 additions & 2 deletions deli/counter/http/mounts/root/routes/compute/v1/images.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ def create(self):
raise cherrypy.HTTPError(404, 'A region with the requested name does not exist.')

if region.state != ResourceState.Created:
raise cherrypy.HTTPError(409, 'Can only create a image with a region in the following state: %s'.format(
ResourceState.Created))
raise cherrypy.HTTPError(409, 'Can only create a image with a region in the following state: {0}'.format(
ResourceState.Created.value))

# TODO: check duplicate file name

Expand Down
22 changes: 12 additions & 10 deletions deli/counter/http/mounts/root/routes/compute/v1/instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ def create(self):
if region is None:
raise cherrypy.HTTPError(404, 'A region with the requested name does not exist.')
if region.state != ResourceState.Created:
raise cherrypy.HTTPError(400, 'Can only create a instance with a region in the following state: %s'.format(
ResourceState.Created))
raise cherrypy.HTTPError(400, 'Can only create a instance with a region in the following state: {0}'.format(
ResourceState.Created.value))

zone = None
if request.zone_name is not None:
Expand All @@ -69,17 +69,18 @@ def create(self):
raise cherrypy.HTTPError(409, 'The requested zone is not within the requested region')
if zone.state != ResourceState.Created:
raise cherrypy.HTTPError(400,
'Can only create a instance with a zone in the following state: %s'.format(
ResourceState.Created))
'Can only create a instance with a zone in the following state: {0}'.format(
ResourceState.Created.value))

network = Network.get(request.network_name)
if network is None:
raise cherrypy.HTTPError(404, 'A network with the requested name does not exist.')
if network.region.name != region.name:
raise cherrypy.HTTPError(409, 'The requested network is not within the requested region')
if network.state != ResourceState.Created:
raise cherrypy.HTTPError(400, 'Can only create a instance with a network in the following state: %s'.format(
ResourceState.Created))
raise cherrypy.HTTPError(400,
'Can only create a instance with a network in the following state: {0}'.format(
ResourceState.Created.value))

# TODO: User inputs image url instead of id
# projectId/imageId
Expand All @@ -89,8 +90,8 @@ def create(self):
if image.region.name != region.name:
raise cherrypy.HTTPError(409, 'The requested image is not within the requested region')
if image.state != ResourceState.Created:
raise cherrypy.HTTPError(400, 'Can only create a instance with a image in the following state: %s'.format(
ResourceState.Created))
raise cherrypy.HTTPError(400, 'Can only create a instance with a image in the following state: {0}'.format(
ResourceState.Created.value))

flavor: Flavor = Flavor.get(request.flavor_name)
if flavor is None:
Expand All @@ -101,15 +102,16 @@ def create(self):
keypair = Keypair.get(project, keypair_name)
if keypair is None:
raise cherrypy.HTTPError(404,
'A keypair with the requested name of %s does not exist.'.format(keypair_name))
'A keypair with the requested name of {0} does not exist.'.format(
keypair_name))
keypairs.append(keypair)

# TODO: User inputs service account email instead of id
# Only project service accounts are allowed
if request.service_account_name is not None:
service_account = ProjectServiceAccount.get(project, request.service_account_name)
if service_account is None:
raise cherrypy.HTTPError(404, 'A service account with the requested name of %s does not exist.'.format(
raise cherrypy.HTTPError(404, 'A service account with the requested name of {0} does not exist.'.format(
request.service_account_name))
else:
service_account = ProjectServiceAccount.get(project, 'default')
Expand Down
4 changes: 2 additions & 2 deletions deli/counter/http/mounts/root/routes/compute/v1/networks.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ def create(self):
raise cherrypy.HTTPError(404, 'A region with the requested name does not exist.')

if region.state != ResourceState.Created:
raise cherrypy.HTTPError(409, 'Can only create a network with a region in the following state: %s'.format(
ResourceState.Created))
raise cherrypy.HTTPError(409, 'Can only create a network with a region in the following state: {0}'.format(
ResourceState.Created.value))

network = Network()
network.name = request.name
Expand Down
4 changes: 2 additions & 2 deletions deli/counter/http/mounts/root/routes/compute/v1/volume.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ def create(self):
raise cherrypy.HTTPError(404, 'A zone with the requested name does not exist.')
if zone.state != ResourceState.Created:
raise cherrypy.HTTPError(400,
'Can only create a volume with a zone in the following state: %s'.format(
ResourceState.Created))
'Can only create a volume with a zone in the following state: {0}'.format(
ResourceState.Created.value))

quota: ProjectQuota = ProjectQuota.get(project.name)
used_disk = quota.used_disk + request.size
Expand Down
4 changes: 2 additions & 2 deletions deli/counter/http/mounts/root/routes/location/v1/zones.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ def create(self):
raise cherrypy.HTTPError(404, 'A region with the requested name does not exist.')

if region.state != ResourceState.Created:
raise cherrypy.HTTPError(400, 'Can only create a zone with a region in the following state: %s'.format(
ResourceState.Created))
raise cherrypy.HTTPError(400, 'Can only create a zone with a region in the following state: {0}'.format(
ResourceState.Created.value))

zone = Zone()
zone.name = request.name
Expand Down
4 changes: 2 additions & 2 deletions deli/kubernetes/resources/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def wait_for_crd(cls):
if cond.type == "NamesAccepted":
if cond.status == "False":
raise ValueError(
"Failed to create CRD %s: name conflict: %s".format(name, cond.message))
"Failed to create CRD {0}: name conflict: {1}".format(name, cond.message))
except ApiException as e:
# If it doesn't exist just wait, k8s may be slow
if e.status != 404:
Expand Down Expand Up @@ -295,7 +295,7 @@ def project(self, value):

def create(self):
if self.project_name is None:
raise ValueError("Project must be set to create %s".format(self.__class__.__name__))
raise ValueError("Project must be set to create {0}".format(self.__class__.__name__))

crd_api = client.CustomObjectsApi()
self._raw = crd_api.create_namespaced_custom_object(GROUP, self.version(), "sandwich-" + self.project_name,
Expand Down
2 changes: 1 addition & 1 deletion deli/kubernetes/resources/v1alpha1/instance/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def creating(self, model: Instance):
# old_vm = self.vmware.get_vm(vmware_client, str(model.vm_id), datacenter)
# if old_vm is not None:
# self.logger.info(
# "A backing for the vm %s / %s already exists so it is going to be deleted".format(
# "A backing for the vm {0} / {1} already exists so it is going to be deleted".format(
# model.project.name,
# model.name))
# self.vmware.power_off_vm(vmware_client, old_vm, hard=True)
Expand Down
2 changes: 2 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ services:
image: redis:alpine
ports:
- "6379:6379"
networks:
- sandwich

networks:
sandwich:
Expand Down
8 changes: 8 additions & 0 deletions docker/manager/.env-sample
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ VCENTER_PORT=
VCENTER_USERNAME=
VCENTER_PASSWORD=

####################
# REDIS #
####################

# Redis URL to connect to
# Used to cache various things
REDIS_URL=

####################
# Menu #
####################
Expand Down

0 comments on commit a08bf3d

Please sign in to comment.