Remove H903 error in source.
Some codes use Windows style line endings, this violates H903 error pep8. This patch will convert dos to unix formate. Change-Id: Idd3da3a259517e1b8612b3c3c129a1f8616403bb Closes-Bug: #1817283
This commit is contained in:
parent
b8c561493d
commit
675a3e913c
@ -1,70 +1,70 @@
|
||||
#
|
||||
# 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_log import log as logging
|
||||
import yaml
|
||||
|
||||
from tacker import objects
|
||||
from tacker.vnfm.policy_actions import abstract_action
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class VNFActionVduAutoheal(abstract_action.AbstractPolicyAction):
|
||||
def get_type(self):
|
||||
return 'vdu_autoheal'
|
||||
|
||||
def get_name(self):
|
||||
return 'vdu_autoheal'
|
||||
|
||||
def get_description(self):
|
||||
return 'Tacker VNF vdu_autoheal policy'
|
||||
|
||||
def execute_action(self, plugin, context, vnf_dict, args):
|
||||
vdu_name = args.get('vdu_name')
|
||||
if vdu_name is None:
|
||||
LOG.error("VDU resource of vnf '%s' is not present for "
|
||||
"autoheal." % vnf_dict['id'])
|
||||
return
|
||||
|
||||
def _get_vdu_resources():
|
||||
"""Get all the resources linked to the VDU.
|
||||
|
||||
Returns: resource list for eg. ['VDU1', CP1]
|
||||
"""
|
||||
resource_list = [vdu_name]
|
||||
heat_template = yaml.safe_load(vnf_dict['attributes'].get(
|
||||
'heat_template'))
|
||||
vdu_resources = heat_template['resources'].get(vdu_name)
|
||||
cp_resources = vdu_resources['properties'].get('networks')
|
||||
for resource in cp_resources:
|
||||
resource_list.append(resource['port'].get('get_resource'))
|
||||
|
||||
return resource_list
|
||||
|
||||
resource_list = _get_vdu_resources()
|
||||
additional_params = []
|
||||
for resource in resource_list:
|
||||
additional_paramas_obj = objects.HealVnfAdditionalParams(
|
||||
parameter=resource,
|
||||
cause=["Unable to reach while monitoring resource: '%s'" %
|
||||
resource])
|
||||
additional_params.append(additional_paramas_obj)
|
||||
|
||||
heal_request_data_obj = objects.HealVnfRequest(
|
||||
cause=("Failed to monitor VDU resource '%s'" % vdu_name),
|
||||
additional_params=additional_params)
|
||||
|
||||
plugin.heal_vnf(context, vnf_dict['id'], heal_request_data_obj)
|
||||
#
|
||||
# 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_log import log as logging
|
||||
import yaml
|
||||
|
||||
from tacker import objects
|
||||
from tacker.vnfm.policy_actions import abstract_action
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class VNFActionVduAutoheal(abstract_action.AbstractPolicyAction):
|
||||
def get_type(self):
|
||||
return 'vdu_autoheal'
|
||||
|
||||
def get_name(self):
|
||||
return 'vdu_autoheal'
|
||||
|
||||
def get_description(self):
|
||||
return 'Tacker VNF vdu_autoheal policy'
|
||||
|
||||
def execute_action(self, plugin, context, vnf_dict, args):
|
||||
vdu_name = args.get('vdu_name')
|
||||
if vdu_name is None:
|
||||
LOG.error("VDU resource of vnf '%s' is not present for "
|
||||
"autoheal." % vnf_dict['id'])
|
||||
return
|
||||
|
||||
def _get_vdu_resources():
|
||||
"""Get all the resources linked to the VDU.
|
||||
|
||||
Returns: resource list for eg. ['VDU1', CP1]
|
||||
"""
|
||||
resource_list = [vdu_name]
|
||||
heat_template = yaml.safe_load(vnf_dict['attributes'].get(
|
||||
'heat_template'))
|
||||
vdu_resources = heat_template['resources'].get(vdu_name)
|
||||
cp_resources = vdu_resources['properties'].get('networks')
|
||||
for resource in cp_resources:
|
||||
resource_list.append(resource['port'].get('get_resource'))
|
||||
|
||||
return resource_list
|
||||
|
||||
resource_list = _get_vdu_resources()
|
||||
additional_params = []
|
||||
for resource in resource_list:
|
||||
additional_paramas_obj = objects.HealVnfAdditionalParams(
|
||||
parameter=resource,
|
||||
cause=["Unable to reach while monitoring resource: '%s'" %
|
||||
resource])
|
||||
additional_params.append(additional_paramas_obj)
|
||||
|
||||
heal_request_data_obj = objects.HealVnfRequest(
|
||||
cause=("Failed to monitor VDU resource '%s'" % vdu_name),
|
||||
additional_params=additional_params)
|
||||
|
||||
plugin.heal_vnf(context, vnf_dict['id'], heal_request_data_obj)
|
||||
|
Loading…
x
Reference in New Issue
Block a user