c9f23471e3
- Added the name field to the network table - Removed mtu, link_capacity and vlan_id from the network table - Removed unused networktypes for bm, control and data-vrs - Added four interface classes (platform, data, pci-passthrough, pci-sriov) to interface table - Assign networks to interface during interface creation and modification - Allow infrastructure network and management network to share an interface with or without VLAN. - Updated sysinv puppet for interface and network Story: 2003087 Task: 23171 Depends-On: https://review.openstack.org/#/c/601155 Change-Id: I2e211767639484992f868084eb47baacbe5ea83a Signed-off-by: Teresa Ho <teresa.ho@windriver.com>
105 lines
3.5 KiB
Python
105 lines
3.5 KiB
Python
#
|
|
# Copyright (c) 2013-2015 Wind River Systems, Inc.
|
|
#
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
#
|
|
|
|
# -*- encoding: utf-8 -*-
|
|
#
|
|
|
|
from cgtsclient.common import base
|
|
from cgtsclient import exc
|
|
from cgtsclient.v1 import port
|
|
|
|
|
|
CREATION_ATTRIBUTES = ['ifname', 'iftype', 'ihost_uuid', 'imtu', 'ifclass',
|
|
'networks', 'network_uuid', 'networktype', 'aemode', 'txhashpolicy',
|
|
'providernetworks', 'providernetworksdict', 'ifcapabilities', 'ports', 'imac',
|
|
'vlan_id', 'uses', 'used_by',
|
|
'ipv4_mode', 'ipv6_mode', 'ipv4_pool', 'ipv6_pool',
|
|
'sriov_numvfs']
|
|
|
|
|
|
class iinterface(base.Resource):
|
|
def __repr__(self):
|
|
return "<iinterface %s>" % self._info
|
|
|
|
|
|
class iinterfaceManager(base.Manager):
|
|
resource_class = iinterface
|
|
|
|
def list(self, ihost_id):
|
|
path = '/v1/ihosts/%s/iinterfaces' % ihost_id
|
|
return self._list(path, "iinterfaces")
|
|
|
|
def list_ports(self, interface_id):
|
|
path = '/v1/iinterfaces/%s/ports' % interface_id
|
|
return self._list(path, "ports")
|
|
|
|
def get(self, iinterface_id):
|
|
path = '/v1/iinterfaces/%s' % iinterface_id
|
|
try:
|
|
return self._list(path)[0]
|
|
except IndexError:
|
|
return None
|
|
|
|
def create(self, **kwargs):
|
|
path = '/v1/iinterfaces'
|
|
new = {}
|
|
for (key, value) in kwargs.items():
|
|
if key in CREATION_ATTRIBUTES:
|
|
new[key] = value
|
|
else:
|
|
raise exc.InvalidAttribute('%s' % key)
|
|
return self._create(path, new)
|
|
|
|
def delete(self, iinterface_id):
|
|
path = '/v1/iinterfaces/%s' % iinterface_id
|
|
return self._delete(path)
|
|
|
|
def update(self, iinterface_id, patch):
|
|
path = '/v1/iinterfaces/%s' % iinterface_id
|
|
return self._update(path, patch)
|
|
|
|
|
|
def _get_ports(cc, ihost, interface):
|
|
ports = cc.iinterface.list_ports(interface.uuid)
|
|
port_list = [port.get_port_display_name(p) for p in ports]
|
|
|
|
interface.ports = port_list
|
|
|
|
if interface.iftype == 'ethernet':
|
|
interface.dpdksupport = [p.dpdksupport for p in ports]
|
|
if interface.iftype == 'vlan':
|
|
interfaces = cc.iinterface.list(ihost.uuid)
|
|
for u in interface.uses:
|
|
for j in interfaces:
|
|
if j.ifname == str(u):
|
|
if j.iftype == 'ethernet':
|
|
uses_ports = cc.iinterface.list_ports(j.uuid)
|
|
interface.dpdksupport = [p.dpdksupport for p in uses_ports]
|
|
elif j.iftype == 'ae':
|
|
for ae_u in j.uses:
|
|
for k in interfaces:
|
|
if k.ifname == str(ae_u):
|
|
uses_ports = cc.iinterface.list_ports(k.uuid)
|
|
interface.dpdksupport = [p.dpdksupport for p in uses_ports]
|
|
elif interface.iftype == 'ae':
|
|
interfaces = cc.iinterface.list(ihost.uuid)
|
|
for u in interface.uses:
|
|
for j in interfaces:
|
|
if j.ifname == str(u):
|
|
uses_ports = cc.iinterface.list_ports(j.uuid)
|
|
interface.dpdksupport = [p.dpdksupport for p in uses_ports]
|
|
|
|
|
|
def _find_interface(cc, ihost, ifnameoruuid):
|
|
interfaces = cc.iinterface.list(ihost.uuid)
|
|
for i in interfaces:
|
|
if i.ifname == ifnameoruuid or i.uuid == ifnameoruuid:
|
|
break
|
|
else:
|
|
raise exc.CommandError('Interface not found: host %s interface %s' %
|
|
(ihost.hostname, ifnameoruuid))
|
|
return i
|