canonical-hw-cert team mailing list archive
-
canonical-hw-cert team
-
Mailing list archive
-
Message #05553
[Merge] ~gavin.lin/cc-lab-manager:skip-not-ready into cc-lab-manager:master
Gavin Lin has proposed merging ~gavin.lin/cc-lab-manager:skip-not-ready into cc-lab-manager:master.
Commit message:
Skip devices not ready yet when generating configs
Requested reviews:
Canonical Hardware Certification (canonical-hw-cert)
For more details, see:
https://code.launchpad.net/~gavin.lin/cc-lab-manager/+git/cc-lab-manager/+merge/426979
--
Your team Canonical Hardware Certification is requested to review the proposed merge of ~gavin.lin/cc-lab-manager:skip-not-ready into cc-lab-manager:master.
diff --git a/cc_lab_manager/gen_config/gen_agent_tf_config.py b/cc_lab_manager/gen_config/gen_agent_tf_config.py
index 1e78c84..365f5f7 100644
--- a/cc_lab_manager/gen_config/gen_agent_tf_config.py
+++ b/cc_lab_manager/gen_config/gen_agent_tf_config.py
@@ -80,13 +80,13 @@ def close_db(db):
def read_data_from_db(cursor):
col_in_c3 = ["CID","Lab","IP","MAAS_Node_ID", "Provision",
- "Power", "Device_ID", "TF_Queue",
+ "Power", "Device_ID", "TF_Queue","MAC",
"Customized_agent_config", "Advertised", "PDU_IP",
"PDU_Outlet", "Controller_IP", "CanonicalLabel",
"SecureID",
"Device_ID"]
- sqlcmd = 'select {},{},{},{},{},{},{},{},{},{},{},{},{},{},{} \
+ sqlcmd = 'select {},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{} \
from lab_hw where CID not like \'dummy-%\' \
order by {} ASC'.format(*col_in_c3)
cursor.execute(sqlcmd)
@@ -128,7 +128,8 @@ def device_id_to_platform_name(device_id):
def create_agent_config_dir(db_machine_list, cfg_path):
for machine in db_machine_list:
- if machine['lab'] == '':
+ if (machine['lab'] == '' or machine['MAC'] == '' or
+ machine['Customized_agent_config'] == 'TRUE'):
continue
agent_name = device_id_to_agent_name(machine["Device_ID"])
@@ -169,7 +170,8 @@ def insert_config_device(update_conf, device_data, maptable, identity):
def generate_agent_config(db_machine_list, cfg_path):
for machine in db_machine_list:
- if machine['lab'] == '' or machine['Customized_agent_config'] == 'TRUE':
+ if (machine['lab'] == '' or machine['MAC'] == '' or
+ machine['Customized_agent_config'] == 'TRUE'):
continue
# Copy data from sqlite3.Row object to a dict so we can add more keys later
@@ -251,7 +253,8 @@ def generate_agent_config(db_machine_list, cfg_path):
def generate_tf_config(db_machine_list, cfg_path):
for machine in db_machine_list:
- if machine['lab'] == '' or machine['Customized_agent_config'] == 'TRUE':
+ if (machine['lab'] == '' or machine['MAC'] == '' or
+ machine['Customized_agent_config'] == 'TRUE'):
continue
# Copy data from sqlite3.Row object to a dict so we can add more keys later
device_data = dict(machine)
@@ -317,6 +320,9 @@ def create_agent_yaml(db_machine_list, cfg_path):
# Separate agent configurations by labs
labs = []
for machine in db_machine_list:
+ if (machine['lab'] == '' or machine['MAC'] == '' or
+ machine['Customized_agent_config'] == 'TRUE'):
+ continue
if machine['lab'].lower() not in labs:
labs.append(machine['lab'].lower())
@@ -338,6 +344,9 @@ def create_agent_yaml(db_machine_list, cfg_path):
}
}
for machine in db_machine_list:
+ if (machine['lab'] == '' or machine['MAC'] == '' or
+ machine['Customized_agent_config'] == 'TRUE'):
+ continue
if machine['lab'].lower() == lab:
agent_name = device_id_to_agent_name(machine["Device_ID"])
data["applications"][agent_name] = {