Closed Exethir closed 5 years ago
Hi, the Element DHCPServer do not exist in the code ;) You can easily créte him with the code : from smc.base.model import Element,ElementCreator class DHCPServer(Element): typeof = 'dhcp_server'
@classmethod
def create(cls, name, address, comment=None):
json = {
'name': name,
'address': address,
'comment': comment}
return ElementCreator(cls, json)
thanks for your response, but i already have the DHCP server created from the management client. I need to use it as a DHCP relay on an interface
Ok , Use the object bellow like this :
from smc.base.model import Element,ElementCreator
class DHCPServer(Element):
typeof = 'dhcp_server'
@classmethod
def create(cls, name, address, comment=None):
json = {
'name': name,
'address': address,
'comment': comment}
return ElementCreator(cls, json)
if name == 'main':
DHCP = DHCPServer(name='YOURDHCP')
DHCPDATA = {'element': [DHCP.href], 'enabled': True, 'max_packet_size': 576, 'trusted_circuit': False}
interface0VLAN3 = engine.interface.get('0.3') # <- retrieve the interface
for node in interface0VLAN3.interfaces: # <- iterate the nodes of that interface and set value/s
if node.typeof == 'cluster_virtual_interface':
node.update(relayed_by_dhcp=True)
interface0VLAN3.update(dhcp_relay=DHCPDATA)
interface0VLAN3.update()
thanks a lot, that's exactly what i wanted to do :)
Hi david, i'm currently working with smc-python and i can't find how to make the DHCP relay of a virtual interface linked with a DHCP server. I'm searching a function that seems like that : interface.add_dhcp_relay(vlan_id, dhcp_serveur) but i could not find anything like that in the doc.