コード例 #1
0
ファイル: alert_rules.py プロジェクト: zhanggong16/hcloud
 def add(cls, alert_rules_id, host_id, port, service, temp_name,
         monitor_items, statistical_period, statistical_approach,
         compute_mode, threshold_value, contact_groups, notify_type,
         status):
     sql = (
         "insert into {table} "
         "(alert_rules_id, host_id, port, service, temp_name, monitor_items, statistical_period, statistical_approach, compute_mode, threshold_value, contact_groups, notify_type, status) values "
         "(:alert_rules_id, :host_id, :port, :service, :monitor_items, :statistical_period, "
         ":statistical_approach, :compute_mode, :threshold_value, :contact_groups, :notify_type, :status)"
     ).format(table=cls._table_ar)
     params = dict(host_id=host_id,
                   port=port,
                   alert_rules_id=alert_rules_id,
                   service=service,
                   temp_name=temp_name,
                   monitor_items=monitor_items,
                   statistical_period=statistical_period,
                   statistical_approach=statistical_approach,
                   compute_mode=compute_mode,
                   threshold_value=threshold_value,
                   contact_groups=contact_groups,
                   notify_type=notify_type,
                   status=status)
     r = db.execute(sql, params=params)
     if r.lastrowid:
         db.commit()
         return r.lastrowid
     db.rollback()
コード例 #2
0
ファイル: alerts.py プロジェクト: zhanggong16/hcloud
 def add(cls, alert_rules_id, host_id, port, service, monitor_items,
         alert_time, current_value, last_time, state, contact_groups,
         status):
     sql = (
         "insert into {table} "
         "(alert_rules_id, host_id, port, service, monitor_items, alert_time, current_value, last_time, state, contact_groups, status) values "
         "(:alert_rules_id, :host_id, :port, :service, :monitor_items, :alert_time, "
         ":current_value, :last_time, :state, :contact_groups, :status)"
     ).format(table=cls._table_ah)
     params = dict(host_id=host_id,
                   port=port,
                   alert_rules_id=alert_rules_id,
                   service=service,
                   monitor_items=monitor_items,
                   alert_time=alert_time,
                   current_value=current_value,
                   last_time=last_time,
                   state=state,
                   contact_groups=contact_groups,
                   status=status)
     r = db.execute(sql, params=params)
     if r.lastrowid:
         db.commit()
         return r.lastrowid
     db.rollback()
コード例 #3
0
ファイル: host.py プロジェクト: zhanggong16/hcloud
 def add_hostpool(cls, host_id, name, description, device_key, privateip,
                  os_type, state, attribute, region, remark, dns,
                  project_id):
     sql = (
         "insert into {table} "
         "(host_id, name, description, device_key, privateip, os_type, state, attribute, region, dns, project_id, remark) values "
         "(:host_id, :name, :description, :device_key, :privateip, "
         ":os_type, :state, :attribute, :region, :dns, :project_id, :remark)"
     ).format(table=cls._table_hp)
     params = dict(host_id=host_id,
                   name=name,
                   description=description,
                   device_key=device_key,
                   privateip=privateip,
                   os_type=os_type,
                   state=state,
                   attribute=attribute,
                   region=region,
                   dns=dns,
                   project_id=project_id,
                   remark=remark)
     r = db.execute(sql, params=params)
     if r.lastrowid:
         db.commit()
         return r.lastrowid
     db.rollback()
コード例 #4
0
ファイル: alert_rules.py プロジェクト: pg-chaos/hcloud
    def update(cls, alert_rules_id, statistical_period, compute_mode,
               threshold_value, contact_groups, notify_type):
        sql = (
            "update {table} set statistical_period=:statistical_period, compute_mode=:compute_mode, threshold_value=:threshold_value, contact_groups=:contact_groups, notify_type=:notify_type where alert_rules_id = :alert_rules_id and deleted = 0"
        ).format(table=cls._table_ar)

        params = dict(statistical_period=statistical_period,
                      compute_mode=compute_mode,
                      threshold_value=threshold_value,
                      contact_groups=contact_groups,
                      notify_type=notify_type,
                      alert_rules_id=alert_rules_id)
        r = db.execute(sql, params=params)
        if r.lastrowid:
            db.commit()
        return r.lastrowid
        db.rollback()
コード例 #5
0
ファイル: alert_rules.py プロジェクト: langzhi827/hcloud
 def update(cls, alert_rules_id, statistical_period, statistical_approach,
            compute_mode, threshold_value, status):
     sql = (
         "update {table} set "
         "statistical_period=:statistical_period, statistical_approach=:statistical_approach, compute_mode=:compute_mode, threshold_value=:threshold_value, status=:status"
         "where alert_rules_id = :alert_rules_id").format(
             table=cls._table_ar)
     params = dict(statistical_period=statistical_period,
                   statistical_approach=statistical_approach,
                   compute_mode=compute_mode,
                   threshold_value=threshold_value,
                   alert_rules_id=alert_rules_id,
                   status=status)
     r = db.execute(sql, params=params)
     if r.lastrowid:
         db.commit()
     return r.lastrowid
     db.rollback()