Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
FROM python:2.7
FROM python:3.5

RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app

COPY . /usr/src/app
RUN pip install --no-cache-dir . -r requirements/production.txt

EXPOSE 8900
CMD ["twistd", "-n", "mimic"]
2 changes: 1 addition & 1 deletion mimic/canned_responses/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Canned response for get auth token
"""

from __future__ import absolute_import, division, unicode_literals


from datetime import datetime, timedelta

Expand Down
198 changes: 99 additions & 99 deletions mimic/canned_responses/fastly.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Canned response for fastly
"""

from __future__ import absolute_import, division, unicode_literals


import random
import string
Expand All @@ -26,7 +26,7 @@ def get_current_customer(self):
("/current_customer") request.
"""
def _random_string():
random_string = u''.join(random.choice(
random_string = ''.join(random.choice(
string.ascii_uppercase + string.ascii_uppercase)
for _ in range(20))
return random_string
Expand All @@ -35,32 +35,32 @@ def _random_string():
owner_id = _random_string()

current_customer = {
u'can_edit_matches': u'0',
u'can_read_public_ip_list': u'0',
u'can_upload_vcl': u'1',
u'updated_at': u'2014-11-03T23:37:44+00:00',
u'has_config_panel': u'1',
u'has_improved_ssl_config': False,
u'id': id,
u'has_historical_stats': u'1',
u'has_openstack_logging': u'0',
u'can_configure_wordpress': u'0',
u'has_improved_logging': u'1',
u'readonly': '',
u'ip_whitelist': u'0.0.0.0/0',
u'owner_id': owner_id,
u'phone_number': u'770-123-1749',
u'postal_address': None,
u'billing_ref': None,
u'can_reset_passwords': True,
u'has_improved_security': u'1',
u'stripe_account': None,
u'name': u'Poppy - Test',
u'created_at': u'2014-11-03T23:37:43+00:00',
u'can_stream_syslog': u'1',
u'pricing_plan': u'developer',
u'billing_contact_id': None,
u'has_streaming': u'1'}
'can_edit_matches': '0',
'can_read_public_ip_list': '0',
'can_upload_vcl': '1',
'updated_at': '2014-11-03T23:37:44+00:00',
'has_config_panel': '1',
'has_improved_ssl_config': False,
'id': id,
'has_historical_stats': '1',
'has_openstack_logging': '0',
'can_configure_wordpress': '0',
'has_improved_logging': '1',
'readonly': '',
'ip_whitelist': '0.0.0.0/0',
'owner_id': owner_id,
'phone_number': '770-123-1749',
'postal_address': None,
'billing_ref': None,
'can_reset_passwords': True,
'has_improved_security': '1',
'stripe_account': None,
'name': 'Poppy - Test',
'created_at': '2014-11-03T23:37:43+00:00',
'can_stream_syslog': '1',
'pricing_plan': 'developer',
'billing_contact_id': None,
'has_streaming': '1'}
return current_customer

def create_service(self, url_data):
Expand All @@ -79,42 +79,42 @@ def create_service(self, url_data):

self.fastly_cache[service_name] = {
'service_details': {
u'comment': '',
u'locked': False,
u'updated_at': u'2014-11-13T14:29:10+00:00',
u'created_at': u'2014-11-13T14:29:10+00:00',
u'testing': None,
u'number': 1,
u'staging': None,
u'active': None,
u'service_id': service_id,
u'deleted_at': None,
u'inherit_service_id': None,
u'deployed': None},
'comment': '',
'locked': False,
'updated_at': '2014-11-13T14:29:10+00:00',
'created_at': '2014-11-13T14:29:10+00:00',
'testing': None,
'number': 1,
'staging': None,
'active': None,
'service_id': service_id,
'deleted_at': None,
'inherit_service_id': None,
'deployed': None},
'service_name': service_name
}
self.fastly_cache[service_id] = self.fastly_cache[service_name]

create_service = {
u'comment': '',
u'publish_key': publish_key,
u'name': service_name,
u'versions': [{u'comment': '', u'locked': u'0',
u'service': service_id,
u'updated_at': u'2014-11-12T18:43:21',
u'created_at': u'2014-11-12T18:43:21',
u'testing': None, u'number': u'1',
u'staging': None,
u'active': None,
u'service_id': service_id,
u'deleted_at': None,
u'inherit_service_id': None,
u'deployed': None,
u'backend': 0}],
u'created_at': u'2014-11-12T18:43:21+00:00',
u'updated_at': u'2014-11-12T18:43:21+00:00',
u'customer_id': data['customer_id'],
u'id': service_id}
'comment': '',
'publish_key': publish_key,
'name': service_name,
'versions': [{'comment': '', 'locked': '0',
'service': service_id,
'updated_at': '2014-11-12T18:43:21',
'created_at': '2014-11-12T18:43:21',
'testing': None, 'number': '1',
'staging': None,
'active': None,
'service_id': service_id,
'deleted_at': None,
'inherit_service_id': None,
'deployed': None,
'backend': 0}],
'created_at': '2014-11-12T18:43:21+00:00',
'updated_at': '2014-11-12T18:43:21+00:00',
'customer_id': data['customer_id'],
'id': service_id}
return create_service

def get_service_by_name(self, service_name):
Expand Down Expand Up @@ -190,31 +190,31 @@ def create_backend(self, url_data, service_id, service_version):
request_dict = {k: v[0] for k, v in url_data}

create_backend = {
u'comment': '',
u'shield': None,
u'weight': 100,
u'ssl_client_key': None,
u'first_byte_timeout': 15000,
u'auto_loadbalance': False,
u'use_ssl': request_dict['use_ssl'],
u'port': request_dict['port'],
u'ssl_hostname': None,
u'hostname': request_dict['name'],
u'error_threshold': 0,
u'max_conn': 20,
u'version': service_version,
u'ipv4': None,
u'ipv6': None,
u'client_cert': None,
u'ssl_ca_cert': None,
u'request_condition': '',
u'healthcheck': None,
u'address': request_dict['address'],
u'ssl_client_cert': None,
u'name': request_dict['name'],
u'connect_timeout': 1000,
u'between_bytes_timeout': 10000,
u'service_id': service_id}
'comment': '',
'shield': None,
'weight': 100,
'ssl_client_key': None,
'first_byte_timeout': 15000,
'auto_loadbalance': False,
'use_ssl': request_dict['use_ssl'],
'port': request_dict['port'],
'ssl_hostname': None,
'hostname': request_dict['name'],
'error_threshold': 0,
'max_conn': 20,
'version': service_version,
'ipv4': None,
'ipv6': None,
'client_cert': None,
'ssl_ca_cert': None,
'request_condition': '',
'healthcheck': None,
'address': request_dict['address'],
'ssl_client_cert': None,
'name': request_dict['name'],
'connect_timeout': 1000,
'between_bytes_timeout': 10000,
'service_id': service_id}

if 'origin_list' not in self.fastly_cache[service_id]:
self.fastly_cache[service_id]['origin_list'] = []
Expand All @@ -234,13 +234,13 @@ def create_condition(self, url_data, service_id, service_version):
request_dict = {k: v[0] for k, v in url_data}

create_condition = {
u"type": "REQUEST",
u"comment": "",
u"name": "condition",
u"version": service_version,
u"service_id": service_id,
u"statement": request_dict['statement'],
u"priority": request_dict['priority']
"type": "REQUEST",
"comment": "",
"name": "condition",
"version": service_version,
"service_id": service_id,
"statement": request_dict['statement'],
"priority": request_dict['priority']
}

if 'condition_list' not in self.fastly_cache[service_id]:
Expand Down Expand Up @@ -374,14 +374,14 @@ def get_service_details(self, service_id):
"""
version_details = self.fastly_cache[service_id]['service_details']
service_details = {
u'id': service_id,
u'name': self.fastly_cache[service_id]['service_name'],
u'customer_id': "hTE5dRlSBICGPJxJwCH4M",
u'comment': "",
u"updated_at": "2012-06-14T21:20:19+00:00",
u"created_at": "2012-06-14T21:20:19+00:00",
u"publish_key": "xgdbdd93h5066f8d330c276fDe00f9d293abfex7",
u'versions': [version_details]}
'id': service_id,
'name': self.fastly_cache[service_id]['service_name'],
'customer_id': "hTE5dRlSBICGPJxJwCH4M",
'comment': "",
"updated_at": "2012-06-14T21:20:19+00:00",
"created_at": "2012-06-14T21:20:19+00:00",
"publish_key": "xgdbdd93h5066f8d330c276fDe00f9d293abfex7",
'versions': [version_details]}

return service_details

Expand Down
2 changes: 1 addition & 1 deletion mimic/canned_responses/glance.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Cannned responses for glance images
"""

from __future__ import absolute_import, division, unicode_literals


from mimic.canned_responses.json.glance.glance_images_json import (images,
image_schema)
Expand Down
2 changes: 1 addition & 1 deletion mimic/canned_responses/json/glance/glance_images_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Glance images
"""

from __future__ import absolute_import, division, unicode_literals


images = {
"images":
Expand Down
2 changes: 1 addition & 1 deletion mimic/canned_responses/loadbalancer.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
add/get/delete/list nodes
"""

from __future__ import absolute_import, division, unicode_literals


from random import randrange

Expand Down
2 changes: 1 addition & 1 deletion mimic/canned_responses/maas_alarm_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Canned responses for MAAS alarm examples.
"""

from __future__ import absolute_import, division, unicode_literals



def alarm_examples():
Expand Down
2 changes: 1 addition & 1 deletion mimic/canned_responses/maas_json_home.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Canned response for monitoring json home
"""

from __future__ import unicode_literals



def json_home(url):
Expand Down
2 changes: 1 addition & 1 deletion mimic/canned_responses/maas_monitoring_zones.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Canned responses for MAAS monitoring zones.
"""

from __future__ import absolute_import, division, unicode_literals



def monitoring_zones():
Expand Down
2 changes: 1 addition & 1 deletion mimic/canned_responses/mimic_presets.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Defines the preset values in the mimic api.
"""

from __future__ import absolute_import, division, unicode_literals



get_presets = {"loadbalancers": {"lb_building": "On create load balancer, keeps the load balancer in "
Expand Down
4 changes: 2 additions & 2 deletions mimic/canned_responses/noit.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Canned response for Noit
"""

from __future__ import absolute_import, division, unicode_literals


import time
from mimic.canned_responses.noit_metrics_fixture import (metrics_common_template,
Expand Down Expand Up @@ -106,7 +106,7 @@ def get_all_checks():
}
}
check_list = []
for key, value in noit_cache.items():
for key, value in list(noit_cache.items()):
each_check = value["check"]["attributes"]
each_check["uuid"] = key
each_check["config"] = value["check"]["config"]
Expand Down
2 changes: 1 addition & 1 deletion mimic/canned_responses/noit_metrics_fixture.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Fixtures for metrics
"""

from __future__ import absolute_import, division, unicode_literals


# Remove this when changing over to object model
# as this is repeated within the check_template
Expand Down
2 changes: 1 addition & 1 deletion mimic/canned_responses/nova.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Canned responses for nova's GET limits API
"""

from __future__ import absolute_import, division, unicode_literals



def get_limit():
Expand Down
6 changes: 3 additions & 3 deletions mimic/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Classes which represent the objects within the service catalog.
"""

from __future__ import absolute_import, division, unicode_literals


__all__ = ("Endpoint", "Entry")

Expand Down Expand Up @@ -70,11 +70,11 @@ def url_with_prefix(self, uri_prefix, internal_url=False):
# internal_url is ignored as anything hosted internally in
# mimic will always use the same URL.
postfix = self.tenant_id
segments = [uri_prefix.rstrip(u"/")]
segments = [uri_prefix.rstrip("/")]
if self.prefix is not None:
segments.append(self.prefix)
segments.append(postfix)
return u"/".join(segments)
return "/".join(segments)


class Entry(object):
Expand Down
Loading