first stage in neutron plugin
Change-Id: I018b846462894637371654d7eba63a377577e233
This commit is contained in:
parent
b95f625216
commit
c36a900d20
@ -9,6 +9,7 @@ python-ceilometerclient>=2.2.1 # Apache-2.0
|
||||
python-cinderclient>=1.3.1 # Apache-2.0
|
||||
python-dateutil>=2.4.2
|
||||
python-keystoneclient!=1.8.0,!=2.1.0,>=1.6.0 # Apache-2.0
|
||||
python-neutronclient!=4.1.0,>=2.6.0 # Apache-2.0
|
||||
python-novaclient>=2.26.0
|
||||
networkx>=1.10
|
||||
oslo.config>=2.7.0 # Apache-2.0
|
||||
|
@ -10,6 +10,7 @@ lxml>=2.3
|
||||
networkx>=1.10
|
||||
python-ceilometerclient>=2.2.1 # Apache-2.0
|
||||
python-cinderclient>=1.3.1 # Apache-2.0
|
||||
python-neutronclient!=4.1.0,>=2.6.0 # Apache-2.0
|
||||
python-novaclient>=2.26.0
|
||||
python-subunit>=0.0.18
|
||||
sphinx!=1.2.0,!=1.3b1,<1.3,>=1.1.2
|
||||
|
@ -17,6 +17,7 @@ from oslo_log import log
|
||||
|
||||
from ceilometerclient import client as cm_client
|
||||
from cinderclient import client as cin_client
|
||||
from neutronclient.v2_0 import client as ne_client
|
||||
from novaclient import client as n_client
|
||||
|
||||
|
||||
@ -76,3 +77,18 @@ def cinder_client(conf):
|
||||
return client
|
||||
except Exception as e:
|
||||
LOG.exception('Create Cinder client - Got Exception: %s', e)
|
||||
|
||||
|
||||
def neutron_client(conf):
|
||||
"""Get an instance of neutron client"""
|
||||
auth_config = conf.service_credentials
|
||||
try:
|
||||
client = ne_client.Client(
|
||||
session=keystone_client.get_session(conf),
|
||||
region_name=auth_config.region_name,
|
||||
interface=auth_config.interface,
|
||||
)
|
||||
LOG.info('Neutron client created')
|
||||
return client
|
||||
except Exception as e:
|
||||
LOG.exception('Create Neutron client - Got Exception: %s', e)
|
||||
|
@ -26,8 +26,9 @@ from vitrage.synchronizer.plugins.base.resource.transformer import \
|
||||
BaseResourceTransformer
|
||||
from vitrage.synchronizer.plugins.cinder.volume import CINDER_VOLUME_PLUGIN
|
||||
from vitrage.synchronizer.plugins.nova.instance import NOVA_INSTANCE_PLUGIN
|
||||
from vitrage.synchronizer.plugins import transformer_base
|
||||
from vitrage.synchronizer.plugins.transformer_base import build_key
|
||||
from vitrage.synchronizer.plugins.transformer_base import extract_field_value
|
||||
from vitrage.synchronizer.plugins.transformer_base import Neighbor
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
@ -133,7 +134,7 @@ class CinderVolumeTransformer(BaseResourceTransformer):
|
||||
self.VOLUME_ID[entity_event[SyncProps.SYNC_MODE]])
|
||||
|
||||
key_fields = self._key_values(CINDER_VOLUME_PLUGIN, volume_id)
|
||||
return transformer_base.build_key(key_fields)
|
||||
return build_key(key_fields)
|
||||
|
||||
def create_placeholder_vertex(self, **kwargs):
|
||||
if VProps.ID not in kwargs:
|
||||
@ -143,7 +144,7 @@ class CinderVolumeTransformer(BaseResourceTransformer):
|
||||
key_fields = self._key_values(CINDER_VOLUME_PLUGIN, kwargs[VProps.ID])
|
||||
|
||||
return graph_utils.create_vertex(
|
||||
transformer_base.build_key(key_fields),
|
||||
build_key(key_fields),
|
||||
entity_id=kwargs[VProps.ID],
|
||||
entity_category=EntityCategory.RESOURCE,
|
||||
entity_type=CINDER_VOLUME_PLUGIN,
|
||||
@ -184,4 +185,4 @@ class CinderVolumeTransformer(BaseResourceTransformer):
|
||||
target_id=instance_vertex.vertex_id,
|
||||
relationship_type=EdgeLabels.ATTACHED)
|
||||
|
||||
return transformer_base.Neighbor(instance_vertex, relationship_edge)
|
||||
return Neighbor(instance_vertex, relationship_edge)
|
||||
|
0
vitrage/synchronizer/plugins/neutron/__init__.py
Normal file
0
vitrage/synchronizer/plugins/neutron/__init__.py
Normal file
27
vitrage/synchronizer/plugins/neutron/base.py
Normal file
27
vitrage/synchronizer/plugins/neutron/base.py
Normal file
@ -0,0 +1,27 @@
|
||||
# Copyright 2016 - Alcatel-Lucent
|
||||
#
|
||||
# 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.
|
||||
|
||||
|
||||
from vitrage import clients
|
||||
from vitrage.synchronizer.plugins.synchronizer_base import SynchronizerBase
|
||||
|
||||
|
||||
class NeutronBase(SynchronizerBase):
|
||||
def __init__(self, conf):
|
||||
super(NeutronBase, self).__init__()
|
||||
self.client = clients.neutron_client(conf)
|
||||
self.conf = conf
|
||||
|
||||
def get_client(self):
|
||||
return self.client
|
30
vitrage/synchronizer/plugins/neutron/network/__init__.py
Normal file
30
vitrage/synchronizer/plugins/neutron/network/__init__.py
Normal file
@ -0,0 +1,30 @@
|
||||
# Copyright 2016 - Nokia
|
||||
#
|
||||
# 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.
|
||||
|
||||
from oslo_config import cfg
|
||||
|
||||
NEUTRON_NETWORK_PLUGIN = 'neutron.network'
|
||||
|
||||
OPTS = [
|
||||
cfg.StrOpt('transformer',
|
||||
default='vitrage.synchronizer.plugins.neutron.network.'
|
||||
'transformer.NetworkTransformer',
|
||||
help='Neutron network transformer class path',
|
||||
required=True),
|
||||
cfg.StrOpt('synchronizer',
|
||||
default='vitrage.synchronizer.plugins.neutron.network.'
|
||||
'synchronizer.NetworkSynchronizer',
|
||||
help='Neutron network synchronizer class path',
|
||||
required=True),
|
||||
]
|
41
vitrage/synchronizer/plugins/neutron/network/synchronizer.py
Normal file
41
vitrage/synchronizer/plugins/neutron/network/synchronizer.py
Normal file
@ -0,0 +1,41 @@
|
||||
# Copyright 2016 - Alcatel-Lucent
|
||||
#
|
||||
# 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.
|
||||
|
||||
from vitrage.synchronizer.plugins.neutron.base import NeutronBase
|
||||
from vitrage.synchronizer.plugins.neutron.network import NEUTRON_NETWORK_PLUGIN
|
||||
|
||||
|
||||
class NetworkSynchronizer(NeutronBase):
|
||||
|
||||
@staticmethod
|
||||
def get_topic(conf):
|
||||
pass
|
||||
|
||||
@staticmethod
|
||||
def get_event_types(conf):
|
||||
pass
|
||||
|
||||
@staticmethod
|
||||
def enrich_event(event, event_type):
|
||||
pass
|
||||
|
||||
@staticmethod
|
||||
def extract(networks):
|
||||
return [network.__dict__ for network in networks]
|
||||
|
||||
def get_all(self, sync_mode):
|
||||
return self.make_pickleable(
|
||||
self.extract(self.client.list_networks()),
|
||||
NEUTRON_NETWORK_PLUGIN,
|
||||
sync_mode)
|
20
vitrage/synchronizer/plugins/neutron/network/transformer.py
Normal file
20
vitrage/synchronizer/plugins/neutron/network/transformer.py
Normal file
@ -0,0 +1,20 @@
|
||||
# Copyright 2016 - Alcatel-Lucent
|
||||
#
|
||||
# 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.
|
||||
|
||||
from vitrage.synchronizer.plugins.base.resource.transformer import \
|
||||
BaseResourceTransformer
|
||||
|
||||
|
||||
class NetworkTransformer(BaseResourceTransformer):
|
||||
pass
|
30
vitrage/synchronizer/plugins/neutron/port/__init__.py
Normal file
30
vitrage/synchronizer/plugins/neutron/port/__init__.py
Normal file
@ -0,0 +1,30 @@
|
||||
# Copyright 2016 - Nokia
|
||||
#
|
||||
# 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.
|
||||
|
||||
from oslo_config import cfg
|
||||
|
||||
NEUTRON_PORT_PLUGIN = 'neutron.port'
|
||||
|
||||
OPTS = [
|
||||
cfg.StrOpt('transformer',
|
||||
default='vitrage.synchronizer.plugins.neutron.port.'
|
||||
'transformer.PortTransformer',
|
||||
help='Neutron port transformer class path',
|
||||
required=True),
|
||||
cfg.StrOpt('synchronizer',
|
||||
default='vitrage.synchronizer.plugins.neutron.port.'
|
||||
'synchronizer.PortSynchronizer',
|
||||
help='Neutron port synchronizer class path',
|
||||
required=True),
|
||||
]
|
41
vitrage/synchronizer/plugins/neutron/port/synchronizer.py
Normal file
41
vitrage/synchronizer/plugins/neutron/port/synchronizer.py
Normal file
@ -0,0 +1,41 @@
|
||||
# Copyright 2016 - Alcatel-Lucent
|
||||
#
|
||||
# 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.
|
||||
|
||||
from vitrage.synchronizer.plugins.neutron.base import NeutronBase
|
||||
from vitrage.synchronizer.plugins.neutron.port import NEUTRON_PORT_PLUGIN
|
||||
|
||||
|
||||
class PortSynchronizer(NeutronBase):
|
||||
|
||||
@staticmethod
|
||||
def get_topic(conf):
|
||||
pass
|
||||
|
||||
@staticmethod
|
||||
def get_event_types(conf):
|
||||
pass
|
||||
|
||||
@staticmethod
|
||||
def enrich_event(event, event_type):
|
||||
pass
|
||||
|
||||
@staticmethod
|
||||
def extract(ports):
|
||||
return [port.__dict__ for port in ports]
|
||||
|
||||
def get_all(self, sync_mode):
|
||||
return self.make_pickleable(
|
||||
self.extract(self.client.list_ports()),
|
||||
NEUTRON_PORT_PLUGIN,
|
||||
sync_mode)
|
20
vitrage/synchronizer/plugins/neutron/port/transformer.py
Normal file
20
vitrage/synchronizer/plugins/neutron/port/transformer.py
Normal file
@ -0,0 +1,20 @@
|
||||
# Copyright 2016 - Alcatel-Lucent
|
||||
#
|
||||
# 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.
|
||||
|
||||
from vitrage.synchronizer.plugins.base.resource.transformer import \
|
||||
BaseResourceTransformer
|
||||
|
||||
|
||||
class PortTransformer(BaseResourceTransformer):
|
||||
pass
|
Loading…
x
Reference in New Issue
Block a user