Check service_type per VDU for openwrt mgmt driver
Get all VDU IDs and check for service_type for all VDUs Closes-Bug: #1506111 Change-Id: I1de206779841ca63e1f95cc9f5bd58496566acfe
This commit is contained in:
parent
d1312149b1
commit
53fb9c1091
|
@ -18,6 +18,7 @@
|
|||
#
|
||||
# @author: Isaku Yamahata, Intel Corporation.
|
||||
|
||||
import ast
|
||||
import yaml
|
||||
|
||||
from oslo_config import cfg
|
||||
|
@ -62,15 +63,23 @@ class DeviceMgmtOpenWRT(abstract_driver.DeviceMGMTAbstractDriver):
|
|||
"uci import %s; /etc/init.d/%s restart" % (service, service)]
|
||||
utils.execute(cmd, process_input=config)
|
||||
|
||||
def get_vdus(self, device):
|
||||
device_attributes = device['device_template']['attributes']
|
||||
vnfd = yaml.load(device_attributes['vnfd'])
|
||||
return vnfd['vdus'].keys()
|
||||
|
||||
@log.log
|
||||
def mgmt_call(self, plugin, context, device, kwargs):
|
||||
if (kwargs[mgmt_constants.KEY_ACTION] !=
|
||||
mgmt_constants.ACTION_UPDATE_DEVICE):
|
||||
return
|
||||
dev_attrs = device.get('attributes', {})
|
||||
service_type = dev_attrs.get('service_type')
|
||||
if not service_type:
|
||||
return
|
||||
service_types = dict()
|
||||
vdus = self.get_vdus(device)
|
||||
for vdu in vdus:
|
||||
vdu_attrs = ast.literal_eval(dev_attrs[vdu])
|
||||
service_types[vdu] = vdu_attrs.get('service_type', '')
|
||||
|
||||
mgmt_url = jsonutils.loads(device.get('mgmt_url', '{}'))
|
||||
if not mgmt_url:
|
||||
return
|
||||
|
@ -86,6 +95,8 @@ class DeviceMgmtOpenWRT(abstract_driver.DeviceMGMTAbstractDriver):
|
|||
KNOWN_SERVICES = ('firewall', )
|
||||
if key not in KNOWN_SERVICES:
|
||||
continue
|
||||
if not service_types[vdu]:
|
||||
continue
|
||||
mgmt_ip_address = mgmt_url.get(vdu, '')
|
||||
if not mgmt_ip_address:
|
||||
LOG.warn(_('tried to configure unknown mgmt address %s'),
|
||||
|
|
Loading…
Reference in New Issue