- name: install ipaddress
pip: name=ipaddress state=latest
+ - name: install urllib
+ pip: name=urllib state=latest
+
from keystone_dummy_api import KeystoneDummyApi
from neutron_dummy_api import NeutronDummyApi
from nova_dummy_api import NovaDummyApi
-
from flask_restful import Resource
from flask import Response, request
from emuvim.api.openstack.openstack_dummies.base_openstack_dummy import BaseOpenstackDummy
+from emuvim.api.openstack.helper import get_host
import logging
import json
resp['image'] = f
# build actual response with headers and everything
r = Response(json.dumps(resp), status=201, mimetype="application/json")
- r.headers.add("Location", "http://%s:%d/v1/images/%s" % (self.api.ip,
+ r.headers.add("Location", "http://%s:%d/v1/images/%s" % (get_host(request),
self.api.port,
img_id))
return r
from flask_restful import Resource
from emuvim.api.openstack.resources import Stack
from emuvim.api.openstack.openstack_dummies.base_openstack_dummy import BaseOpenstackDummy
+from emuvim.api.openstack.helper import get_host
from datetime import datetime
from emuvim.api.openstack.heat_parser import HeatParser
import logging
"id": "v1.0",
"links": [
{
- "href": "http://%s:%d/v2.0" % (self.api.ip, self.api.port),
+ "href": "http://%s:%d/v2.0" % (get_host(request), self.api.port),
"rel": "self"
}
]
"links": [
{
"href": "http://%s:%s/v1/%s/stacks/%s"
- % (self.api.ip, self.api.port, tenant_id, stack.id),
+ % (get_host(request), self.api.port, tenant_id, stack.id),
"rel": "self"
}]}}
"links": [
{
"href": "http://%s:%s/v1/%s/stacks/%s"
- % (self.api.ip, self.api.port, tenant_id, stack.id),
+ % (get_host(request), self.api.port, tenant_id, stack.id),
"rel": "self"
}
],
from flask_restful import Resource
from flask import request, Response
from emuvim.api.openstack.openstack_dummies.base_openstack_dummy import BaseOpenstackDummy
+from emuvim.api.openstack.helper import get_host
import logging
import json
"id": "v2.0",
"links": [
{
- "href": "http://%s:%d/v2.0" % (self.api.ip, self.api.port),
+ "href": "http://%s:%d/v2.0" % (get_host(request), self.api.port),
"rel": "self"
}
],
"id": "v2.0",
"links": [
{
- "href": "http://%s:%d/v2.0" % (self.api.ip, self.api.port),
+ "href": "http://%s:%d/v2.0" % (get_host(request), self.api.port),
"rel": "self"
},
{
- "href": "http://%s:%d/v2.0/tokens" % (self.api.ip, self.api.port),
+ "href": "http://%s:%d/v2.0/tokens" % (get_host(request), self.api.port),
"rel": "self"
},
{
- "href": "http://%s:%d/v2.0/networks" % (self.api.ip, neutron_port),
+ "href": "http://%s:%d/v2.0/networks" % (get_host(request), neutron_port),
"rel": "self"
},
{
- "href": "http://%s:%d/v2.0/subnets" % (self.api.ip, neutron_port),
+ "href": "http://%s:%d/v2.0/subnets" % (get_host(request), neutron_port),
"rel": "self"
},
{
- "href": "http://%s:%d/v2.0/ports" % (self.api.ip, neutron_port),
+ "href": "http://%s:%d/v2.0/ports" % (get_host(request), neutron_port),
"rel": "self"
},
{
- "href": "http://%s:%d/v1/<tenant_id>/stacks" % (self.api.ip, heat_port),
+ "href": "http://%s:%d/v1/<tenant_id>/stacks" % (get_host(request), heat_port),
"rel": "self"
}
]
"id": "v2.0",
"links": [
{
- "href": "http://%s:%d/v2.0" % (self.api.ip, self.api.port),
+ "href": "http://%s:%d/v2.0" % (get_host(request), self.api.port),
"rel": "self"
},
{
- "href": "http://%s:%d/v2.0/tokens" % (self.api.ip, self.api.port),
+ "href": "http://%s:%d/v2.0/tokens" % (get_host(request), self.api.port),
"rel": "self"
},
{
- "href": "http://%s:%d/v2.0/networks" % (self.api.ip, neutron_port),
+ "href": "http://%s:%d/v2.0/networks" % (get_host(request), neutron_port),
"rel": "self"
},
{
- "href": "http://%s:%d/v2.0/subnets" % (self.api.ip, neutron_port),
+ "href": "http://%s:%d/v2.0/subnets" % (get_host(request), neutron_port),
"rel": "self"
},
{
- "href": "http://%s:%d/v2.0/ports" % (self.api.ip, neutron_port),
+ "href": "http://%s:%d/v2.0/ports" % (get_host(request), neutron_port),
"rel": "self"
},
{
- "href": "http://%s:%d/v1/<tenant_id>/stacks" % (self.api.ip, heat_port),
+ "href": "http://%s:%d/v1/<tenant_id>/stacks" % (get_host(request), heat_port),
"rel": "self"
}
]
ret['access']['serviceCatalog'] = [{
"endpoints": [
{
- "adminURL": "http://%s:%s/v2.1/%s" % (self.api.ip, self.api.port + 3774, user['id']),
+ "adminURL": "http://%s:%s/v2.1/%s" % (get_host(request), self.api.port + 3774, user['id']),
"region": "RegionOne",
- "internalURL": "http://%s:%s/v2.1/%s" % (self.api.ip, self.api.port + 3774, user['id']),
+ "internalURL": "http://%s:%s/v2.1/%s" % (get_host(request), self.api.port + 3774, user['id']),
"id": "2dad48f09e2a447a9bf852bcd93548ef",
- "publicURL": "http://%s:%s/v2.1/%s" % (self.api.ip, self.api.port + 3774, user['id'])
+ "publicURL": "http://%s:%s/v2.1/%s" % (get_host(request), self.api.port + 3774, user['id'])
}
],
"endpoints_links": [],
{
"endpoints": [
{
- "adminURL": "http://%s:%s/v2.0" % (self.api.ip, self.api.port),
+ "adminURL": "http://%s:%s/v2.0" % (get_host(request), self.api.port),
"region": "RegionOne",
- "internalURL": "http://%s:%s/v2.0" % (self.api.ip, self.api.port),
+ "internalURL": "http://%s:%s/v2.0" % (get_host(request), self.api.port),
"id": "2dad48f09e2a447a9bf852bcd93543fc",
- "publicURL": "http://%s:%s/v2" % (self.api.ip, self.api.port)
+ "publicURL": "http://%s:%s/v2" % (get_host(request), self.api.port)
}
],
"endpoints_links": [],
{
"endpoints": [
{
- "adminURL": "http://%s:%s" % (self.api.ip, self.api.port + 4696),
+ "adminURL": "http://%s:%s" % (get_host(request), self.api.port + 4696),
"region": "RegionOne",
- "internalURL": "http://%s:%s" % (self.api.ip, self.api.port + 4696),
+ "internalURL": "http://%s:%s" % (get_host(request), self.api.port + 4696),
"id": "2dad48f09e2a447a9bf852bcd93548cf",
- "publicURL": "http://%s:%s" % (self.api.ip, self.api.port + 4696)
+ "publicURL": "http://%s:%s" % (get_host(request), self.api.port + 4696)
}
],
"endpoints_links": [],
{
"endpoints": [
{
- "adminURL": "http://%s:%s" % (self.api.ip, self.api.port + 4242),
+ "adminURL": "http://%s:%s" % (get_host(request), self.api.port + 4242),
"region": "RegionOne",
- "internalURL": "http://%s:%s" % (self.api.ip, self.api.port + 4242),
+ "internalURL": "http://%s:%s" % (get_host(request), self.api.port + 4242),
"id": "2dad48f09e2a447a9bf852bcd93548cf",
- "publicURL": "http://%s:%s" % (self.api.ip, self.api.port + 4242)
+ "publicURL": "http://%s:%s" % (get_host(request), self.api.port + 4242)
}
],
"endpoints_links": [],
{
"endpoints": [
{
- "adminURL": "http://%s:%s/v1/%s" % (self.api.ip, self.api.port + 3004, user['id']),
+ "adminURL": "http://%s:%s/v1/%s" % (get_host(request), self.api.port + 3004, user['id']),
"region": "RegionOne",
- "internalURL": "http://%s:%s/v1/%s" % (self.api.ip, self.api.port + 3004, user['id']),
+ "internalURL": "http://%s:%s/v1/%s" % (get_host(request), self.api.port + 3004, user['id']),
"id": "2dad48f09e2a447a9bf852bcd93548bf",
- "publicURL": "http://%s:%s/v1/%s" % (self.api.ip, self.api.port + 3004, user['id'])
+ "publicURL": "http://%s:%s/v1/%s" % (get_host(request), self.api.port + 3004, user['id'])
}
],
"endpoints_links": [],
token['catalog'] = [{
"endpoints": [
{
- "url": "http://%s:%s/v2.1/%s" % (self.api.ip, self.api.port + 3774, user['id']),
+ "url": "http://%s:%s/v2.1/%s" % (get_host(request), self.api.port + 3774, user['id']),
"region": "RegionOne",
"interface": "public",
"id": "2dad48f09e2a447a9bf852bcd93548ef"
{
"endpoints": [
{
- "url": "http://%s:%s/v2.0" % (self.api.ip, self.api.port),
+ "url": "http://%s:%s/v2.0" % (get_host(request), self.api.port),
"region": "RegionOne",
"interface": "public",
"id": "2dad48f09e2a447a9bf852bcd93543fc"
{
"endpoints": [
{
- "url": "http://%s:%s" % (self.api.ip, self.api.port + 4696),
+ "url": "http://%s:%s" % (get_host(request), self.api.port + 4696),
"region": "RegionOne",
"interface": "public",
"id": "2dad48f09e2a447a9bf852bcd93548cf"
{
"endpoints": [
{
- "url": "http://%s:%s" % (self.api.ip, self.api.port + 4242),
+ "url": "http://%s:%s" % (get_host(request), self.api.port + 4242),
"region": "RegionOne",
"interface": "public",
"id": "2dad48f09e2a447a9bf852bcd93548cf"
{
"endpoints": [
{
- "url": "http://%s:%s/v1/%s" % (self.api.ip, self.api.port + 3004, user['id']),
+ "url": "http://%s:%s/v1/%s" % (get_host(request), self.api.port + 3004, user['id']),
"region": "RegionOne",
"interface": "public",
"id": "2dad48f09e2a447a9bf852bcd93548bf"
from flask_restful import Resource
from flask import request, Response
from emuvim.api.openstack.openstack_dummies.base_openstack_dummy import BaseOpenstackDummy
+from emuvim.api.openstack.helper import get_host
from datetime import datetime
import neutron_sfc_dummy_api as SFC
import logging
import uuid
from emuvim.api.openstack.resources.port_chain import PortChain
+from emuvim.api.openstack.helper import get_host
class SFC(Resource):
from flask_restful import Resource
from flask import Response, request
from emuvim.api.openstack.openstack_dummies.base_openstack_dummy import BaseOpenstackDummy
+from emuvim.api.openstack.helper import get_host
import logging
import json
import uuid
}
]
}
- """ % (self.api.ip, self.api.port)
+ """ % (get_host(request), self.api.port)
response = Response(resp, status=200, mimetype="application/json")
response.headers['Access-Control-Allow-Origin'] = '*'
"updated": "2013-07-23T11:33:21Z"
}
}
- """ % (self.api.ip, self.api.port)
+ """ % (get_host(request), self.api.port)
response = Response(resp, status=200, mimetype="application/json")
response.headers['Access-Control-Allow-Origin'] = '*'
resp['servers'] = list()
for server in self.api.compute.computeUnits.values():
s = server.create_server_dict(self.api.compute)
- s['links'] = [{'href': "http://%s:%d/v2.1/%s/servers/%s" % (self.api.ip,
+ s['links'] = [{'href': "http://%s:%d/v2.1/%s/servers/%s" % (get_host(request),
self.api.port,
id,
server.id)}]
resp['servers'] = list()
for server in self.api.compute.computeUnits.values():
s = server.create_server_dict(self.api.compute)
- s['links'] = [{'href': "http://%s:%d/v2.1/%s/servers/%s" % (self.api.ip,
+ s['links'] = [{'href': "http://%s:%d/v2.1/%s/servers/%s" % (get_host(request),
self.api.port,
id,
server.id)}]
resp = {"servers": list()}
for server in self.api.compute.computeUnits.values():
s = server.create_server_dict(self.api.compute)
- s['links'] = [{'href': "http://%s:%d/v2.1/%s/servers/%s" % (self.api.ip,
+ s['links'] = [{'href': "http://%s:%d/v2.1/%s/servers/%s" % (get_host(request),
self.api.port,
id,
server.id)}]
"id": flavor.id,
"links": [
{
- "href": "http://%s:%d/v2.1/%s/flavors/%s" % (self.api.ip,
+ "href": "http://%s:%d/v2.1/%s/flavors/%s" % (get_host(request),
self.api.port,
id,
flavor.id),
"id": image.id,
"links": [
{
- "href": "http://%s:%d/v2.1/%s/images/%s" % (self.api.ip,
+ "href": "http://%s:%d/v2.1/%s/images/%s" % (get_host(request),
self.api.port,
id,
image.id),
f = flavor.__dict__.copy()
f['id'] = flavor.id
f['name'] = flavor.name
- f['links'] = [{'href': "http://%s:%d/v2.1/%s/flavors/%s" % (self.api.ip,
+ f['links'] = [{'href': "http://%s:%d/v2.1/%s/flavors/%s" % (get_host(request),
self.api.port,
id,
flavor.id)}]
data.get("disk"), "GB")
# create response based on incoming data
data["id"] = f.id
- data["links"] = [{'href': "http://%s:%d/v2.1/%s/flavors/%s" % (self.api.ip,
+ data["links"] = [{'href': "http://%s:%d/v2.1/%s/flavors/%s" % (get_host(request),
self.api.port,
id,
f.id)}]
# but use a copy so we don't modifiy the original
f = flavor.__dict__.copy()
# add additional expected stuff stay openstack compatible
- f['links'] = [{'href': "http://%s:%d/v2.1/%s/flavors/%s" % (self.api.ip,
+ f['links'] = [{'href': "http://%s:%d/v2.1/%s/flavors/%s" % (get_host(request),
self.api.port,
id,
flavor.id)}]
data.get("disk"), "GB")
# create response based on incoming data
data["id"] = f.id
- data["links"] = [{'href': "http://%s:%d/v2.1/%s/flavors/%s" % (self.api.ip,
+ data["links"] = [{'href': "http://%s:%d/v2.1/%s/flavors/%s" % (get_host(request),
self.api.port,
id,
f.id)}]
break
resp['flavor']['id'] = flavor.id
resp['flavor']['name'] = flavor.name
- resp['flavor']['links'] = [{'href': "http://%s:%d/v2.1/%s/flavors/%s" % (self.api.ip,
+ resp['flavor']['links'] = [{'href': "http://%s:%d/v2.1/%s/flavors/%s" % (get_host(request),
self.api.port,
id,
flavor.id)}]
f = dict()
f['id'] = image.id
f['name'] = str(image.name).replace(":latest", "")
- f['links'] = [{'href': "http://%s:%d/v2.1/%s/images/%s" % (self.api.ip,
+ f['links'] = [{'href': "http://%s:%d/v2.1/%s/images/%s" % (get_host(request),
self.api.port,
id,
image.id)}]
f = image.__dict__.copy()
# add additional expected stuff stay openstack compatible
f['name'] = str(image.name).replace(":latest", "")
- f['links'] = [{'href': "http://%s:%d/v2.1/%s/images/%s" % (self.api.ip,
+ f['links'] = [{'href': "http://%s:%d/v2.1/%s/images/%s" % (get_host(request),
self.api.port,
id,
image.id)}]
if server is None:
return Response("Server with id or name %s does not exists." % serverid, status=404)
s = server.create_server_dict()
- s['links'] = [{'href': "http://%s:%d/v2.1/%s/servers/%s" % (self.api.ip,
+ s['links'] = [{'href': "http://%s:%d/v2.1/%s/servers/%s" % (get_host(request),
self.api.port,
id,
server.id)}]
"id": flavor.id,
"links": [
{
- "href": "http://%s:%d/v2.1/%s/flavors/%s" % (self.api.ip,
+ "href": "http://%s:%d/v2.1/%s/flavors/%s" % (get_host(request),
self.api.port,
id,
flavor.id),
"id": image.id,
"links": [
{
- "href": "http://%s:%d/v2.1/%s/images/%s" % (self.api.ip,
+ "href": "http://%s:%d/v2.1/%s/images/%s" % (get_host(request),
self.api.port,
id,
image.id),
from emuvim.api.openstack.openstack_api_endpoint import OpenstackApiEndpoint
logging.basicConfig(level=logging.INFO)
+setLogLevel('info') # set Mininet loglevel
+logging.getLogger('werkzeug').setLevel(logging.DEBUG)
+logging.getLogger('api.openstack.base').setLevel(logging.DEBUG)
+logging.getLogger('api.openstack.compute').setLevel(logging.DEBUG)
+logging.getLogger('api.openstack.keystone').setLevel(logging.DEBUG)
+logging.getLogger('api.openstack.nova').setLevel(logging.DEBUG)
+logging.getLogger('api.openstack.neutron').setLevel(logging.DEBUG)
+logging.getLogger('api.openstack.heat').setLevel(logging.DEBUG)
+logging.getLogger('api.openstack.heat.parser').setLevel(logging.DEBUG)
+logging.getLogger('api.openstack.glance').setLevel(logging.DEBUG)
+logging.getLogger('api.openstack.helper').setLevel(logging.DEBUG)
def create_topology():
def main():
- setLogLevel('info') # set Mininet loglevel
create_topology()
# install son-emu
RUN echo 'install son-emu'
RUN apt-get install -y python-dev python-zmq libzmq-dev libffi-dev libssl-dev
-RUN pip install -U zerorpc tabulate argparse networkx six ryu oslo.config pytest Flask flask_restful requests prometheus_client pyaml
+RUN pip install -U zerorpc tabulate argparse networkx six ryu oslo.config pytest Flask flask_restful requests urllib prometheus_client pyaml
WORKDIR /
#avoid pulling not the latest git, copy the current dir, to run this from Jenkins
#RUN git clone https://github.com/sonata-nfv/son-emu.git
ENTRYPOINT ["/son-emu/utils/docker/entrypoint.sh"]
# dummy GK, cAdvisor, Prometheus Push Gateway, son-emu REST API, OpenStack-fake APIs
-EXPOSE 5000 8081 9091 5001 6001 6002 6003 6004
+EXPOSE 5000 8081 9091 5001 4000 10243 9005 6001 9775 10697