Пример #1
0
    def __init__(self):
        super(main, self).__init__()
        self.logger = logging.getLogger(self.__class__.__name__)
        self.logger.info('initializing Self-Adaptive System')

        KB = KnowledgeBase.KnowledgeBase()
        KB.loadGoalModel('car-wheel.json')

        E = Executor.Executor(KB)
        P = Planner.Planner(KB, E)
        A = Analyzer.Analyzer(KB, P)
        M = Monitor.Monitor(KB)
Пример #2
0
 def __init__(self, ip, def_perms=Permissions.Guest):
     # установка адреса, порта, главного сокета
     self.HOST = ip
     self.PORT = 9090
     self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
     self.sock.bind((self.HOST, self.PORT))
     self.sock.listen(10)
     # инициализация списков юзеров, блокировок
     self.blacklist = []
     self.users = []
     # создание потока приема новых пользователей
     self.th = threading.Thread(target=self.acceptor)
     self.th.start()
     # создание обработчика команд
     self.executor = Executor(self)
     # установка стандартных прав при входе на сервер
     Permissions.Default = def_perms
     self.users.append(ConsoleUser(self))
Пример #3
0
#!/usr/bin/python
#coding:utf-8
import sys
from Executor import *

#获取参数
cmd = sys.argv[1]

#设置端口和ip
ip = 2
sshPort = "40011"

#初始化实例
executor = Executor('value-dnsmasq', {
    "ip": ip,
})
print(executor.get_ip())
Пример #4
0
#coding:utf-8
import sys
from Executor import *

#获取参数
cmd = sys.argv[1]
index = sys.argv[2]

#设置端口和ip
startPort = (4020 + int(index)) * 10
ip = str(100 + int(index))
sshPort = str(startPort + 1)
memPort = str(startPort + 2)
twPort = str(startPort + 3)

#初始化实例
executor = Executor(
    'value-cs', {
        "ip": ip,
        "sshPort": sshPort,
        "portMap": {
            "127.0.0.1:" + sshPort: "22",
            memPort: "11211",
            twPort: "22122"
        },
        "volumeMap": {
            "~/authorized_keys": "/root/.ssh/authorized_keys"
        }
    })
executor.execute(cmd, index)
Пример #5
0
from Memory import *
from Reader import *
from Executor import *
memory = Memory()
reader = Reader(memory)
executor = Executor(memory)
memory.consolePrintMemory()
reader.launch()
executor.executor()
memory.consolePrintMemory()
Пример #6
0
#!/usr/bin/python
#coding:utf-8
import sys
from Executor import *

#获取参数
cmd = sys.argv[1]
index = sys.argv[2]

#设置端口和ip
startPort = (4161 + int(index)) * 10
ip = str(80 + int(index))
sshPort = str(startPort + 1)
ftpPort = str(startPort + 2)

#初始化实例
executor = Executor(
    'value-ftp', {
        "ip": ip,
        "sshPort": sshPort,
        "portMap": {
            "127.0.0.1:" + sshPort: "22",
            ftpPort: "21"
        },
        "volumeMap": {
            "~/authorized_keys": "/root/.ssh/authorized_keys",
            "/home/ftp/pureftp" + str(index): "/home/ftp"
        }
    })
executor.execute(cmd, index)
Пример #7
0
import sys
import os
import time
import fileinput
from Executor import *

#获取参数
cmd = sys.argv[1]
index = sys.argv[2]

#设置端口和ip
startPort = (4181 + int(index)) * 10
ip = str(130 + int(index))
sshPort = str(startPort + 1)
debugPort = str(startPort + 2)

executor = Executor(
    'el-stat', {
        "ip": ip,
        "sshPort": sshPort,
        "portMap": {
            "127.0.0.1:" + sshPort: "22",
            debugPort: "9999"
        },
        "volumeMap": {
            "~/authorized_keys": "/root/.ssh/authorized_keys",
            "/home/res/eduos/stat": "/home/stat"
        }
    })
executor.execute(cmd, index)
Пример #8
0
cmd = sys.argv[1]
index = sys.argv[2]

#设置端口和ip
startPort = (4031 + int(index)) * 10
ip = str(140 + int(index))
sshPort = str(startPort + 1)
trackerPort = str(startPort + 2)
storagePort = str(startPort + 3)

#初始化实例
executor = Executor(
    'value-fdfs', {
        "ip": ip,
        "sshPort": sshPort,
        "portMap": {
            "127.0.0.1:" + sshPort: "22",
            trackerPort: "22122",
            storagePort: str(storagePort)
        },
        "volumeMap": {
            "/home/res/fdfs/fdfs" + index: "/home/fdfs",
            "~/authorized_keys": "/root/.ssh/authorized_keys"
        }
    })
executor.execute(cmd, index)

#if cmd == 'create':
#    time.sleep(5)
#    os.system("ssh [email protected] -p %s 'sh /root/init.sh'" % (sshPort,))
Пример #9
0
import time
from Executor import *

#获取参数
cmd = sys.argv[1]
index = sys.argv[2]

#设置端口和ip
startPort = (4091 + int(index)) * 10
ip = str(40 + int(index))
sshPort = str(startPort + 1)

#初始化实例
elmExe = Executor(
    'elm-as', {
        "ip": ip,
        "sshPort": sshPort,
        "portMap": {
            "127.0.0.1:" + sshPort: "22"
        },
        "volumeMap": {
            "/home/res/elm": "/home/res/elm",
            "~/authorized_keys": "/root/.ssh/authorized_keys"
        }
    })
elmExe.execute(cmd, index)
#如果是新增或重启容器,则还要重启应用
if cmd == 'create' or cmd == 'restart':
    time.sleep(5)
    elmExe.app_restart(index)
Пример #10
0
#coding:utf-8
import sys
from Executor import *

#获取参数
cmd = sys.argv[1]
index = sys.argv[2]

#设置端口和ip
startPort = (4171 + int(index)) * 10
ip = str(90 + int(index))
sshPort = str(startPort + 1)
dbPort = str(startPort + 2)
adminPort = str(startPort + 3)

#初始化实例
executor = Executor(
    'value-atlas', {
        "ip": ip,
        "sshPort": sshPort,
        "portMap": {
            "127.0.0.1:" + sshPort: "22",
            dbPort: "1234",
            adminPort: "2345"
        },
        "volumeMap": {
            "~/authorized_keys": "/root/.ssh/authorized_keys"
        }
    })
executor.execute(cmd, index)
Пример #11
0
#coding:utf-8
import sys
from Executor import *

#获取参数
cmd = sys.argv[1]
index = sys.argv[2]

#设置端口和ip
startPort = (4050 + int(index)) * 10
ip = str(110 + int(index))
sshPort = str(startPort + 1)
rtmpPort = str(startPort + 2)
httpPort = str(startPort + 3)

#初始化实例
executor = Executor('value-sms', {
    "ip": ip,
    "sshPort": sshPort,
    "portMap": {
        "127.0.0.1:" + sshPort: "22",
        rtmpPort: "1935",
        httpPort: "80"
    },
    "volumeMap": {
        "/home/res/sms": "/home/sms",
        "~/authorized_keys": "/root/.ssh/authorized_keys"
    }
})
executor.execute(cmd, index)
Пример #12
0
#!/usr/bin/python
#coding:utf-8
import sys
from Executor import *

#获取参数
cmd = sys.argv[1]
index = sys.argv[2]

#设置端口和ip
startPort = (4150 + int(index)) * 10
ip = str(70 + int(index))
sshPort = str(startPort + 1)
redisPort = str(startPort + 2)

#初始化实例
executor = Executor(
    'value-redis', {
        "ip": ip,
        "sshPort": sshPort,
        "portMap": {
            "127.0.0.1:" + sshPort: "22",
            redisPort: "6379"
        },
        "volumeMap": {
            "~/authorized_keys": "/root/.ssh/authorized_keys"
        }
    })
executor.execute(cmd, index)
Пример #13
0
#coding:utf-8
import sys
import time
from Executor import *

#获取参数
cmd = sys.argv[1]
index = sys.argv[2]

#设置端口和ip
startPort = (4191 + int(index)) * 10
ip = str(150 + int(index))
sshPort = str(startPort + 1)
serverPort = str(startPort + 2)

#初始化实例
executor = Executor(
    'value-nodejs', {
        "ip": ip,
        "sshPort": sshPort,
        "portMap": {
            "127.0.0.1:" + sshPort: "22",
            serverPort: "3000"
        },
        "volumeMap": {
            "/home/res/nodejs": "/home/nodejs",
            "~/authorized_keys": "/root/.ssh/authorized_keys"
        }
    })
executor.execute(cmd, index)
Пример #14
0
from Executor import *

# Use global variables for now

# Path to executables
path = "C:/Windows/System32/"
# name of programs to run (name.exe)
programs = ["notepad.exe"]
# how many seconds to run a program, before running next
# one week = 604800
timeOut = 5

if __name__ == '__main__':
    ex = Executor(path, programs, timeOut)
    ex.execute()
Пример #15
0
#!/usr/bin/python

import os
import sys

try:
    from fabricate import *
    from Executor import *
except ImportError, e:
    print "Couldn't find the fabricate module."
    sys.exit(1)

e = Executor(logPrefix="[multicast] ")

sources = ['multicast.c']
target = 'multicast'
includes = []

cflags = ['-O2', '-std=gnu99'] + includes


def build():
    compile()
    link()


def compile():
    for source in sources:
        run('gcc', cflags, '-c', source, '-o', source.replace('.c', '.o'))

Пример #16
0
#!/usr/bin/python
#coding:utf-8
import sys
from Executor import *

cmd = sys.argv[1]
index = sys.argv[2]
startPort = (4051 + int(index)) * 10
ip = str(10 + int(index))
sshPort = str(startPort + 1)
nginxPort = str(startPort + 2)

#初始化实例
executor = Executor('value-slb', {
    "ip": ip,
    "sshPort": sshPort,
    "portMap": {
        "127.0.0.1:" + sshPort: "22",
        "127.0.0.1:" + nginxPort: "80"
    },
    "volumeMap": {
        "~/authorized_keys": "/root/.ssh/authorized_keys"
    }
})
executor.execute(cmd, index)

Пример #17
0
index = sys.argv[2]

#设置端口和ip
startPort = (4040 + int(index)) * 10
ip = str(120 + int(index))
sshPort = str(startPort + 1)
ftpPort = str(startPort + 2)

#初始化实例
executor = Executor(
    'value-cw', {
        "ip": ip,
        "sshPort": sshPort,
        "portMap": {
            "127.0.0.1:" + sshPort: "22",
            ftpPort: "21"
        },
        "volumeMap": {
            "/home/res/eduos/cw": "/home/cw",
            "/home/res/paper": "/home/paper",
            "~/authorized_keys": "/root/.ssh/authorized_keys"
        }
    })
executor.execute(cmd, index)

if cmd == 'create':
    time.sleep(5)
    os.system("ssh [email protected] -p %s 'sh /root/install.sh'" % (sshPort, ))

if cmd == 'create' or cmd == 'restart':
    time.sleep(5)
    executor.app_restart(index)
Пример #18
0
#设置端口和ip
startPort = (4141 + int(index)) * 10
ip = str(60 + int(index))
sshPort = str(startPort + 1)
serverPort = str(startPort + 2)
debugPort = str(startPort + 3)

if cmd == 'create':
    hostIp = os.environ.get('HOST_IP')
    os.system("mkdir -p /home/res/eduos/fsc/" + index)
    os.system("echo " + hostIp + ":" + serverPort + " > /home/res/eduos/fsc/" +
              index + "/ip.txt")

executor = Executor(
    'eduos-fsc', {
        "ip": ip,
        "sshPort": sshPort,
        "portMap": {
            "127.0.0.1:" + sshPort: "22",
            serverPort: "10081",
            debugPort: "9999"
        },
        "volumeMap": {
            "~/authorized_keys": "/root/.ssh/authorized_keys",
            "/home/res/eduos/fsc/app": "/home/fsc",
            "/home/res/eduos/fsc/" + index + "/ip.txt": "/root/ip.txt",
        }
    })
executor.execute(cmd, index)
Пример #19
0
#!/usr/bin/python
#coding:utf-8
import sys
from Executor import *

#获取参数
cmd = sys.argv[1]
index = sys.argv[2]

#设置端口和ip
startPort = (4110 + int(index)) * 10
ip = str(160 + int(index))
sshPort = str(startPort + 1)

#初始化实例
executor = Executor(
    'value-db', {
        "ip": ip,
        "sshPort": sshPort,
        "portMap": {
            "127.0.0.1:" + sshPort: "22"
        },
        "volumeMap": {
            "/home/mysql/mysql" + str(index): "/home/mysql",
            "~/authorized_keys": "/root/.ssh/authorized_keys"
        }
    })
executor.execute(cmd, index)
Пример #20
0
#!/usr/bin/python
#coding:utf-8
import sys
import time
from Executor import *

#获取参数
cmd = sys.argv[1]

#初始化实例
executor = Executor(
    'jenkins', {
        "ip": "3",
        "sshPort": "40001",
        "portMap": {
            "127.0.0.1:40001:22",
        },
        "volumeMap": {
            "~/authorized_keys": "/root/.ssh/authorized_keys"
        }
    })
executor.execute(cmd)
if cmd == 'restart':
    time.sleep(2)
    executor.app_restart("0")
Пример #21
0
            if (int(str(val[0]), 16) > 7):
                val = "F" * (8 - len(val)) + val
            else:
                val = "0" * (8 - len(val)) + val
        n = list(int(i, 16) for i in val)
        if (n[0] < 8):
            return (int(val, 16) % (2**(bits - 1)))
        else:
            nc = list(15 - i for i in n)
            nc[len(nc) - 1] += 1
            for i in range(len(nc) - 1, 1, -1):
                if (nc[i] == 16):
                    nc[i] = 0
                    nc[i - 1] += 1
            new_val = "".join(list(hex(i) for i in nc)).replace("0x", "")
            return -(int(new_val, 16) % (2**(bits - 1)))


class BuilderState:
    NONE = 0
    STATIC = 1
    CODE = 2


if __name__ == "__main__":
    Sim = Simulator("/Users/Seth/Desktop/MIPS Simulator/example.asm", 32)
    ex = Executor(Sim.memory.initialize(), Sim.registers)
    while (ex.can_execute()):
        Sim.registers = ex.execute()
        Sim.view()
        raw_input("")
Пример #22
0
#coding:utf-8
import sys
from Executor import *

#获取参数
cmd = sys.argv[1]
index = sys.argv[2]

#设置端口和ip
startPort = (4121 + int(index)) * 10
ip = str(180 + int(index))
sshPort = str(startPort + 1)
serverPort = str(startPort + 2)
httpPort = str(startPort + 3)

#初始化实例
executor = Executor(
    'value-metaq', {
        "ip": ip,
        "sshPort": sshPort,
        "portMap": {
            "127.0.0.1:" + sshPort: "22",
            serverPort: serverPort,
            httpPort: "8120"
        },
        "volumeMap": {
            "~/authorized_keys": "/root/.ssh/authorized_keys"
        }
    })
executor.execute(cmd, index)