示例#1
0
文件: main.py 项目: GunioRobot/closin
 def create_service(self, name, data):
     service = model.Service.all().filter("name", name).get()
     if not service:
         service = model.Service(name=name, data=json.dumps(data))
     else:
         service.data = json.dumps(data)
     service.put()
     self.render_json(service.data)
示例#2
0
def deploy_two_products_in_vm(request, template_name):
    atts = []
    atts.append({'port': '8080'})
    template = model.Template(template_name)
    product = model.Product('tomcat', 'io.murano.apps.apache.Tomcat', atts)
    net = model.Network("node-int-net-01", True)
    inst = model.Instance('ubuntu', 'Ubuntu14.04init_deprecated', '2', '',
                          False, [net])
    service = model.Service(product.name, product)
    service.add_instance(inst)
    template.add_service(service)

    product2 = model.Product('tomcat', 'io.murano.apps.apache.Tomcat', atts)
    service2 = model.Service(product2.name, product2)
    service.add_instance(inst, True)
    template.add_service(service2)
    request.deploy_template(template)
示例#3
0
def deploy_blueprint_template(request, template_name, product):
    template = model.Template(template_name)
    net = model.Network("node-int-net-01", True)
    inst = model.Instance('ubuntu', 'Ubuntu14.04init_deprecated', '2', '',
                          False, [net])
    service = model.Service(product.name, product)
    service.add_instance(inst)
    template.add_service(service)
    request.deploy_template(template)
示例#4
0
def deploy_no_network(request, template_name):
    atts = []
    atts.append({'port': '8080'})
    template = model.Template(template_name)
    product = model.Product('tomcat', 'io.murano.apps.apache.Tomcat', atts)
    inst = model.Instance('ubuntu', 'Ubuntu14.04init_deprecated', '2', '',
                          False)
    service = model.Service(product.name, product)
    service.add_instance(inst)
    template.add_service(service)
    request.deploy_template(template)
示例#5
0
def deploy_orion_docker(request, template_name):
    template = model.Template(template_name)
    net = model.Network("node-int-net-01", True)

    inst = model.Instance('ubuntu', 'Ubuntu14.04init_deprecated', '2', '',
                          False, [net])
    product = model.Product('docker',
                            'io.murano.apps.docker.DockerStandaloneHost')
    service = model.Service(product.name, product)
    service.add_instance(inst)

    atts = []
    atts.append({'publish': True})
    atts.append({'host': product.id})
    product = model.Product('dockerorion', 'io.murano.apps.docker.DockerOrion',
                            atts)
    service2 = model.Service(product.name, product)

    template.add_service(service)
    template.add_service(service2)
    request.deploy_template(template)
示例#6
0
def deploy_orion_chef(request, template_name):
    atts = []
    atts.append({'port': '1026'})
    product = model.Product('orionchef', 'io.murano.conflang.chef.GitChef',
                            atts)
    template = model.Template(template_name)
    net = model.Network("node-int-net-01", True)
    inst = model.Instance('centos', 'CentOS-6.5init_deprecated', '2', 'demo4',
                          False, [net])
    service = model.Service(product.name, product)
    service.add_instance(inst)
    template.add_service(service)
    request.deploy_template(template)
示例#7
0
def update_lists(jsonrpc):
    # safety check omitted for brevity
    data = jsonrpc["params"]["data"]
    url = jsonrpc["params"]["url"]

    # Remove if exist slash at the end of url
    if url.endswith('/'):
        url = url[:-1]

    # if GW posting list of ids
    if "id" in data:
        for i in data["id"]:
            print(i)
        return

    # else data contain object
    item_id = jsonrpc["params"]["data"][":id"]

    if jsonrpc["method"] == "PUT":
        # url contain UUID at the end
        item = url.split('/')[-2]
        # TODO check what kingd of item and update item
        print(Colors.WARNING + "TODO --- Update item: " + item + Colors.ENDC)
        return

    # else - POST
    item = url.split('/')[-1]
    parent_id = url.split('/')[-2]

    if item == "gateway":
        global gateway
        gateway = model.Gateway(data, url, None)
        print(gateway)

    if item == "network":
        global network
        network = model.Network(data, url, None)
        print(network)

    if item == "device":
        device = model.Device(data, url, parent_id)
        if device.data["included"] == "0":
            device.data["included"] = "1"
            client = Client("/tmp/zero_interface")
            client.includeDevice(device)
        else:
            create_update_item(device, devices)
            if device.data['product']:
                print('product: {}'.format(device.data['product']))
            if device.data['version_hardware']:
                print("version_hardware: {}".format(
                    device.data['version_hardware']))
            if device.data['version_stack']:
                print("version_stack: {}".format(device.data['version_stack']))
            if device.data['version_boot']:
                print("version_boot: {}".format(device.data['version_boot']))
            if device.data['version_application']:
                print("version_application: {}".format(
                    device.data['version_application']))

    if item == "service":
        service = model.Service(data, url, parent_id)
        create_update_item(service, services)

    if item == "value":
        value = model.Value(data, url, parent_id)
        create_update_item(value, values)

    if item == "status":
        level = data["level"]
        status_type = data["type"]
        message = data["message"]
        print(Colors.OKGREEN + "Status level: '" + level + "' type: '" +
              status_type + "' message: '" + message + "'" + Colors.ENDC)

    if item == "configuration":
        configuration = model.Configuration(data, url, parent_id)
        create_update_item(configuration, configurations)

    if item == "partner":
        partner = model.Partner(data, url, parent_id)
        create_update_item(partner, partners)

    if item == "action":
        action = model.Action(data, url, parent_id)
        create_update_item(action, actions)

    if item == "calendar":
        calendar = model.Calendar(data, url, parent_id)
        create_update_item(calendar, calendars)

    if item == "calculation":
        calculation = model.Calculation(data, url, parent_id)
        create_update_item(calculation, calculations)

    if item == "timer":
        timer = model.Timer(data, url, parent_id)
        create_update_item(timer, timers)

    if item == "statemachine":
        machine = model.StateMachine(data, url, parent_id)
        create_update_item(machine, statemachines)