Fix zuul gates for f/centos8
This commit fixes various gate issues on f/centos8, this is being done so we can merge the master branch into the f/centos8 due to an issue with merging branches and zuul. The fixes have been cherry-picked from the master branch: - "Turn off the legacy pip resolver for distcloud" Fix requirements that needed to be updated, also fix bugbear. (527a48513a
) - "Specify the nodeset for zuul jobs" py2.7 jobs need to specify xenial, py3.6 needs to specify bionic. (9f5b85c41c
) - " Remove entries related to host-based snmp" SNMP has been removed in the sysinv repo as a result the distcloud repo is out of sync. This is a temporary workaround until the master branch has been merged. (ec8dba8a53
) Signed-off-by: Charles Short <charles.short@windriver.com> Change-Id: Ife92f0639b4b56aa3a16369613388c33834bca97
This commit is contained in:
parent
a39415ff84
commit
8a5d90815f
|
@ -25,6 +25,7 @@
|
||||||
- job:
|
- job:
|
||||||
name: stx-distcloud-tox-py27
|
name: stx-distcloud-tox-py27
|
||||||
parent: tox
|
parent: tox
|
||||||
|
nodeset: ubuntu-xenial
|
||||||
description: Run py27 for distcloud
|
description: Run py27 for distcloud
|
||||||
required-projects:
|
required-projects:
|
||||||
- starlingx/fault
|
- starlingx/fault
|
||||||
|
@ -37,6 +38,7 @@
|
||||||
|
|
||||||
- job:
|
- job:
|
||||||
name: stx-distcloud-tox-py36
|
name: stx-distcloud-tox-py36
|
||||||
|
nodeset: ubuntu-bionic
|
||||||
parent: tox
|
parent: tox
|
||||||
description: Run py36 for distcloud
|
description: Run py36 for distcloud
|
||||||
required-projects:
|
required-projects:
|
||||||
|
@ -50,6 +52,7 @@
|
||||||
|
|
||||||
- job:
|
- job:
|
||||||
name: stx-distcloud-tox-pylint
|
name: stx-distcloud-tox-pylint
|
||||||
|
nodeset: ubuntu-bionic
|
||||||
parent: tox
|
parent: tox
|
||||||
description: Run pylint for distcloud
|
description: Run pylint for distcloud
|
||||||
required-projects:
|
required-projects:
|
||||||
|
@ -63,6 +66,7 @@
|
||||||
|
|
||||||
- job:
|
- job:
|
||||||
name: stx-distcloud-tox-pep8
|
name: stx-distcloud-tox-pep8
|
||||||
|
nodeset: ubuntu-bionic
|
||||||
parent: tox
|
parent: tox
|
||||||
description: Run pep8 for distcloud
|
description: Run pep8 for distcloud
|
||||||
required-projects:
|
required-projects:
|
||||||
|
|
|
@ -21,12 +21,7 @@
|
||||||
|
|
||||||
import hashlib
|
import hashlib
|
||||||
|
|
||||||
from cgtsclient.exc import HTTPConflict
|
|
||||||
from cgtsclient.exc import HTTPNotFound
|
from cgtsclient.exc import HTTPNotFound
|
||||||
from cgtsclient.v1.icommunity import CREATION_ATTRIBUTES \
|
|
||||||
as SNMP_COMMUNITY_CREATION_ATTRIBUTES
|
|
||||||
from cgtsclient.v1.itrapdest import CREATION_ATTRIBUTES \
|
|
||||||
as SNMP_TRAPDEST_CREATION_ATTRIBUTES
|
|
||||||
from oslo_log import log
|
from oslo_log import log
|
||||||
|
|
||||||
from sysinv.common import constants as sysinv_constants
|
from sysinv.common import constants as sysinv_constants
|
||||||
|
@ -238,137 +233,6 @@ class SysinvClient(base.DriverBase):
|
||||||
|
|
||||||
return idns
|
return idns
|
||||||
|
|
||||||
def snmp_trapdest_list(self):
|
|
||||||
"""Get the trapdest list for this region
|
|
||||||
|
|
||||||
:return: itrapdests list of itrapdest
|
|
||||||
"""
|
|
||||||
itrapdests = self.sysinv_client.itrapdest.list()
|
|
||||||
return itrapdests
|
|
||||||
|
|
||||||
def snmp_trapdest_create(self, trapdest_dict):
|
|
||||||
"""Add the trapdest for this region
|
|
||||||
|
|
||||||
:param: trapdest_payload dictionary
|
|
||||||
:return: itrapdest
|
|
||||||
"""
|
|
||||||
|
|
||||||
# Example trapdest_dict:
|
|
||||||
# {"ip_address": "10.10.10.12", "community": "cgcs"}
|
|
||||||
itrapdest = None
|
|
||||||
trapdest_create_dict = {}
|
|
||||||
for k, v in trapdest_dict.items():
|
|
||||||
if k in SNMP_TRAPDEST_CREATION_ATTRIBUTES:
|
|
||||||
trapdest_create_dict[str(k)] = v
|
|
||||||
|
|
||||||
LOG.info("snmp_trapdest_create driver region={}"
|
|
||||||
"trapdest_create_dict={}".format(
|
|
||||||
self.region_name, trapdest_create_dict))
|
|
||||||
try:
|
|
||||||
itrapdest = self.sysinv_client.itrapdest.create(
|
|
||||||
**trapdest_create_dict)
|
|
||||||
except HTTPConflict:
|
|
||||||
LOG.info("snmp_trapdest_create exists region={}"
|
|
||||||
"trapdest_dict={}".format(
|
|
||||||
self.region_name, trapdest_dict))
|
|
||||||
# Retrieve the existing itrapdest
|
|
||||||
trapdests = self.snmp_trapdest_list()
|
|
||||||
for trapdest in trapdests:
|
|
||||||
if trapdest.ip_address == trapdest_dict.get('ip_address'):
|
|
||||||
LOG.info("snmp_trapdest_create found existing {}"
|
|
||||||
"for region: {}".format(
|
|
||||||
trapdest, self.region_name))
|
|
||||||
itrapdest = trapdest
|
|
||||||
break
|
|
||||||
except Exception as e:
|
|
||||||
LOG.error("snmp_trapdest_create exception={}".format(e))
|
|
||||||
raise e
|
|
||||||
|
|
||||||
return itrapdest
|
|
||||||
|
|
||||||
def snmp_trapdest_delete(self, trapdest_ip_address):
|
|
||||||
"""Delete the trapdest for this region
|
|
||||||
|
|
||||||
:param: trapdest_ip_address
|
|
||||||
"""
|
|
||||||
try:
|
|
||||||
LOG.info("snmp_trapdest_delete region {} ip_address: {}".format(
|
|
||||||
self.region_name, trapdest_ip_address))
|
|
||||||
self.sysinv_client.itrapdest.delete(trapdest_ip_address)
|
|
||||||
except HTTPNotFound:
|
|
||||||
LOG.info("snmp_trapdest_delete NotFound {} for region: {}".format(
|
|
||||||
trapdest_ip_address, self.region_name))
|
|
||||||
raise exceptions.TrapDestNotFound(region_name=self.region_name,
|
|
||||||
ip_address=trapdest_ip_address)
|
|
||||||
except Exception as e:
|
|
||||||
LOG.error("snmp_trapdest_delete exception={}".format(e))
|
|
||||||
raise e
|
|
||||||
|
|
||||||
def snmp_community_list(self):
|
|
||||||
"""Get the community list for this region
|
|
||||||
|
|
||||||
:return: icommunitys list of icommunity
|
|
||||||
"""
|
|
||||||
icommunitys = self.sysinv_client.icommunity.list()
|
|
||||||
return icommunitys
|
|
||||||
|
|
||||||
def snmp_community_create(self, community_dict):
|
|
||||||
"""Add the community for this region
|
|
||||||
|
|
||||||
:param: community_payload dictionary
|
|
||||||
:return: icommunity
|
|
||||||
"""
|
|
||||||
|
|
||||||
# Example community_dict: {"community": "cgcs"}
|
|
||||||
icommunity = None
|
|
||||||
community_create_dict = {}
|
|
||||||
for k, v in community_dict.items():
|
|
||||||
if k in SNMP_COMMUNITY_CREATION_ATTRIBUTES:
|
|
||||||
community_create_dict[str(k)] = v
|
|
||||||
|
|
||||||
LOG.info("snmp_community_create driver region={}"
|
|
||||||
"community_create_dict={}".format(
|
|
||||||
self.region_name, community_create_dict))
|
|
||||||
try:
|
|
||||||
icommunity = self.sysinv_client.icommunity.create(
|
|
||||||
**community_create_dict)
|
|
||||||
except HTTPConflict:
|
|
||||||
LOG.info("snmp_community_create exists region={}"
|
|
||||||
"community_dict={}".format(
|
|
||||||
self.region_name, community_dict))
|
|
||||||
# Retrieve the existing icommunity
|
|
||||||
communitys = self.snmp_community_list()
|
|
||||||
for community in communitys:
|
|
||||||
if community.community == community_dict.get('community'):
|
|
||||||
LOG.info("snmp_community_create found existing {}"
|
|
||||||
"for region: {}".format(
|
|
||||||
community, self.region_name))
|
|
||||||
icommunity = community
|
|
||||||
break
|
|
||||||
except Exception as e:
|
|
||||||
LOG.error("snmp_community_create exception={}".format(e))
|
|
||||||
raise e
|
|
||||||
|
|
||||||
return icommunity
|
|
||||||
|
|
||||||
def snmp_community_delete(self, community):
|
|
||||||
"""Delete the community for this region
|
|
||||||
|
|
||||||
:param: community
|
|
||||||
"""
|
|
||||||
try:
|
|
||||||
LOG.info("snmp_community_delete region {} community: {}".format(
|
|
||||||
self.region_name, community))
|
|
||||||
self.sysinv_client.icommunity.delete(community)
|
|
||||||
except HTTPNotFound:
|
|
||||||
LOG.info("snmp_community_delete NotFound {} for region: {}".format(
|
|
||||||
community, self.region_name))
|
|
||||||
raise exceptions.CommunityNotFound(region_name=self.region_name,
|
|
||||||
community=community)
|
|
||||||
except Exception as e:
|
|
||||||
LOG.error("snmp_community_delete exception={}".format(e))
|
|
||||||
raise e
|
|
||||||
|
|
||||||
def get_certificates(self):
|
def get_certificates(self):
|
||||||
"""Get the certificates for this region
|
"""Get the certificates for this region
|
||||||
|
|
||||||
|
|
|
@ -81,20 +81,6 @@ class OAMAddressesNotFound(NotFound):
|
||||||
message = _("OAM Addresses Not Found")
|
message = _("OAM Addresses Not Found")
|
||||||
|
|
||||||
|
|
||||||
class TrapDestNotFound(NotFound):
|
|
||||||
message = _("Trapdest in region=%(region_name)s with ip_address "
|
|
||||||
"%(ip_address)s not found")
|
|
||||||
|
|
||||||
|
|
||||||
class CommunityAlreadyExists(Conflict):
|
|
||||||
message = _("Community %(community)s in region=%(region_name)s "
|
|
||||||
"already exists")
|
|
||||||
|
|
||||||
|
|
||||||
class CommunityNotFound(NotFound):
|
|
||||||
message = _("Community %(community)s not found in region=%(region_name)s")
|
|
||||||
|
|
||||||
|
|
||||||
class CertificateNotFound(NotFound):
|
class CertificateNotFound(NotFound):
|
||||||
message = _("Certificate in region=%(region_name)s with signature "
|
message = _("Certificate in region=%(region_name)s with signature "
|
||||||
"%(signature)s not found")
|
"%(signature)s not found")
|
||||||
|
|
|
@ -26,12 +26,6 @@ from dcdbsync.common import context
|
||||||
TRANSPORT = None
|
TRANSPORT = None
|
||||||
NOTIFIER = None
|
NOTIFIER = None
|
||||||
|
|
||||||
_ALIASES = {
|
|
||||||
'dcdbsync.openstack.common.rpc.impl_kombu': 'rabbit',
|
|
||||||
'dcdbsync.openstack.common.rpc.impl_qpid': 'qpid',
|
|
||||||
'dcdbsync.openstack.common.rpc.impl_zmq': 'zmq',
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class RequestContextSerializer(oslo_messaging.Serializer):
|
class RequestContextSerializer(oslo_messaging.Serializer):
|
||||||
def __init__(self, base):
|
def __init__(self, base):
|
||||||
|
@ -76,7 +70,7 @@ def setup(url=None, optional=False):
|
||||||
exmods = ['dcdbsync.common.exception']
|
exmods = ['dcdbsync.common.exception']
|
||||||
try:
|
try:
|
||||||
TRANSPORT = oslo_messaging.get_transport(
|
TRANSPORT = oslo_messaging.get_transport(
|
||||||
cfg.CONF, url, allowed_remote_exmods=exmods, aliases=_ALIASES)
|
cfg.CONF, url, allowed_remote_exmods=exmods)
|
||||||
except oslo_messaging.InvalidTransportURL as e:
|
except oslo_messaging.InvalidTransportURL as e:
|
||||||
TRANSPORT = None
|
TRANSPORT = None
|
||||||
if not optional or e.url:
|
if not optional or e.url:
|
||||||
|
|
|
@ -370,10 +370,6 @@ class ComputeAPIController(APIController):
|
||||||
class SysinvAPIController(APIController):
|
class SysinvAPIController(APIController):
|
||||||
|
|
||||||
ENDPOINT_TYPE = consts.ENDPOINT_TYPE_PLATFORM
|
ENDPOINT_TYPE = consts.ENDPOINT_TYPE_PLATFORM
|
||||||
RESOURCE_ID_MAP = {
|
|
||||||
consts.RESOURCE_TYPE_SYSINV_SNMP_TRAPDEST: 'ip_address',
|
|
||||||
consts.RESOURCE_TYPE_SYSINV_SNMP_COMM: 'community'
|
|
||||||
}
|
|
||||||
OK_STATUS_CODE = [
|
OK_STATUS_CODE = [
|
||||||
webob.exc.HTTPOk.code,
|
webob.exc.HTTPOk.code,
|
||||||
webob.exc.HTTPNoContent.code
|
webob.exc.HTTPNoContent.code
|
||||||
|
@ -414,14 +410,7 @@ class SysinvAPIController(APIController):
|
||||||
else:
|
else:
|
||||||
resource_ids = [resource.get('signature')]
|
resource_ids = [resource.get('signature')]
|
||||||
else:
|
else:
|
||||||
if (operation_type == consts.OPERATION_TYPE_POST and
|
resource_id = self.get_resource_id_from_link(request_header)
|
||||||
resource_type in self.RESOURCE_ID_MAP):
|
|
||||||
# need to get the id from the request data since it is
|
|
||||||
# not available in the header
|
|
||||||
rid = self.RESOURCE_ID_MAP.get(resource_type)
|
|
||||||
resource_id = json.loads(request_body)[rid]
|
|
||||||
else:
|
|
||||||
resource_id = self.get_resource_id_from_link(request_header)
|
|
||||||
resource_ids = [resource_id]
|
resource_ids = [resource_id]
|
||||||
if operation_type != consts.OPERATION_TYPE_DELETE:
|
if operation_type != consts.OPERATION_TYPE_DELETE:
|
||||||
resource_info['payload'] = json.loads(request_body)
|
resource_info['payload'] = json.loads(request_body)
|
||||||
|
|
|
@ -80,16 +80,6 @@ DNS_PATHS = [
|
||||||
'/v1/idns/{uuid}'
|
'/v1/idns/{uuid}'
|
||||||
]
|
]
|
||||||
|
|
||||||
TRAP_DEST_PATHS = [
|
|
||||||
'/v1/itrapdest',
|
|
||||||
'/v1/itrapdest/{ip}'
|
|
||||||
]
|
|
||||||
|
|
||||||
COMMUNITY_STRING_PATHS = [
|
|
||||||
'/v1/icommunity',
|
|
||||||
'/v1/icommunity/{community}'
|
|
||||||
]
|
|
||||||
|
|
||||||
CERTIFICATE_PATHS = [
|
CERTIFICATE_PATHS = [
|
||||||
'/v1/certificate/certificate_install',
|
'/v1/certificate/certificate_install',
|
||||||
'/v1/certificate/{uuid}'
|
'/v1/certificate/{uuid}'
|
||||||
|
@ -102,8 +92,6 @@ USER_PATHS = [
|
||||||
|
|
||||||
SYSINV_PATH_MAP = {
|
SYSINV_PATH_MAP = {
|
||||||
consts.RESOURCE_TYPE_SYSINV_DNS: DNS_PATHS,
|
consts.RESOURCE_TYPE_SYSINV_DNS: DNS_PATHS,
|
||||||
consts.RESOURCE_TYPE_SYSINV_SNMP_TRAPDEST: TRAP_DEST_PATHS,
|
|
||||||
consts.RESOURCE_TYPE_SYSINV_SNMP_COMM: COMMUNITY_STRING_PATHS,
|
|
||||||
consts.RESOURCE_TYPE_SYSINV_CERTIFICATE: CERTIFICATE_PATHS,
|
consts.RESOURCE_TYPE_SYSINV_CERTIFICATE: CERTIFICATE_PATHS,
|
||||||
consts.RESOURCE_TYPE_SYSINV_USER: USER_PATHS,
|
consts.RESOURCE_TYPE_SYSINV_USER: USER_PATHS,
|
||||||
}
|
}
|
||||||
|
@ -314,8 +302,6 @@ ROUTE_METHOD_MAP = {
|
||||||
},
|
},
|
||||||
consts.ENDPOINT_TYPE_PLATFORM: {
|
consts.ENDPOINT_TYPE_PLATFORM: {
|
||||||
consts.RESOURCE_TYPE_SYSINV_DNS: ['PATCH', 'PUT'],
|
consts.RESOURCE_TYPE_SYSINV_DNS: ['PATCH', 'PUT'],
|
||||||
consts.RESOURCE_TYPE_SYSINV_SNMP_TRAPDEST: ['POST', 'DELETE'],
|
|
||||||
consts.RESOURCE_TYPE_SYSINV_SNMP_COMM: ['POST', 'DELETE'],
|
|
||||||
consts.RESOURCE_TYPE_SYSINV_CERTIFICATE: ['POST', 'DELETE'],
|
consts.RESOURCE_TYPE_SYSINV_CERTIFICATE: ['POST', 'DELETE'],
|
||||||
consts.RESOURCE_TYPE_SYSINV_USER: ['PATCH', 'PUT'],
|
consts.RESOURCE_TYPE_SYSINV_USER: ['PATCH', 'PUT'],
|
||||||
},
|
},
|
||||||
|
|
|
@ -75,8 +75,6 @@ ORCH_REQUEST_ABORTED = "aborted"
|
||||||
# SysInv Resources
|
# SysInv Resources
|
||||||
RESOURCE_TYPE_SYSINV_CERTIFICATE = "certificates"
|
RESOURCE_TYPE_SYSINV_CERTIFICATE = "certificates"
|
||||||
RESOURCE_TYPE_SYSINV_DNS = "idns"
|
RESOURCE_TYPE_SYSINV_DNS = "idns"
|
||||||
RESOURCE_TYPE_SYSINV_SNMP_COMM = "icommunity"
|
|
||||||
RESOURCE_TYPE_SYSINV_SNMP_TRAPDEST = "itrapdest"
|
|
||||||
RESOURCE_TYPE_SYSINV_USER = "iuser"
|
RESOURCE_TYPE_SYSINV_USER = "iuser"
|
||||||
RESOURCE_TYPE_SYSINV_FERNET_REPO = "fernet_repo"
|
RESOURCE_TYPE_SYSINV_FERNET_REPO = "fernet_repo"
|
||||||
|
|
||||||
|
|
|
@ -42,9 +42,6 @@ class SysinvSyncThread(SyncThread):
|
||||||
consts.RESOURCE_TYPE_SYSINV_FERNET_REPO
|
consts.RESOURCE_TYPE_SYSINV_FERNET_REPO
|
||||||
]
|
]
|
||||||
|
|
||||||
SYSINV_ADD_DELETE_RESOURCES = [consts.RESOURCE_TYPE_SYSINV_SNMP_COMM,
|
|
||||||
consts.RESOURCE_TYPE_SYSINV_SNMP_TRAPDEST]
|
|
||||||
|
|
||||||
SYSINV_CREATE_RESOURCES = [consts.RESOURCE_TYPE_SYSINV_CERTIFICATE,
|
SYSINV_CREATE_RESOURCES = [consts.RESOURCE_TYPE_SYSINV_CERTIFICATE,
|
||||||
consts.RESOURCE_TYPE_SYSINV_FERNET_REPO]
|
consts.RESOURCE_TYPE_SYSINV_FERNET_REPO]
|
||||||
|
|
||||||
|
@ -60,10 +57,6 @@ class SysinvSyncThread(SyncThread):
|
||||||
self.sync_handler_map = {
|
self.sync_handler_map = {
|
||||||
consts.RESOURCE_TYPE_SYSINV_DNS:
|
consts.RESOURCE_TYPE_SYSINV_DNS:
|
||||||
self.sync_platform_resource,
|
self.sync_platform_resource,
|
||||||
consts.RESOURCE_TYPE_SYSINV_SNMP_COMM:
|
|
||||||
self.sync_platform_resource,
|
|
||||||
consts.RESOURCE_TYPE_SYSINV_SNMP_TRAPDEST:
|
|
||||||
self.sync_platform_resource,
|
|
||||||
consts.RESOURCE_TYPE_SYSINV_CERTIFICATE:
|
consts.RESOURCE_TYPE_SYSINV_CERTIFICATE:
|
||||||
self.sync_platform_resource,
|
self.sync_platform_resource,
|
||||||
consts.RESOURCE_TYPE_SYSINV_USER:
|
consts.RESOURCE_TYPE_SYSINV_USER:
|
||||||
|
@ -78,8 +71,6 @@ class SysinvSyncThread(SyncThread):
|
||||||
self.audit_resources = [
|
self.audit_resources = [
|
||||||
consts.RESOURCE_TYPE_SYSINV_CERTIFICATE,
|
consts.RESOURCE_TYPE_SYSINV_CERTIFICATE,
|
||||||
consts.RESOURCE_TYPE_SYSINV_DNS,
|
consts.RESOURCE_TYPE_SYSINV_DNS,
|
||||||
consts.RESOURCE_TYPE_SYSINV_SNMP_COMM,
|
|
||||||
consts.RESOURCE_TYPE_SYSINV_SNMP_TRAPDEST,
|
|
||||||
consts.RESOURCE_TYPE_SYSINV_USER,
|
consts.RESOURCE_TYPE_SYSINV_USER,
|
||||||
consts.RESOURCE_TYPE_SYSINV_FERNET_REPO,
|
consts.RESOURCE_TYPE_SYSINV_FERNET_REPO,
|
||||||
]
|
]
|
||||||
|
@ -164,141 +155,6 @@ class SysinvSyncThread(SyncThread):
|
||||||
.format(rsrc.id, subcloud_rsrc_id, nameservers),
|
.format(rsrc.id, subcloud_rsrc_id, nameservers),
|
||||||
extra=self.log_extra)
|
extra=self.log_extra)
|
||||||
|
|
||||||
def sync_itrapdest(self, s_os_client, request, rsrc):
|
|
||||||
switcher = {
|
|
||||||
consts.OPERATION_TYPE_POST: self.snmp_trapdest_create,
|
|
||||||
consts.OPERATION_TYPE_CREATE: self.snmp_trapdest_create,
|
|
||||||
consts.OPERATION_TYPE_DELETE: self.snmp_trapdest_delete,
|
|
||||||
}
|
|
||||||
|
|
||||||
func = switcher[request.orch_job.operation_type]
|
|
||||||
try:
|
|
||||||
func(s_os_client, request, rsrc)
|
|
||||||
except Exception as e:
|
|
||||||
LOG.exception(e)
|
|
||||||
raise e
|
|
||||||
|
|
||||||
def snmp_trapdest_create(self, s_os_client, request, rsrc):
|
|
||||||
LOG.info("snmp_trapdest_create region {} resource_info={}".format(
|
|
||||||
self.subcloud_engine.subcloud.region_name,
|
|
||||||
request.orch_job.resource_info),
|
|
||||||
extra=self.log_extra)
|
|
||||||
resource_info_dict = jsonutils.loads(request.orch_job.resource_info)
|
|
||||||
payload = resource_info_dict.get('payload')
|
|
||||||
if not payload:
|
|
||||||
payload = resource_info_dict
|
|
||||||
|
|
||||||
try:
|
|
||||||
itrapdest = s_os_client.sysinv_client.snmp_trapdest_create(
|
|
||||||
payload)
|
|
||||||
itrapdest_id = itrapdest.uuid
|
|
||||||
ip_address = itrapdest.ip_address
|
|
||||||
except (AttributeError, TypeError) as e:
|
|
||||||
LOG.info("snmp_trapdest_create error {}".format(e),
|
|
||||||
extra=self.log_extra)
|
|
||||||
raise exceptions.SyncRequestFailedRetry
|
|
||||||
|
|
||||||
# Now persist the subcloud resource to the DB for later
|
|
||||||
subcloud_rsrc_id = self.persist_db_subcloud_resource(
|
|
||||||
rsrc.id, ip_address)
|
|
||||||
|
|
||||||
LOG.info("SNMP trapdest {}:{} [{}/{}] created".format(rsrc.id,
|
|
||||||
subcloud_rsrc_id, ip_address, itrapdest_id),
|
|
||||||
extra=self.log_extra)
|
|
||||||
return itrapdest
|
|
||||||
|
|
||||||
def snmp_trapdest_delete(self, s_os_client, request, rsrc):
|
|
||||||
subcloud_rsrc = self.get_db_subcloud_resource(rsrc.id)
|
|
||||||
if not subcloud_rsrc:
|
|
||||||
return
|
|
||||||
|
|
||||||
try:
|
|
||||||
s_os_client.sysinv_client.snmp_trapdest_delete(
|
|
||||||
subcloud_rsrc.subcloud_resource_id)
|
|
||||||
except dccommon_exceptions.TrapDestNotFound:
|
|
||||||
# SNMP trapdest already deleted in subcloud, carry on.
|
|
||||||
LOG.info("SNMP trapdest not in subcloud, may be already deleted",
|
|
||||||
extra=self.log_extra)
|
|
||||||
except (AttributeError, TypeError) as e:
|
|
||||||
LOG.info("snmp_trapdest_delete error {}".format(e),
|
|
||||||
extra=self.log_extra)
|
|
||||||
raise exceptions.SyncRequestFailedRetry
|
|
||||||
|
|
||||||
subcloud_rsrc.delete()
|
|
||||||
# Master Resource can be deleted only when all subcloud resources
|
|
||||||
# are deleted along with corresponding orch_job and orch_requests.
|
|
||||||
LOG.info("SNMP trapdest {}:{} [{}] deleted".format(
|
|
||||||
rsrc.id, subcloud_rsrc.id,
|
|
||||||
subcloud_rsrc.subcloud_resource_id),
|
|
||||||
extra=self.log_extra)
|
|
||||||
|
|
||||||
def sync_icommunity(self, s_os_client, request, rsrc):
|
|
||||||
switcher = {
|
|
||||||
consts.OPERATION_TYPE_POST: self.snmp_community_create,
|
|
||||||
consts.OPERATION_TYPE_CREATE: self.snmp_community_create,
|
|
||||||
consts.OPERATION_TYPE_DELETE: self.snmp_community_delete,
|
|
||||||
}
|
|
||||||
|
|
||||||
func = switcher[request.orch_job.operation_type]
|
|
||||||
try:
|
|
||||||
func(s_os_client, request, rsrc)
|
|
||||||
except Exception as e:
|
|
||||||
LOG.exception(e)
|
|
||||||
raise exceptions.SyncRequestFailedRetry
|
|
||||||
|
|
||||||
def snmp_community_create(self, s_os_client, request, rsrc):
|
|
||||||
LOG.info("snmp_community_create region {} resource_info={}".format(
|
|
||||||
self.subcloud_engine.subcloud.region_name,
|
|
||||||
request.orch_job.resource_info),
|
|
||||||
extra=self.log_extra)
|
|
||||||
resource_info_dict = jsonutils.loads(request.orch_job.resource_info)
|
|
||||||
payload = resource_info_dict.get('payload')
|
|
||||||
if not payload:
|
|
||||||
payload = resource_info_dict
|
|
||||||
|
|
||||||
try:
|
|
||||||
icommunity = s_os_client.sysinv_client.snmp_community_create(
|
|
||||||
payload)
|
|
||||||
icommunity_id = icommunity.uuid
|
|
||||||
community = icommunity.community
|
|
||||||
except (AttributeError, TypeError) as e:
|
|
||||||
LOG.info("snmp_community_create error {}".format(e),
|
|
||||||
extra=self.log_extra)
|
|
||||||
raise exceptions.SyncRequestFailedRetry
|
|
||||||
|
|
||||||
# Now persist the subcloud resource to the DB for later
|
|
||||||
subcloud_rsrc_id = self.persist_db_subcloud_resource(
|
|
||||||
rsrc.id, community)
|
|
||||||
|
|
||||||
LOG.info("SNMP community {}:{} [{}/{}] created".format(rsrc.id,
|
|
||||||
subcloud_rsrc_id, community, icommunity_id),
|
|
||||||
extra=self.log_extra)
|
|
||||||
return icommunity
|
|
||||||
|
|
||||||
def snmp_community_delete(self, s_os_client, request, rsrc):
|
|
||||||
subcloud_rsrc = self.get_db_subcloud_resource(rsrc.id)
|
|
||||||
if not subcloud_rsrc:
|
|
||||||
return
|
|
||||||
try:
|
|
||||||
s_os_client.sysinv_client.snmp_community_delete(
|
|
||||||
subcloud_rsrc.subcloud_resource_id)
|
|
||||||
except dccommon_exceptions.CommunityNotFound:
|
|
||||||
# Community already deleted in subcloud, carry on.
|
|
||||||
LOG.info("SNMP community not in subcloud, may be already deleted",
|
|
||||||
extra=self.log_extra)
|
|
||||||
except (AttributeError, TypeError) as e:
|
|
||||||
LOG.info("snmp_community_delete error {}".format(e),
|
|
||||||
extra=self.log_extra)
|
|
||||||
raise exceptions.SyncRequestFailedRetry
|
|
||||||
|
|
||||||
subcloud_rsrc.delete()
|
|
||||||
# Master Resource can be deleted only when all subcloud resources
|
|
||||||
# are deleted along with corresponding orch_job and orch_requests.
|
|
||||||
LOG.info("SNMP community {}:{} [{}] deleted".format(
|
|
||||||
rsrc.id, subcloud_rsrc.id,
|
|
||||||
subcloud_rsrc.subcloud_resource_id),
|
|
||||||
extra=self.log_extra)
|
|
||||||
|
|
||||||
def update_certificate(self, s_os_client, signature,
|
def update_certificate(self, s_os_client, signature,
|
||||||
certificate=None, data=None):
|
certificate=None, data=None):
|
||||||
|
|
||||||
|
@ -577,10 +433,6 @@ class SysinvSyncThread(SyncThread):
|
||||||
thread_name=self.audit_thread.name)
|
thread_name=self.audit_thread.name)
|
||||||
if resource_type == consts.RESOURCE_TYPE_SYSINV_DNS:
|
if resource_type == consts.RESOURCE_TYPE_SYSINV_DNS:
|
||||||
return [self.get_dns_resource(os_client)]
|
return [self.get_dns_resource(os_client)]
|
||||||
elif resource_type == consts.RESOURCE_TYPE_SYSINV_SNMP_COMM:
|
|
||||||
return self.get_snmp_community_resources(os_client)
|
|
||||||
elif resource_type == consts.RESOURCE_TYPE_SYSINV_SNMP_TRAPDEST:
|
|
||||||
return self.get_snmp_trapdest_resources(os_client)
|
|
||||||
elif resource_type == consts.RESOURCE_TYPE_SYSINV_CERTIFICATE:
|
elif resource_type == consts.RESOURCE_TYPE_SYSINV_CERTIFICATE:
|
||||||
return self.get_certificates_resources(os_client)
|
return self.get_certificates_resources(os_client)
|
||||||
elif resource_type == consts.RESOURCE_TYPE_SYSINV_USER:
|
elif resource_type == consts.RESOURCE_TYPE_SYSINV_USER:
|
||||||
|
@ -601,10 +453,6 @@ class SysinvSyncThread(SyncThread):
|
||||||
thread_name=self.audit_thread.name)
|
thread_name=self.audit_thread.name)
|
||||||
if resource_type == consts.RESOURCE_TYPE_SYSINV_DNS:
|
if resource_type == consts.RESOURCE_TYPE_SYSINV_DNS:
|
||||||
return [self.get_dns_resource(os_client)]
|
return [self.get_dns_resource(os_client)]
|
||||||
elif resource_type == consts.RESOURCE_TYPE_SYSINV_SNMP_COMM:
|
|
||||||
return self.get_snmp_community_resources(os_client)
|
|
||||||
elif resource_type == consts.RESOURCE_TYPE_SYSINV_SNMP_TRAPDEST:
|
|
||||||
return self.get_snmp_trapdest_resources(os_client)
|
|
||||||
elif resource_type == consts.RESOURCE_TYPE_SYSINV_CERTIFICATE:
|
elif resource_type == consts.RESOURCE_TYPE_SYSINV_CERTIFICATE:
|
||||||
return self.get_certificates_resources(os_client)
|
return self.get_certificates_resources(os_client)
|
||||||
elif resource_type == consts.RESOURCE_TYPE_SYSINV_USER:
|
elif resource_type == consts.RESOURCE_TYPE_SYSINV_USER:
|
||||||
|
@ -649,12 +497,6 @@ class SysinvSyncThread(SyncThread):
|
||||||
def get_dns_resource(self, os_client):
|
def get_dns_resource(self, os_client):
|
||||||
return os_client.sysinv_client.get_dns()
|
return os_client.sysinv_client.get_dns()
|
||||||
|
|
||||||
def get_snmp_trapdest_resources(self, os_client):
|
|
||||||
return os_client.sysinv_client.snmp_trapdest_list()
|
|
||||||
|
|
||||||
def get_snmp_community_resources(self, os_client):
|
|
||||||
return os_client.sysinv_client.snmp_community_list()
|
|
||||||
|
|
||||||
def get_certificates_resources(self, os_client):
|
def get_certificates_resources(self, os_client):
|
||||||
certificate_list = os_client.sysinv_client.get_certificates()
|
certificate_list = os_client.sysinv_client.get_certificates()
|
||||||
# Filter SSL certificates to avoid sync
|
# Filter SSL certificates to avoid sync
|
||||||
|
@ -672,17 +514,7 @@ class SysinvSyncThread(SyncThread):
|
||||||
return FernetKeyManager.to_resource_info(keys)
|
return FernetKeyManager.to_resource_info(keys)
|
||||||
|
|
||||||
def get_resource_id(self, resource_type, resource):
|
def get_resource_id(self, resource_type, resource):
|
||||||
if resource_type == consts.RESOURCE_TYPE_SYSINV_SNMP_COMM:
|
if resource_type == consts.RESOURCE_TYPE_SYSINV_CERTIFICATE:
|
||||||
LOG.debug("get_resource_id for community {}".format(resource))
|
|
||||||
return resource.community
|
|
||||||
elif resource_type == consts.RESOURCE_TYPE_SYSINV_SNMP_TRAPDEST:
|
|
||||||
if hasattr(resource, 'ip_address') and \
|
|
||||||
hasattr(resource, 'community'):
|
|
||||||
LOG.debug("get_resource_id resource={} has ip_address and "
|
|
||||||
"community".format(resource),
|
|
||||||
extra=self.log_extra)
|
|
||||||
return resource.ip_address
|
|
||||||
elif resource_type == consts.RESOURCE_TYPE_SYSINV_CERTIFICATE:
|
|
||||||
if hasattr(resource, 'signature'):
|
if hasattr(resource, 'signature'):
|
||||||
LOG.debug("get_resource_id signature={}".format(
|
LOG.debug("get_resource_id signature={}".format(
|
||||||
resource.signature))
|
resource.signature))
|
||||||
|
@ -725,22 +557,6 @@ class SysinvSyncThread(SyncThread):
|
||||||
same_nameservers = False
|
same_nameservers = False
|
||||||
return same_nameservers
|
return same_nameservers
|
||||||
|
|
||||||
def same_snmp_trapdest(self, i1, i2):
|
|
||||||
LOG.debug("same_snmp_trapdest i1={}, i2={}".format(i1, i2),
|
|
||||||
extra=self.log_extra)
|
|
||||||
return (i1.ip_address == i2.ip_address and
|
|
||||||
i1.community == i2.community)
|
|
||||||
|
|
||||||
def same_snmp_community(self, i1, i2):
|
|
||||||
LOG.debug("same_snmp_community i1={}, i2={}".format(i1, i2),
|
|
||||||
extra=self.log_extra)
|
|
||||||
if i1.community and (i1.community != i2.community):
|
|
||||||
if i1.signature == self.RESOURCE_UUID_NULL:
|
|
||||||
LOG.info("Master Resource SNMP Community NULL UUID")
|
|
||||||
return True
|
|
||||||
return False
|
|
||||||
return True
|
|
||||||
|
|
||||||
def same_certificate(self, i1, i2):
|
def same_certificate(self, i1, i2):
|
||||||
LOG.debug("same_certificate i1={}, i2={}".format(i1, i2),
|
LOG.debug("same_certificate i1={}, i2={}".format(i1, i2),
|
||||||
extra=self.log_extra)
|
extra=self.log_extra)
|
||||||
|
@ -780,10 +596,6 @@ class SysinvSyncThread(SyncThread):
|
||||||
def same_resource(self, resource_type, m_resource, sc_resource):
|
def same_resource(self, resource_type, m_resource, sc_resource):
|
||||||
if resource_type == consts.RESOURCE_TYPE_SYSINV_DNS:
|
if resource_type == consts.RESOURCE_TYPE_SYSINV_DNS:
|
||||||
return self.same_dns(m_resource, sc_resource)
|
return self.same_dns(m_resource, sc_resource)
|
||||||
elif resource_type == consts.RESOURCE_TYPE_SYSINV_SNMP_COMM:
|
|
||||||
return self.same_snmp_community(m_resource, sc_resource)
|
|
||||||
elif resource_type == consts.RESOURCE_TYPE_SYSINV_SNMP_TRAPDEST:
|
|
||||||
return self.same_snmp_trapdest(m_resource, sc_resource)
|
|
||||||
elif resource_type == consts.RESOURCE_TYPE_SYSINV_CERTIFICATE:
|
elif resource_type == consts.RESOURCE_TYPE_SYSINV_CERTIFICATE:
|
||||||
return self.same_certificate(m_resource, sc_resource)
|
return self.same_certificate(m_resource, sc_resource)
|
||||||
elif resource_type == consts.RESOURCE_TYPE_SYSINV_USER:
|
elif resource_type == consts.RESOURCE_TYPE_SYSINV_USER:
|
||||||
|
@ -797,17 +609,8 @@ class SysinvSyncThread(SyncThread):
|
||||||
|
|
||||||
def audit_discrepancy(self, resource_type, m_resource, sc_resources):
|
def audit_discrepancy(self, resource_type, m_resource, sc_resources):
|
||||||
# Return true to try the audit_action
|
# Return true to try the audit_action
|
||||||
if resource_type in self.SYSINV_ADD_DELETE_RESOURCES:
|
if (resource_type in self.SYSINV_MODIFY_RESOURCES or
|
||||||
# It could be that the details are different
|
resource_type in self.SYSINV_CREATE_RESOURCES):
|
||||||
# between master cloud and subcloud now.
|
|
||||||
# Thus, delete the resource before creating it again.
|
|
||||||
master_id = self.get_resource_id(resource_type, m_resource)
|
|
||||||
self.schedule_work(self.endpoint_type, resource_type,
|
|
||||||
master_id,
|
|
||||||
consts.OPERATION_TYPE_DELETE)
|
|
||||||
return True
|
|
||||||
elif (resource_type in self.SYSINV_MODIFY_RESOURCES or
|
|
||||||
resource_type in self.SYSINV_CREATE_RESOURCES):
|
|
||||||
# The resource differs, signal to perform the audit_action
|
# The resource differs, signal to perform the audit_action
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -880,8 +683,6 @@ class SysinvSyncThread(SyncThread):
|
||||||
def get_resource_info(self, resource_type,
|
def get_resource_info(self, resource_type,
|
||||||
resource, operation_type=None):
|
resource, operation_type=None):
|
||||||
payload_resources = [consts.RESOURCE_TYPE_SYSINV_DNS,
|
payload_resources = [consts.RESOURCE_TYPE_SYSINV_DNS,
|
||||||
consts.RESOURCE_TYPE_SYSINV_SNMP_COMM,
|
|
||||||
consts.RESOURCE_TYPE_SYSINV_SNMP_TRAPDEST,
|
|
||||||
consts.RESOURCE_TYPE_SYSINV_CERTIFICATE,
|
consts.RESOURCE_TYPE_SYSINV_CERTIFICATE,
|
||||||
consts.RESOURCE_TYPE_SYSINV_USER,
|
consts.RESOURCE_TYPE_SYSINV_USER,
|
||||||
]
|
]
|
||||||
|
|
|
@ -11,7 +11,7 @@ Paste # MIT
|
||||||
PasteDeploy>=1.5.0 # MIT
|
PasteDeploy>=1.5.0 # MIT
|
||||||
Routes>=2.3.1 # MIT
|
Routes>=2.3.1 # MIT
|
||||||
debtcollector>=1.2.0 # Apache-2.0
|
debtcollector>=1.2.0 # Apache-2.0
|
||||||
eventlet!=0.18.3,<0.21.0,>=0.18.2 # MIT
|
eventlet
|
||||||
pecan!=1.0.2,!=1.0.3,!=1.0.4,!=1.2,>=1.0.0 # BSD
|
pecan!=1.0.2,!=1.0.3,!=1.0.4,!=1.2,>=1.0.0 # BSD
|
||||||
greenlet>=0.3.2 # MIT
|
greenlet>=0.3.2 # MIT
|
||||||
httplib2>=0.7.5 # MIT
|
httplib2>=0.7.5 # MIT
|
||||||
|
|
|
@ -8,7 +8,7 @@ fixtures>=3.0.0 # Apache-2.0/BSD
|
||||||
mock>=2.0 # BSD
|
mock>=2.0 # BSD
|
||||||
python-subunit>=0.0.18 # Apache-2.0/BSD
|
python-subunit>=0.0.18 # Apache-2.0/BSD
|
||||||
requests-mock>=1.1 # Apache-2.0
|
requests-mock>=1.1 # Apache-2.0
|
||||||
sphinx!=1.6.1,>=1.5.1 # BSD
|
sphinx # BSD
|
||||||
oslosphinx>=4.7.0 # Apache-2.0
|
oslosphinx>=4.7.0 # Apache-2.0
|
||||||
testrepository>=0.0.18 # Apache-2.0/BSD
|
testrepository>=0.0.18 # Apache-2.0/BSD
|
||||||
testtools>=1.4.0 # MIT
|
testtools>=1.4.0 # MIT
|
||||||
|
|
|
@ -16,8 +16,7 @@ cgtsclient_src_dir = ../../config/sysinv/cgts-client/cgts-client
|
||||||
cgcs_patch_src_dir = ../../update/cgcs-patch/cgcs-patch
|
cgcs_patch_src_dir = ../../update/cgcs-patch/cgcs-patch
|
||||||
|
|
||||||
[testenv]
|
[testenv]
|
||||||
install_command = pip install \
|
install_command = pip install -v -v -v \
|
||||||
-c ./upper-constraints.txt \
|
|
||||||
-c https://opendev.org/openstack/requirements/raw/branch/stable/stein/upper-constraints.txt \
|
-c https://opendev.org/openstack/requirements/raw/branch/stable/stein/upper-constraints.txt \
|
||||||
{opts} {packages}
|
{opts} {packages}
|
||||||
setenv =
|
setenv =
|
||||||
|
@ -38,6 +37,9 @@ whitelist_externals =
|
||||||
|
|
||||||
[testenv:py27]
|
[testenv:py27]
|
||||||
basepython = python2.7
|
basepython = python2.7
|
||||||
|
install_command = pip install -v -v -v \
|
||||||
|
-c https://opendev.org/openstack/requirements/raw/branch/stable/stein/upper-constraints.txt \
|
||||||
|
{opts} {packages}
|
||||||
deps = -r{toxinidir}/test-requirements.txt
|
deps = -r{toxinidir}/test-requirements.txt
|
||||||
-r{toxinidir}/requirements.txt
|
-r{toxinidir}/requirements.txt
|
||||||
keyring
|
keyring
|
||||||
|
@ -86,7 +88,6 @@ commands = oslo_debug_helper {posargs}
|
||||||
basepython = python3
|
basepython = python3
|
||||||
deps = hacking>=1.1.0,<=2.0.0
|
deps = hacking>=1.1.0,<=2.0.0
|
||||||
pycodestyle>=2.0.0
|
pycodestyle>=2.0.0
|
||||||
flake8-bugbear
|
|
||||||
commands = flake8
|
commands = flake8
|
||||||
|
|
||||||
[testenv:venv]
|
[testenv:venv]
|
||||||
|
@ -168,15 +169,8 @@ show-source = True
|
||||||
# E402 module level import not at top of file
|
# E402 module level import not at top of file
|
||||||
# E501 line too long
|
# E501 line too long
|
||||||
# E731 do not assign a lambda expression, use a def
|
# E731 do not assign a lambda expression, use a def
|
||||||
# -B- codes are bugbear errors
|
|
||||||
# B005 Using .strip() with multi-character strings is misleading the reader.
|
|
||||||
# B006 Do not use mutable data structures for argument defaults.
|
|
||||||
# B007 Loop control variable not used within the loop body.
|
|
||||||
# B009 Do not call getattr with a constant attribute value,
|
|
||||||
# B306 `BaseException.message` has been deprecated as of Python 2.6 and is removed in Python 3
|
|
||||||
ignore = W503,W504,W605,
|
ignore = W503,W504,W605,
|
||||||
E117,E123,E125,E305,E402,E501,E731,
|
E117,E123,E125,E305,E402,E501,E731
|
||||||
B005,B006,B007,B009,B306
|
|
||||||
builtins = _
|
builtins = _
|
||||||
exclude=.venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build
|
exclude=.venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build
|
||||||
|
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
# oslo.messaging locked to pike version
|
|
||||||
# https://bugs.launchpad.net/starlingx/+bug/1865054
|
|
||||||
oslo.messaging==5.30.6 # Apache-2.0
|
|
||||||
Pygments==2.5.2
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
sphinx>=1.6.2
|
sphinx # BSD
|
||||||
openstackdocstheme>=1.26.0 # Apache-2.0
|
openstackdocstheme # Apache-2.0
|
||||||
|
|
||||||
# Release Notes documentation
|
# Release Notes documentation
|
||||||
reno>=0.1.1 # Apache2
|
reno # Apache-2.0
|
||||||
|
|
||||||
# Api Ref documentation
|
# Api Ref documentation
|
||||||
os-api-ref>=1.4.0 # Apache-2.0
|
os-api-ref>=1.4.0 # Apache-2.0
|
||||||
|
|
2
tox.ini
2
tox.ini
|
@ -4,7 +4,7 @@ minversion = 2.3
|
||||||
skipsdist = True
|
skipsdist = True
|
||||||
|
|
||||||
[testenv]
|
[testenv]
|
||||||
install_command = pip install \
|
install_command = pip install -v -v -v \
|
||||||
-c https://opendev.org/openstack/requirements/raw/branch/stable/stein/upper-constraints.txt \
|
-c https://opendev.org/openstack/requirements/raw/branch/stable/stein/upper-constraints.txt \
|
||||||
{opts} {packages}
|
{opts} {packages}
|
||||||
setenv =
|
setenv =
|
||||||
|
|
Loading…
Reference in New Issue