Пример #1
0
def zone_insert_mx(tags):
    # Get Zone
    fields = tags['id_record']
    record = list()
    column_record = model.get_columns("v_record")
    query = "select * from v_record where id_record='"+fields+"' AND nm_type='MX'"
    db.execute(query)
    rows = db.fetchall()
    for row in rows:
        record.append(dict(zip(column_record, row)))
    column_ttl = model.get_columns("v_ttldata")
    query = "select * from v_ttldata where id_record='"+fields+"' AND nm_type='MX'"
    db.execute(query)
    rows = db.fetchall()
    ttldata = list()
    for row in rows:
        ttldata.append(dict(zip(column_ttl, row)))
    
    content_data = list()
    column_cdata= model.get_columns("v_contentdata")
    query = "select * from v_contentdata where id_record='"+fields+"' AND nm_type='MX'"
    db.execute(query)
    rows = db.fetchall()
    for row in rows:
        content_data.append(dict(zip(column_cdata, row)))

    content_serial = list()
    column_cserial= model.get_columns("v_content_serial")
    query = "select * from v_content_serial where id_record='"+fields+"' AND nm_type='MX'"
    db.execute(query)
    rows = db.fetchall()
    for row in rows:
        content_serial.append(dict(zip(column_cserial, row)))
    
    serial_data = ""
    data = ""
    for ns in content_data:
        data = data+" "+ns['nm_content']
    for serial in content_serial:
        serial_data = serial_data+" "+serial['nm_content_serial']
    data_ns_soa = data
    data_ns_serial = serial_data

    json_command = {
                    "srv-set": {
                        "sendblock": {
                            "cmd": "zone-set",
                            "zone": record[0]['nm_zone'],
                            "owner": record[0]['nm_record'],
                            "rtype": record[0]['nm_type'],
                            "ttl": ttldata[0]['nm_ttl'],
                            "data": data_ns_soa+""+data_ns_serial
                        },
                        "receive": {
                            "type": "command"
                        }
                    }
                }
    return json_command
Пример #2
0
def get_cleanup_id(domainname):
    obj_userdata= list()
    column = model.get_columns("v_all_content")
    query = "SELECT * FROM v_all_content WHERE nm_zone = \'"+domainname+"""\'"""
    try:
        result = list()
        db.execute(query)
        rows = db.fetchall()
        for row in rows:
            result.append(dict(zip(column,row)))
        
    except Exception as e:
        respons = {
            "status" : False,
            "messages":str(e)
        }
    else:
        for i in result:
            data = {
                "id_zone": str(i['id_zone']),
                "id_content": str(i['id_content']),
                "id_content_serial": str(i['id_content_serial']),
                "id_ttldata": str(i['id_ttldata']),
                "id_record": str(i['id_record'])
            }
            obj_userdata.append(data)    
    finally:
        return obj_userdata
Пример #3
0
def user_get():
    id_userdata = get_jwt_identity()
    obj_userdata = list()
    column = db.get_columns('tb_userdata')
    try:
        results = list()
        query = "select * from tb_userdata where id_userdata='"+id_userdata+"' "
        data = db.query(query)
        rows = dbq.fetchall()
        for row in rows:
            print(row)
            results.append(dict(zip(column, row)))
    except Exception as e:
        return response(200, message=str(e))
    else:
        for i in results :
            data = {
                "id_userdata": str(i['id_userdata']),
                "email" : i['email'],
                "first_name" : i['first_name'],
                "last_name" : i['last_name'],
                "location" : i['location']
            }
            obj_userdata.append(data)
        return response(200, data=obj_userdata)
Пример #4
0
def zone_ns_insert(tags):
    fields = str(list(tags.keys())[0])
    record = list()
    column_record = model.get_columns("v_record")
    query = "select * from v_record where "+fields+"='"+tags[fields]+"' AND nm_type='NS'"
    db.execute(query)
    rows = db.fetchall()
    for row in rows:
        record.append(dict(zip(column_record, row)))

    ttldata = list()
    column_ttldata = model.get_columns("v_ttldata")
    query = "select * from v_ttldata where id_record='"+str(record[0]['id_record'])+"'"
    db.execute(query)
    rows = db.fetchall()
    for row in rows:
        ttldata.append(dict(zip(column_ttldata, row)))

    ctdata = list()
    column_ctdata = model.get_columns("v_contentdata")
    query = "select * from v_contentdata where id_record='"+str(record[0]['id_record'])+"'"
    db.execute(query)
    rows = db.fetchall()
    for row in rows:
        ctdata.append(dict(zip(column_ctdata, row)))
    command_ns = list()
    for ctn in ctdata:
        json_command={
            "zone-set": {
                "sendblock": {
                    "cmd": "zone-set",
                    "zone": record[0]['nm_zone'],
                    "owner": "@",
                    "rtype": record[0]['nm_type'],
                    "ttl": ttldata[0]['nm_ttl'],
                    "data": ctn['nm_content']
                },
                "receive": {
                    "type": "block"
                }
            }
        }
        command_ns.append({
            "id_record": record[0]['id_record'],
            "command": json_command
        })
    return command_ns
Пример #5
0
def zone_insert(tags):
    # Get Record Data
    id_record = tags['id_record']
    record = list()
    column_record = model.get_columns("v_record")
    query = "select * from v_record where id_record='"+id_record+"'"
    db.execute(query)
    rows = db.fetchall()
    for row in rows:
        record.append(dict(zip(column_record, row)))
    
    ttldata = list()
    column_ttldata = model.get_columns("v_ttldata")
    query = "select * from v_ttldata where id_record='"+str(record[0]['id_record'])+"'"
    db.execute(query)
    rows = db.fetchall()
    for row in rows:
        ttldata.append(dict(zip(column_ttldata, row)))
    
    ctdata = list()
    column_ctdata = model.get_columns("v_contentdata")
    query = "select * from v_contentdata where id_record='"+str(record[0]['id_record'])+"'"
    db.execute(query)
    rows = db.fetchall()
    for row in rows:
        ctdata.append(dict(zip(column_ctdata, row)))
    json_command={
        "zone-set": {
            "sendblock": {
                "cmd": "zone-set",
                "zone": record[0]['nm_zone'],
                "owner": record[0]['nm_record'],
                "rtype": record[0]['nm_type'],
                "ttl": ttldata[0]['nm_ttl'],
                "data": ctdata[0]['nm_content']
            },
            "receive": {
                "type": "block"
            }
        }
    }
    return json_command
Пример #6
0
def zone_unset(tags):
    id_record = tags['id_record']
    record = list()
    column_record = model.get_columns("v_record")
    query = "select * from v_record where id_record='"+id_record+"'"
    db.execute(query)
    rows = db.fetchall()
    for row in rows:
        record.append(dict(zip(column_record, row)))
    json_command={
        "zone-unset": {
            "sendblock": {
                "cmd": "zone-unset",
                "zone": record[0]['nm_zone'],
                "owner": record[0]['nm_record'],
                "rtype": record[0]['nm_type']
            },
            "receive": {
                "type": "block"
            }
        }
    }
    return json_command
Пример #7
0
def conf_unset(tags):
    id_zone = tags['id_zone']
    record = list()
    column_record = model.get_columns("zn_zone")
    query = "select * from zn_zone where id_zone='"+id_zone+"'"
    db.execute(query)
    rows = db.fetchall()
    for row in rows:
        record.append(dict(zip(column_record, row)))
    json_command={
        "conf-unset": {
            "sendblock": {
                "cmd": "conf-unset",
                "section": "zone",
                "item": "domain",
                "data":record[0]['nm_zone']
            },
            "receive": {
                "type": "block"
            }
        }
    }
    return json_command
Пример #8
0
def zone_soa_insert_default(tags):
    # Get Zone
    fields = str(list(tags.keys())[0])
    record = list()
    column_record = model.get_columns("v_record")
    query = "select * from v_record where "+fields+"='"+tags[fields]+"' AND nm_type='SOA'"
    db.execute(query)
    rows = db.fetchall()
    for row in rows:
        record.append(dict(zip(column_record, row)))

    column_ttl = model.get_columns("v_ttldata")
    query = "select * from v_ttldata where "+fields+"='"+tags[fields]+"' AND nm_type='SOA'"
    db.execute(query)
    rows = db.fetchall()
    ttldata = list()
    for row in rows:
        ttldata.append(dict(zip(column_ttl, row)))
    
    content_data = list()
    column_cdata= model.get_columns("v_contentdata")
    query = "select * from v_contentdata where "+fields+"='"+tags[fields]+"' AND nm_type='SOA'"
    db.execute(query)
    rows = db.fetchall()
    for row in rows:
        content_data.append(dict(zip(column_cdata, row)))

    content_serial = list()
    column_cserial= model.get_columns("v_content_serial")
    query = "select * from v_content_serial where "+fields+"='"+tags[fields]+"' AND nm_type='SOA'"
    db.execute(query)
    rows = db.fetchall()
    for row in rows:
        content_serial.append(dict(zip(column_cserial, row)))
    
    serial_data = ""
    data = ""
    date_t = record[0]['date_record']

    for ns in content_data:
        data = data+" "+ns['nm_content']
    data_ns_soa = data

    for serial in content_serial:
        serial_data = serial_data+" "+serial['nm_content_serial']
    data_ns_serial = serial_data
    json_command={
        "soa-set": {
            "sendblock": {
                "cmd": "zone-set",
                "zone": record[0]['nm_zone'],
                "owner": record[0]['nm_record'],
                "rtype": "SOA",
                "ttl": ttldata[0]['nm_ttl'],
                "data": data_ns_soa+" "+date_t+" "+data_ns_serial
            },
            "receive": {
                "type": "command"
            }
        }
    }
    # print(json_command)
    return record[0]['id_record'], json_command
Пример #9
0
    def post(self):
        json_req = request.get_json(force=True)
        command = utils.get_command(request.path)
        command = 'dt_' + command
        init_data = cmd.parser(json_req, command)
        respons = dict()
        if init_data['action'] == 'insert':
            table = init_data['data'][0]['table']
            fields = init_data['data'][0]['fields']
            try:
                result = model.insert(table, fields)
            except Exception as e:
                respons = {"status": False, "error": str(e)}
            else:
                respons = {"status": True, "messages": "Success", "id": result}
            finally:
                return response(200, data=fields, message=respons)
        if init_data['action'] == 'remove':
            table = ""
            tags = dict()
            fields = ""
            for i in init_data['data']:
                table = i['table']
                tags = i['tags']
            fields = str(list(tags.keys())[0])
            try:
                result = model.delete(table, fields, tags[fields])
            except Exception as e:
                respons = {"status": False, "messages": str(e)}
            else:
                respons = {"status": result, "messages": "Success!"}
            finally:
                return response(200, data=tags, message=respons)

        if init_data['action'] == 'where':
            obj_userdata = list()
            table = ""
            fields = ""
            tags = dict()
            for i in init_data['data']:
                table = i['table']
                tags = i['tags']
                for a in tags:
                    if tags[a] is not None:
                        fields = a
            try:
                result = model.get_by_id(table, fields, tags[fields])
            except Exception as e:
                respons = {"status": False, "messages": str(e)}
            else:
                for i in result:
                    data = {
                        "id_hosting": str(i['id_hosting']),
                        "id_company_product": str(i['id_company_product']),
                        'spec_price': i['spec_price'],
                        "spec_storage": i['spec_storage'],
                        'spec_database': i['spec_database'],
                        "spec_free_domain": i['spec_free_domain'],
                        "spec_hosting_domain": i['spec_hosting_domain'],
                        'spec_subdomain': i['spec_subdomain'],
                        "spec_ftp_user": i['spec_ftp_user'],
                        "spec_control_panel": i['spec_control_panel'],
                        'spec_email_account': i['spec_email_account'],
                        "spec_spam_filter": i['spec_spam_filter'],
                        "date_time": i['date_time']
                    }
                    obj_userdata.append(data)
                respons = {"status": True, "messages": "Fine!"}
            finally:
                return response(200, data=obj_userdata, message=respons)
        if init_data['action'] == 'view':
            obj_userdata = list()
            table = ""
            fields = None
            tags = dict()
            for i in init_data['data']:
                table = i['table']
                tags = i['tags']
                for a in tags:
                    if tags[a] is not None:
                        fields = a
            column = model.get_columns("v_product_hosting")
            try:
                result = list()
                if fields is None:
                    query = """select * from v_product_hosting"""
                    db.execute(query)
                    rows = db.fetchall()
                    for row in rows:
                        result.append(dict(zip(column, row)))
                else:
                    query = """ select * from v_product_hosting where """ + fields + """='""" + tags[
                        fields] + """'"""
                    db.execute(query)
                    rows = db.fetchall()
                    for row in rows:
                        result.append(dict(zip(column, row)))
            except Exception as e:
                respons = {"status": False, "messages": str(e)}
            else:
                for i in result:
                    data = {
                        "id_company": str(i["id_company"]),
                        "id_product": str(i["id_product"]),
                        "id_hosting": str(i['id_hosting']),
                        "id_company_product": str(i['id_company_product']),
                        "id_additional_features":
                        str(i["id_additional_features"]),
                        "nm_company": i['nm_company'],
                        "url_company": i['url_company'],
                        "nm_product": i['nm_product'],
                        "nm_company_product": i['nm_company_product'],
                        "spec_storage": i['spec_storage'],
                        'spec_price': i['spec_price'],
                        "spec_storage": i['spec_storage'],
                        'spec_database': i['spec_database'],
                        "spec_free_domain": i['spec_free_domain'],
                        "spec_hosting_domain": i['spec_hosting_domain'],
                        'spec_subdomain': i['spec_subdomain'],
                        "spec_ftp_user": i['spec_ftp_user'],
                        "spec_control_panel": i['spec_control_panel'],
                        'spec_email_account': i['spec_email_account'],
                        "spec_spam_filter": i['spec_spam_filter'],
                        "date_time": i['date_time'],
                        "spec_features": i['spec_features'],
                        "spec_features_value": i['spec_features_value'],
                        "spec_features_price": i['spec_features_price']
                    }
                    obj_userdata.append(data)
                respons = {"status": True, "messages": "Fine!"}
            finally:
                return response(200, data=obj_userdata, message=respons)
Пример #10
0
    def post(self):
        json_req = request.get_json(force=True)
        command = utils.get_command(request.path)
        command = 'dt_' + command
        init_data = cmd.parser(json_req, command)
        respons = {}
        if init_data['action'] == 'insert':
            table = init_data['data'][0]['table']
            fields = init_data['data'][0]['fields']
            try:
                result = model.insert(table, fields)
            except Exception as e:
                respons = {"status": False, "error": str(e)}
            else:
                respons = {"status": True, "messages": "Success", "id": result}
            finally:
                return response(200, data=fields, message=respons)
        if init_data['action'] == 'remove':
            table = ""
            tags = dict()
            fields = ""
            for i in init_data['data']:
                table = i['table']
                tags = i['tags']
            fields = str(list(tags.keys())[0])
            try:
                result = model.delete(table, fields, tags[fields])
            except Exception as e:
                respons = {"status": False, "messages": str(e)}
            else:
                respons = {"status": result, "messages": "Success!"}
            finally:
                return response(200, data=tags, message=respons)
        if init_data['action'] == 'view':
            obj_userdata = list()
            table = ""
            fields = None
            tags = dict()
            for i in init_data['data']:
                table = i['table']
                tags = i['tags']
                for a in tags:
                    if tags[a] is not None:
                        fields = a
            column = model.get_columns("v_product_vm")
            try:
                result = list()
                if fields is None:
                    query = """select * from v_product_vm"""
                    db.execute(query)
                    rows = db.fetchall()
                    for row in rows:
                        result.append(dict(zip(column, row)))
                else:
                    query = """ select * from v_product_vm_test where """ + fields + """='""" + tags[
                        fields] + """'"""
                    db.execute(query)
                    rows = db.fetchall()
                    for row in rows:
                        result.append(dict(zip(column, row)))
            except Exception as e:
                respons = {"status": False, "messages": str(e)}
            else:
                for i in result:
                    data = {
                        "id_company": str(i['id_company']),
                        "id_company_product": str(i['id_company_product']),
                        "id_product": str(i['id_product']),
                        'id_vm': str(i['id_vm']),
                        "id_additional_features":
                        str(i['id_additional_features']),
                        "nm_company": i['nm_company'],
                        "url_company": i['url_company'],
                        'nm_company_product': i['nm_company_product'],
                        "nm_product": i['nm_product'],
                        "currency_used": i['currency_used'],
                        'spec_clock': i['spec_clock'],
                        "spec_ram": i['spec_ram'],
                        "spec_os": i['spec_os'],
                        'spec_storage_volume': i['spec_storage_volume'],
                        "spec_ssd_volume": i['spec_ssd_volume'],
                        "spec_snapshot_volume": i['spec_snapshot_volume'],
                        "spec_template_volume": i['spec_template_volume'],
                        'spec_iso_volume': i['spec_iso_volume'],
                        "spec_public_ip": i['spec_public_ip'],
                        "spec_backup_storage": i['spec_backup_storage'],
                        'spec_features': i['spec_features'],
                        "spec_features_value": i['spec_features_value'],
                        "spec_features_price": i['spec_features_price'],
                        'spec_price': i['spec_price'],
                        "date_time": i['date_time']
                    }
                    obj_userdata.append(data)
                respons = {"status": True, "messages": "Fine!"}
            finally:
                return response(200, data=obj_userdata, message=respons)

        if init_data['action'] == 'where':
            obj_userdata = list()
            table = ""
            fields = ""
            tags = dict()
            for i in init_data['data']:
                table = i['table']
                tags = i['tags']
                for a in tags:
                    if tags[a] is not None:
                        fields = a
            try:
                result = model.get_by_id(table, fields, tags[fields])
            except Exception as e:
                respons = {"status": False, "messages": str(e)}
            else:
                for i in result:
                    data = {
                        "id_vm": str(i['id_vm']),
                        "id_company_product": str(i['id_company_product']),
                        "spec_vcpu": i['spec_vcpu'],
                        'spec_clock': i['spec_clock'],
                        "spec_ram": i['spec_ram'],
                        "spec_os": i['spec_os'],
                        "spec_storage_volume": i['spec_storage_volume'],
                        'spec_ssd_volume': i['spec_ssd_volume'],
                        "spec_snapshot_volume": i['spec_snapshot_volume'],
                        "spec_template_volume": i['spec_template_volume'],
                        'spec_iso_volume': i['spec_iso_volume'],
                        "spec_public_ip": i['spec_public_ip'],
                        "spec_backup_storage": i['spec_backup_storage'],
                        'spec_price': i['spec_price'],
                        "spec_notes": i['spec_notes'],
                        "date_time": i['date_time']
                    }
                    obj_userdata.append(data)
                respons = {"status": True, "messages": "Fine!"}
            finally:
                return response(200, data=obj_userdata, message=respons)
Пример #11
0
    def post(self):
        json_req = request.get_json(force=True)
        command = utils.get_command(request.path)
        command = "zn_" + command
        init_data = cmd.parser(json_req, command)
        respons = dict()
        if init_data['action'] == 'insert':
            table = init_data['data'][0]['table']
            fields = init_data['data'][0]['fields']
            try:
                result = model.insert(table, fields)
            except Exception as e:
                respons = {"status": False, "error": str(e)}
            else:
                respons = {"status": True, "messages": "Fine!", "id": result}
            finally:
                return response(200, data=fields, message=respons)
        if init_data['action'] == 'where':
            obj_userdata = list()
            table = ""
            fields = ""
            tags = dict()
            for i in init_data['data']:
                table = i['table']
                tags = i['tags']
                for a in tags:
                    if tags[a] is not None:
                        fields = a
            try:
                result = model.get_by_id(table, fields, tags[fields])
            except Exception as e:
                respons = {"status": False, "messages": str(e)}
            else:
                for i in result:
                    data = {
                        "id_content": str(i['id_content']),
                        "id_ttldata": str(i['id_ttldata']),
                        "nm_content": str(i['nm_content'])
                    }
                    obj_userdata.append(data)
                respons = {"status": True, "messages": "Fine!"}
            finally:
                return response(200, data=obj_userdata, message=respons)
        if init_data['action'] == 'remove':
            table = ""
            tags = dict()
            fields = ""
            for i in init_data['data']:
                table = i['table']
                tags = i['tags']
                for a in tags:
                    if tags[a] is not None:
                        fields = a
            try:
                result = model.delete(table, fields, tags[fields])
            except Exception as e:
                respons = {"status": False, "messages": str(e)}
            else:
                respons = {"status": result, "messages": "Fine Deleted!"}
            finally:
                return response(200, data=tags, message=respons)

        if init_data['action'] == 'view':
            obj_userdata = list()
            table = ""
            fields = None
            tags = dict()
            for i in init_data['data']:
                table = i['table']
                tags = i['tags']
                for a in tags:
                    if tags[a] is not None:
                        fields = a
            column = model.get_columns("v_contentdata")
            try:
                result = list()
                if fields is None:
                    query = """select * from v_contentdata"""
                    db.execute(query)
                    rows = db.fetchall()
                    for row in rows:
                        result.append(dict(zip(column, row)))
                else:
                    query = """ select * from v_contentdata where """ + fields + """='""" + tags[
                        fields] + """'"""
                    db.execute(query)
                    rows = db.fetchall()
                    for row in rows:
                        result.append(dict(zip(column, row)))
            except Exception as e:
                respons = {"status": False, "messages": str(e)}
            else:
                for i in result:
                    data = {
                        "id_content": str(i['id_content']),
                        "nm_zone": str(i['nm_zone']),
                        "nm_record": str(i['nm_record']),
                        "nm_type": str(i['nm_type']),
                        "nm_ttl": i['nm_ttl'],
                        "id_record": str(i['id_record']),
                        "nm_content": str(i['nm_content']),
                    }
                    obj_userdata.append(data)
                respons = {"status": True, "messages": "Fine!"}
            finally:
                return response(200, data=obj_userdata, message=respons)