Beispiel #1
0
 def watch_get_all(self):
     
     msg = Message("WATCH_GET")
     msg.set_str('field_name', 'config_child')
     msg.set_array('field_value', ["0"])
     
     return msg
    def read_msg(self, data, offset):
        msg_headers = self.read_msg_header(data, offset)

        msg_header = msg_headers[0]
        msg_offset = msg_headers[1]

        msg = Message(msg_header[0])

        for idx, field_name in enumerate(msg_header):
            if idx > 0:
                sigs = self.read_signature(data, msg_offset)
                sig = sigs[0]
                msg_offset = sigs[1]

                if sig == self.packet_type.INTEGER:
                    rtn_ints = self.read_int(data, msg_offset)
                    rtn_int = rtn_ints[0]
                    msg_offset = rtn_ints[1]

                    msg.set_int(field_name, rtn_int)

                elif sig == self.packet_type.FLOAT:
                    rtn_floats = self.read_float(data, msg_offset)
                    rtn_float = rtn_floats[0]
                    msg_offset = rtn_floats[1]

                    msg.set_float(field_name, rtn_float)
                elif sig == self.packet_type.LONG:
                    rtn_longs = self.read_long(data, msg_offset)
                    rtn_long = rtn_longs[0]
                    msg_offset = rtn_longs[1]

                    msg.set_long(field_name, rtn_long)
                elif sig == self.packet_type.STRING:
                    rtn_strs = self.read_str(data, msg_offset)
                    rtn_str = rtn_strs[0]
                    msg_offset = rtn_strs[1]

                    msg.set_str(field_name, rtn_str)
                elif sig == self.packet_type.BYTES:
                    rtn_bins = self.read_bytes(data, msg_offset)
                    rtn_bin = rtn_bins[0]
                    msg_offset = rtn_bins[1]

                    msg.set_bytes(field_name, rtn_bin)
                elif sig == self.packet_type.COMPLEX:
                    rtn_msgs = self.read_msg(data, msg_offset)
                    rtn_msg = rtn_msgs[0]
                    msg_offset = rtn_msgs[1]

                    msg.set_msg(field_name, rtn_msg)
                elif sig == self.packet_type.ARRAY:
                    rtn_arrays = self.read_array(data, msg_offset)
                    rtn_array = rtn_arrays[0]
                    msg_offset = rtn_arrays[1]

                    msg.set_array(field_name, rtn_array)

        return (msg, msg_offset)
Beispiel #3
0
    def login(self):

        msg = Message("LOGIN")
        msg.set_str('user_id', 'root')
        msg.set_str('user_pw', 'changeit')
        msg.set_int('client_type', 6)

        return msg
Beispiel #4
0
    def channel_get(self):

        objectId = self.readCommand('object id')

        msg = Message("CHANNEL_GET")
        msg.set_str('field_name', 'object_id')
        msg.set_array('field_value', [objectId])

        return msg
Beispiel #5
0
 def watch_get(self):
     
     objectId = self.readCommand('object id')
     
     msg = Message("WATCH_GET")
     msg.set_str('field_name', 'object_id')
     msg.set_array('field_value', [objectId])
     
     return msg
    def config_get(self):

        objectId = self.readCommand('object id')

        msg = Message("CONFIG_GET")
        msg.set_str('field_name', 'object_id')
        msg.set_array('field_value', [objectId])

        return msg
Beispiel #7
0
    def channel_get_all(self):

        msg = Message("CHANNEL_GET")
        msg.set_str('base_config_id', '0')
        msg.set_str('channel_type', '*')
        msg.set_str('field_name', 'list')
        msg.set_str('object_id', '*')
        msg.set_str('os', '*')
        msg.set_str('watch_type', '*')
        msg.set_array('field_value', [])

        return msg
    def fault_get_current(self):
        msg = Message("FAULT_GET_CURRENT")
        msg.set_str('field_name', 'config_id')
        msg.set_array('field_value', [])

        return msg
Beispiel #9
0
import copy

import struct

from insoft.openmanager.message.message import Message
from insoft.openmanager.message.packet import Packet
from insoft.openmanager.message.packet_reader import PacketReader
from insoft.openmanager.message.packet_writer import PacketWriter

msg = Message("MESSAGE_TEST")

msg.set_int("integer", 1)
msg.set_float("float", 2.0)
msg.set_long("long", 3)
msg.set_str("str", "message_test")
msg.set_bytes("byte", bytes("message", "utf-8"))
msg.set_msg("msg", Message("NEW_MESSAGE"))
msg.set_array("array", ["A", "B", "C"])

print(msg)
Beispiel #10
0
import copy
import socket
import struct
import time

from insoft.openmanager.message.message import Message
from insoft.openmanager.message.packet import Packet
from insoft.openmanager.message.packet_reader import PacketReader
from insoft.openmanager.message.packet_writer import PacketWriter
from insoft.openmanager.message.client_packet_dof import DofClientPacket

msg = Message("LOGIN")
msg.set_str('user_id', 'root')
msg.set_str('user_pw', 'changeit')
msg.set_int('client_type', 6)

print(msg)

addr = ('192.168.9.62', 9100)
s = socket.socket()
s.connect(addr)

packet_writer = PacketWriter()
b_msg = packet_writer.parse_to_bytes(msg)

client_packet = DofClientPacket()
client_packet.send(s, b_msg)

print("send message...")

time.sleep(3)
    def config_get_all(self):
        msg = Message("CONFIG_GET")
        msg.set_str('field_name', 'user_configs')
        msg.set_array('field_value', ['0'])

        return msg