def set_build_info(self, product_uri, manufacturer_name, product_name, software_version, build_number, build_date): """ Update the servers build information. This needs to be added to the ServerStatus, BuildInfo and all underlying nodes """ status_node = self.get_node(ua.NodeId(ua.ObjectIds.Server_ServerStatus)) build_node = self.get_node(ua.NodeId(ua.ObjectIds.Server_ServerStatus_BuildInfo)) status = status_node.get_value() if status is None: status = ua.ServerStatusDataType() status.BuildInfo.ProductUri = product_uri status.BuildInfo.ManufacturerName = manufacturer_name status.BuildInfo.ProductName = product_name status.BuildInfo.SoftwareVersion = software_version status.BuildInfo.BuildNumber = build_number status.BuildInfo.BuildDate = build_date status_node.set_value(status) build_node.set_value(status.BuildInfo) # we also need to update all individual nodes :/ product_uri_node = self.get_node(ua.NodeId(ua.ObjectIds.Server_ServerStatus_BuildInfo_ProductUri)) product_name_node = self.get_node(ua.NodeId(ua.ObjectIds.Server_ServerStatus_BuildInfo_ProductName)) product_manufacturer_name_node = self.get_node(ua.NodeId(ua.ObjectIds.Server_ServerStatus_BuildInfo_ManufacturerName)) product_software_version_node = self.get_node(ua.NodeId(ua.ObjectIds.Server_ServerStatus_BuildInfo_SoftwareVersion)) product_build_number_node = self.get_node(ua.NodeId(ua.ObjectIds.Server_ServerStatus_BuildInfo_BuildNumber)) product_build_date_node = self.get_node(ua.NodeId(ua.ObjectIds.Server_ServerStatus_BuildInfo_BuildDate)) product_uri_node.set_value(status.BuildInfo.ProductUri) product_name_node.set_value(status.BuildInfo.ProductName) product_manufacturer_name_node.set_value(status.BuildInfo.ManufacturerName) product_software_version_node.set_value(status.BuildInfo.SoftwareVersion) product_build_number_node.set_value(status.BuildInfo.BuildNumber) product_build_date_node.set_value(status.BuildInfo.BuildDate)
def __init__(self, shelffile=None, iserver=None): self.logger = logging.getLogger(__name__) self.endpoint = urlparse("opc.tcp://0.0.0.0:4840/freeopcua/server/") self._application_uri = "urn:freeopcua:python:server" self.product_uri = "urn:freeopcua.github.io:python:server" self.name = "FreeOpcUa Python Server" self.manufacturer_name = "FreeOpcUa" self.application_type = ua.ApplicationType.ClientAndServer self.default_timeout = 3600000 if iserver is not None: self.iserver = iserver else: self.iserver = InternalServer(shelffile) self.bserver = None self._discovery_clients = {} self._discovery_period = 60 self.certificate = None self.private_key = None self._policies = [] self.nodes = Shortcuts(self.iserver.isession) # setup some expected values self.set_application_uri(self._application_uri) sa_node = self.get_node(ua.NodeId(ua.ObjectIds.Server_ServerArray)) sa_node.set_value([self._application_uri]) status_node = self.get_node(ua.NodeId( ua.ObjectIds.Server_ServerStatus)) build_node = self.get_node( ua.NodeId(ua.ObjectIds.Server_ServerStatus_BuildInfo)) status = ua.ServerStatusDataType() status.BuildInfo.ProductUri = self.product_uri status.BuildInfo.ManufacturerName = self.manufacturer_name status.BuildInfo.ProductName = self.name status.BuildInfo.SoftwareVersion = "1.0pre" status.BuildInfo.BuildNumber = "0" status.BuildInfo.BuildDate = datetime.now() status.SecondsTillShutdown = 0 status_node.set_value(status) build_node.set_value(status.BuildInfo) # enable all endpoints by default self._security_policy = [ ua.SecurityPolicyType.NoSecurity, ua.SecurityPolicyType.Basic128Rsa15_SignAndEncrypt, ua.SecurityPolicyType.Basic128Rsa15_Sign, ua.SecurityPolicyType.Basic256_SignAndEncrypt, ua.SecurityPolicyType.Basic256_Sign ] self._policyIDs = ["Anonymous", "Basic256", "Basic128", "Username"]