Initial version
This commit is contained in:
parent
34ceeb1e6e
commit
c69b68fc81
|
@ -0,0 +1,79 @@
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<!-- POM Build file for the Orchestration API Developer Guide -->
|
||||||
|
<!-- ################################################ -->
|
||||||
|
<!-- USE "mvn clean generate-sources" to run this POM -->
|
||||||
|
<!-- ################################################ -->
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<groupId>org.openstack.identity</groupId>
|
||||||
|
<artifactId>docs</artifactId>
|
||||||
|
<version>1.0</version>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
<name>OpenStack API Page Project</name>
|
||||||
|
<profiles>
|
||||||
|
<profile>
|
||||||
|
<id>Rackspace Research Repositories</id>
|
||||||
|
<activation>
|
||||||
|
<activeByDefault>true</activeByDefault>
|
||||||
|
</activation>
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>rackspace-research</id>
|
||||||
|
<name>Rackspace Research Repository</name>
|
||||||
|
<url>http://maven.research.rackspacecloud.com/content/groups/public/</url>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
<pluginRepositories>
|
||||||
|
<pluginRepository>
|
||||||
|
<id>rackspace-research</id>
|
||||||
|
<name>Rackspace Research Repository</name>
|
||||||
|
<url>http://maven.research.rackspacecloud.com/content/groups/public/</url>
|
||||||
|
<snapshots>
|
||||||
|
<updatePolicy>always</updatePolicy>
|
||||||
|
</snapshots>
|
||||||
|
</pluginRepository>
|
||||||
|
</pluginRepositories>
|
||||||
|
</profile>
|
||||||
|
</profiles>
|
||||||
|
<properties>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
<doctools.version>1.12.2</doctools.version>
|
||||||
|
</properties>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>com.rackspace.cloud.api</groupId>
|
||||||
|
<artifactId>clouddocs-maven-plugin</artifactId>
|
||||||
|
<version>${doctools.version}</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>g1</id>
|
||||||
|
<goals>
|
||||||
|
<goal>generate-webhelp</goal>
|
||||||
|
</goals>
|
||||||
|
<phase>generate-sources</phase>
|
||||||
|
<configuration>
|
||||||
|
<highlightSource>false</highlightSource>
|
||||||
|
<enableGoogleAnalytics>1</enableGoogleAnalytics>
|
||||||
|
<googleAnalyticsId>UA-17511903-1</googleAnalyticsId>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
<configuration>
|
||||||
|
<!-- These parameters apply to pdf and webhelp -->
|
||||||
|
<xincludeSupported>true</xincludeSupported>
|
||||||
|
<sourceDirectory>src/docbkx</sourceDirectory>
|
||||||
|
<includes>
|
||||||
|
api-ref.xml
|
||||||
|
</includes>
|
||||||
|
<profileSecurity>reviewer</profileSecurity>
|
||||||
|
<branding>openstack</branding>
|
||||||
|
<trimWadlUriCount>2</trimWadlUriCount>
|
||||||
|
<showXslMessages>true</showXslMessages>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
|
@ -0,0 +1,126 @@
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
# License for the specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
|
||||||
|
import eventlet
|
||||||
|
from oslo.config import cfg
|
||||||
|
import oslo.messaging
|
||||||
|
from oslo.serialization import jsonutils
|
||||||
|
from osprofiler import profiler
|
||||||
|
|
||||||
|
from senlin.common import context
|
||||||
|
|
||||||
|
|
||||||
|
TRANSPORT = None
|
||||||
|
NOTIFIER = None
|
||||||
|
|
||||||
|
_ALIASES = {
|
||||||
|
'senlin.openstack.common.rpc.impl_kombu': 'rabbit',
|
||||||
|
'senlin.openstack.common.rpc.impl_qpid': 'qpid',
|
||||||
|
'senlin.openstack.common.rpc.impl_zmq': 'zmq',
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class RequestContextSerializer(oslo.messaging.Serializer):
|
||||||
|
def __init__(self, base):
|
||||||
|
self._base = base
|
||||||
|
|
||||||
|
def serialize_entity(self, ctxt, entity):
|
||||||
|
if not self._base:
|
||||||
|
return entity
|
||||||
|
return self._base.serialize_entity(ctxt, entity)
|
||||||
|
|
||||||
|
def deserialize_entity(self, ctxt, entity):
|
||||||
|
if not self._base:
|
||||||
|
return entity
|
||||||
|
return self._base.deserialize_entity(ctxt, entity)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def serialize_context(ctxt):
|
||||||
|
_context = ctxt.to_dict()
|
||||||
|
prof = profiler.get()
|
||||||
|
if prof:
|
||||||
|
trace_info = {
|
||||||
|
"hmac_key": prof.hmac_key,
|
||||||
|
"base_id": prof.get_base_id(),
|
||||||
|
"parent_id": prof.get_id()
|
||||||
|
}
|
||||||
|
_context.update({"trace_info": trace_info})
|
||||||
|
return _context
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def deserialize_context(ctxt):
|
||||||
|
trace_info = ctxt.pop("trace_info", None)
|
||||||
|
if trace_info:
|
||||||
|
profiler.init(**trace_info)
|
||||||
|
return context.RequestContext.from_dict(ctxt)
|
||||||
|
|
||||||
|
|
||||||
|
class JsonPayloadSerializer(oslo.messaging.NoOpSerializer):
|
||||||
|
@classmethod
|
||||||
|
def serialize_entity(cls, context, entity):
|
||||||
|
return jsonutils.to_primitive(entity, convert_instances=True)
|
||||||
|
|
||||||
|
|
||||||
|
def setup(url=None, optional=False):
|
||||||
|
"""Initialise the oslo.messaging layer."""
|
||||||
|
global TRANSPORT, NOTIFIER
|
||||||
|
|
||||||
|
if url and url.startswith("fake://"):
|
||||||
|
# NOTE(sileht): oslo.messaging fake driver uses time.sleep
|
||||||
|
# for task switch, so we need to monkey_patch it
|
||||||
|
eventlet.monkey_patch(time=True)
|
||||||
|
|
||||||
|
if not TRANSPORT:
|
||||||
|
oslo.messaging.set_transport_defaults('senlin')
|
||||||
|
exmods = ['senlin.common.exception']
|
||||||
|
try:
|
||||||
|
TRANSPORT = oslo.messaging.get_transport(
|
||||||
|
cfg.CONF, url, allowed_remote_exmods=exmods, aliases=_ALIASES)
|
||||||
|
except oslo.messaging.InvalidTransportURL as e:
|
||||||
|
TRANSPORT = None
|
||||||
|
if not optional or e.url:
|
||||||
|
# NOTE(sileht): oslo.messaging is configured but unloadable
|
||||||
|
# so reraise the exception
|
||||||
|
raise
|
||||||
|
|
||||||
|
if not NOTIFIER and TRANSPORT:
|
||||||
|
serializer = RequestContextSerializer(JsonPayloadSerializer())
|
||||||
|
NOTIFIER = oslo.messaging.Notifier(TRANSPORT, serializer=serializer)
|
||||||
|
|
||||||
|
|
||||||
|
def cleanup():
|
||||||
|
"""Cleanup the oslo.messaging layer."""
|
||||||
|
global TRANSPORT, NOTIFIER
|
||||||
|
if TRANSPORT:
|
||||||
|
TRANSPORT.cleanup()
|
||||||
|
TRANSPORT = NOTIFIER = None
|
||||||
|
|
||||||
|
|
||||||
|
def get_rpc_server(target, endpoint):
|
||||||
|
"""Return a configured oslo.messaging rpc server."""
|
||||||
|
serializer = RequestContextSerializer(JsonPayloadSerializer())
|
||||||
|
return oslo.messaging.get_rpc_server(TRANSPORT, target, [endpoint],
|
||||||
|
executor='eventlet',
|
||||||
|
serializer=serializer)
|
||||||
|
|
||||||
|
|
||||||
|
def get_rpc_client(**kwargs):
|
||||||
|
"""Return a configured oslo.messaging RPCClient."""
|
||||||
|
target = oslo.messaging.Target(**kwargs)
|
||||||
|
serializer = RequestContextSerializer(JsonPayloadSerializer())
|
||||||
|
return oslo.messaging.RPCClient(TRANSPORT, target,
|
||||||
|
serializer=serializer)
|
||||||
|
|
||||||
|
|
||||||
|
def get_notifier(publisher_id):
|
||||||
|
"""Return a configured oslo.messaging notifier."""
|
||||||
|
return NOTIFIER.prepare(publisher_id=publisher_id)
|
Loading…
Reference in New Issue