"Deleted (3)"
};
+static char *subnet_states[] = {
+ "Reserved (0)",
+ "Billable (1)",
+ "Private (2)",
+ "Resnet (3)",
+ "Infrastructure (4)"
+};
+
static char *MacState(int state)
{
static char buf[BUFSIZ];
return states[state];
}
+static char *SubnetState(int state)
+{
+ static char buf[BUFSIZ];
+ if (state < 0 || state > 4)
+ {
+ sprintf(buf, "Unknown (%d)", state);
+ return buf;
+ }
+ return subnet_states[state];
+}
/* -------------------- Set Defaults -------------------- */
info[M_LOC] = strdup(M_DEFAULT_TYPE);
info[M_CONTACT] = strdup(M_DEFAULT_TYPE);
info[M_BILL_CONTACT] = strdup(M_DEFAULT_TYPE);
+ info[M_ACCT_NUMBER] = strdup("");
info[M_USE] = strdup("0");
info[M_STAT] = strdup("1");
info[M_SUBNET] = strdup("NONE");
info[M_OWNER_NAME] = strdup("NONE");
info[M_ACOMMENT] = strdup("");
info[M_OCOMMENT] = strdup("");
- info[16] = info[17] = NULL;
+ info[17] = info[18] = NULL;
return info;
}
{
char buf[256];
- info[C_NAME] = strdup(name);
+ info[SN_NAME] = strdup(name);
info[SN_DESC] = strdup("");
+ info[SN_STATUS] = strdup("1");
+ info[SN_CONTACT] = strdup(DEFAULT_NONE);
+ info[SN_ACCT_NUMBER] = strdup("");
sprintf(buf, "%ld", ntohl(inet_addr("18.255.0.0")));
info[SN_ADDRESS] = strdup(buf);
sprintf(buf, "%ld", ntohl(inet_addr("255.255.0.0")));
MacState(atoi(info[M_STAT])), info[M_STAT_CHNG]);
Put_message(buf);
Put_message("");
-
sprintf(buf, "Vendor: %-16s Location: %s", info[M_VENDOR],
info[M_LOC]);
Put_message(buf);
sprintf(buf, "OS: %-16s Billing Contact: %s", info[M_OS],
info[M_BILL_CONTACT]);
Put_message(buf);
- Put_message("");
- sprintf(buf, "Opt: %s", info[M_USE]);
+ sprintf(buf, "Opt: %-16s Account Number: %s", info[M_USE],
+ info[M_ACCT_NUMBER]);
Put_message(buf);
Put_message("");
sprintf(buf, "Adm cmt: %s", info[M_ACOMMENT]);
Put_message(buf);
sprintf(buf, MOD_FORMAT, info[M_MODBY], info[M_MODTIME], info[M_MODWITH]);
Put_message(buf);
+ /* Do a get_subnet for the machine's subnet. We need to know if it's
+ * Private.
+ */
+ args[0] = info[M_SUBNET];
+ stat = do_mr_query("get_subnet", 1, args, StoreInfo, &elem);
+ if (stat)
+ com_err(program_name, stat, " looking up subnet info");
+ if (atoi(((char **)elem->q_data)[2]) == SNET_STATUS_PRIVATE)
+ {
+ Put_message("");
+ sprintf(buf, "Warning: This host is on a private subnet.");
+ Put_message(buf);
+ sprintf(buf, "Billing information shown is superceded by billing information for the subnet.");
+ Put_message(buf);
+ }
+
return info[M_NAME];
}
Put_message(buf);
sprintf(buf, " Description: %s", info[SN_DESC]);
Put_message(buf);
+ sprintf(buf, " Status: %s", SubnetState(atoi(info[SN_STATUS])));
+ Put_message(buf);
+ sprintf(buf, " Contact: %s", info[SN_CONTACT]);
+ Put_message(buf);
+ sprintf(buf, " Account Number: %s", info[SN_ACCT_NUMBER]);
+ Put_message(buf);
addr.s_addr = htonl(atoi(info[SN_ADDRESS]));
mask.s_addr = htonl(atoi(info[SN_MASK]));
low.s_addr = htonl(atoi(info[SN_LOW]));
if (GetValueFromUser("Machine's billing contact",
&info[M_BILL_CONTACT]) == SUB_ERROR)
return NULL;
+ if (GetValueFromUser("Machine's billing account number",
+ &info[M_ACCT_NUMBER]) == SUB_ERROR)
+ return NULL;
while (1)
{
int i;
if (name)
{
/* info did not come from SetMachineDefaults(), which does not
- * initialize entry 8 (M_STAT_CHNG), therefore we can
+ * initialize entry 10 (M_STAT_CHNG), therefore we can
* free it.
*/
/* This is an update of an existing machine and the structure
* was filled in thru a query to the db which does fill in this
* field.
*/
- free(info[9]);
+ free(info[10]);
}
- info[9] = info[M_SUBNET];
- info[10] = info[M_ADDR];
- info[11] = info[M_OWNER_TYPE];
- info[12] = info[M_OWNER_NAME];
- info[13] = info[M_ACOMMENT];
- info[14] = info[M_OCOMMENT];
+ info[10] = info[M_SUBNET];
+ info[11] = info[M_ADDR];
+ info[12] = info[M_OWNER_TYPE];
+ info[13] = info[M_OWNER_NAME];
+ info[14] = info[M_ACOMMENT];
+ info[15] = info[M_OCOMMENT];
if (name)
{
- if (GetValueFromUser("Machine's network (or 'none')", &info[9])
+ if (GetValueFromUser("Machine's network (or 'none')", &info[10])
== SUB_ERROR)
return NULL;
}
if (GetValueFromUser("Machine's address (or 'unassigned' or 'unique')",
- &info[10]) == SUB_ERROR)
+ &info[11]) == SUB_ERROR)
return NULL;
- if (GetTypeFromUser("Machine's owner type", "ace_type", &info[11]) ==
+ if (GetTypeFromUser("Machine's owner type", "ace_type", &info[12]) ==
SUB_ERROR)
return NULL;
- if (strcmp(info[11], "NONE") &&
- GetValueFromUser("Owner's Name", &info[12]) == SUB_ERROR)
+ if (strcmp(info[12], "NONE") &&
+ GetValueFromUser("Owner's Name", &info[13]) == SUB_ERROR)
return NULL;
- if (!strcmp(info[11], "KERBEROS"))
+ if (!strcmp(info[12], "KERBEROS"))
{
char *canon;
- mrcl_validate_kerberos_member(info[12], &canon);
+ mrcl_validate_kerberos_member(info[13], &canon);
if (mrcl_get_message())
Put_message(mrcl_get_message());
- free(info[12]);
- info[12] = canon;
+ free(info[13]);
+ info[13] = canon;
}
- if (GetValueFromUser("Administrative comment", &info[13]) == SUB_ERROR)
+ if (GetValueFromUser("Administrative comment", &info[14]) == SUB_ERROR)
return NULL;
- if (GetValueFromUser("Operational comment", &info[14]) == SUB_ERROR)
+ if (GetValueFromUser("Operational comment", &info[15]) == SUB_ERROR)
return NULL;
- info[15] = NULL;
- FreeAndClear(&info[16], TRUE);
+ info[16] = NULL;
FreeAndClear(&info[17], TRUE);
+ FreeAndClear(&info[18], TRUE);
break;
case SUBNET:
if (GetValueFromUser("Network description", &info[SN_DESC]) == SUB_ERROR)
return NULL;
+ while (1)
+ {
+ int i;
+ if (GetValueFromUser("Network's status (? for help)",
+ &info[SN_STATUS]) == SUB_ERROR)
+ return NULL;
+ if (isdigit(info[SN_STATUS][0]))
+ break;
+ Put_message("Valid status numbers:");
+ for (i = 0; i < 5; i++)
+ Put_message(subnet_states[i]);
+ }
+ if (GetValueFromUser("Network's contact", &info[SN_CONTACT]) == SUB_ERROR)
+ return NULL;
+ if (GetValueFromUser("Network's billing account number",
+ &info[SN_ACCT_NUMBER]) == SUB_ERROR)
+ return NULL;
if (GetAddressFromUser("Network address", &info[SN_ADDRESS]) == SUB_ERROR)
return NULL;
if (GetAddressFromUser("Network mask", &info[SN_MASK]) == SUB_ERROR)
return QueueTop(elem);
}
+int MachineByAcctNumber(int argc, char **argv)
+{
+ char *args[0], *account_number;
+ int status;
+ struct mqelem *elem = NULL;
+
+ if (GetValueFromUser("Account Number", &account_number) == SUB_ERROR)
+ return DM_NORMAL;
+
+ args[0] = account_number;
+ if (status = do_mr_query("get_host_by_account_number", 1, args, StoreInfo,
+ &elem))
+ {
+ com_err(program_name, status, " in get_host_by_account_number");
+ return DM_NORMAL;
+ }
+ Loop(QueueTop(elem), (void (*)(char **)) PrintMachInfo);
+ FreeQueue(elem);
+
+ return DM_NORMAL;
+}
+
int ShowContainerInfo(int argc, char **argv)
{
struct mqelem *top;
char *hostname, *whoami;
char *newname, *address, *network, *h_status, *vendor, *model;
-char *os, *location, *contact, *billing_contact, *adm_cmt, *op_cmt;
+char *os, *location, *contact, *billing_contact, *account_number;
+char *adm_cmt, *op_cmt;
in_addr_t ipaddress;
struct owner_type *owner;
update_alias_flag = verbose = noauth = 0;
list_container_flag = update_container_flag = 0;
newname = address = network = h_status = vendor = model = NULL;
- os = location = contact = billing_contact = adm_cmt = op_cmt = NULL;
+ os = location = contact = billing_contact = account_number = adm_cmt = NULL;
+ op_cmt = NULL;
owner = NULL;
alias_add_queue = alias_remove_queue = NULL;
map_add_queue = map_remove_queue = NULL;
} else
usage(argv);
}
+ else if (argis("an", "accountnumber")) {
+ if (arg - argv < argc - 1) {
+ arg++;
+ update_flag++;
+ account_number = *arg;
+ } else
+ usage(argv);
+ }
else if (argis("ac", "admcmt")) {
if (arg - argv < argc - 1) {
arg++;
}
/* fire up Moira */
- status = mrcl_connect(server, "stella", 7, !noauth);
+ status = mrcl_connect(server, "stella", 8, !noauth);
if (status == MRCL_AUTH_ERROR)
{
com_err(whoami, 0, "Try the -noauth flag if you don't "
char *argv[30];
int cnt;
- for (cnt = 0; cnt < 16; cnt++) {
+ for (cnt = 0; cnt < 17; cnt++) {
argv[cnt] = "";
}
argv[5] = contact;
if (billing_contact)
argv[6] = billing_contact;
+ if (account_number)
+ argv[7] = account_number;
/* The use field always gets set to "0" */
- argv[7] = "0";
+ argv[8] = "0";
if (h_status)
- argv[8] = h_status;
+ argv[9] = h_status;
else
- argv[8] = "1";
+ argv[9] = "1";
if (network)
- argv[9] = network;
+ argv[10] = network;
if (address)
- argv[10] = address;
+ argv[11] = address;
else
- argv[10] = "unique";
+ argv[11] = "unique";
if (adm_cmt)
- argv[13] = adm_cmt;
+ argv[14] = adm_cmt;
if (op_cmt)
- argv[14] = op_cmt;
+ argv[15] = op_cmt;
if (owner)
{
- argv[12] = owner->name;
+ argv[13] = owner->name;
switch (owner->type)
{
case M_ANY:
case M_USER:
- argv[11] = "USER";
- status = wrap_mr_query("add_host", 15, argv, NULL, NULL);
+ argv[12] = "USER";
+ status = wrap_mr_query("add_host", 16, argv, NULL, NULL);
if (owner->type != M_ANY || status != MR_USER)
break;
case M_LIST:
- argv[11] = "LIST";
- status = wrap_mr_query("add_host", 15, argv, NULL, NULL);
+ argv[12] = "LIST";
+ status = wrap_mr_query("add_host", 16, argv, NULL, NULL);
break;
case M_KERBEROS:
- argv[11] = "KERBEROS";
- status = mrcl_validate_kerberos_member(argv[12], &argv[12]);
+ argv[12] = "KERBEROS";
+ status = mrcl_validate_kerberos_member(argv[13], &argv[13]);
if (mrcl_get_message())
mrcl_com_err(whoami);
- status = wrap_mr_query("add_host", 15, argv, NULL, NULL);
+ status = wrap_mr_query("add_host", 16, argv, NULL, NULL);
break;
case M_NONE:
- argv[11] = "NONE";
- status = wrap_mr_query("add_host", 15, argv, NULL, NULL);
+ argv[12] = "NONE";
+ status = wrap_mr_query("add_host", 16, argv, NULL, NULL);
break;
}
}
else
{
- argv[11] = "NONE";
argv[12] = "NONE";
+ argv[13] = "NONE";
- status = wrap_mr_query("add_host", 15, argv, NULL, NULL);
+ status = wrap_mr_query("add_host", 16, argv, NULL, NULL);
}
if (status)
else if (update_flag)
{
char *old_argv[30];
- char *argv[16];
+ char *argv[17];
char *args[5];
args[0] = canonicalize_hostname(strdup(hostname));
argv[7] = old_argv[6];
argv[8] = old_argv[7];
argv[9] = old_argv[8];
- argv[10] = old_argv[10];
+ argv[10] = old_argv[9];
argv[11] = old_argv[11];
argv[12] = old_argv[12];
argv[13] = old_argv[13];
argv[14] = old_argv[14];
argv[15] = old_argv[15];
+ argv[16] = old_argv[16];
argv[0] = canonicalize_hostname(strdup(hostname));
if (newname)
argv[6] = contact;
if (billing_contact)
argv[7] = billing_contact;
+ if (account_number)
+ argv[8] = account_number;
if (h_status)
- argv[9] = h_status;
+ argv[10] = h_status;
if (network)
- argv[10] = network;
+ argv[11] = network;
if (address)
- argv[11] = address;
+ argv[12] = address;
if (adm_cmt)
- argv[14] = adm_cmt;
+ argv[15] = adm_cmt;
if (op_cmt)
- argv[15] = op_cmt;
+ argv[16] = op_cmt;
if (owner)
{
- argv[13] = owner->name;
+ argv[14] = owner->name;
switch (owner->type)
{
case M_ANY:
case M_USER:
- argv[12] = "USER";
- status = wrap_mr_query("update_host", 16, argv, NULL, NULL);
+ argv[13] = "USER";
+ status = wrap_mr_query("update_host", 17, argv, NULL, NULL);
if (owner->type != M_ANY || status != MR_USER)
break;
case M_LIST:
- argv[12] = "LIST";
- status = wrap_mr_query("update_host", 16, argv, NULL, NULL);
+ argv[13] = "LIST";
+ status = wrap_mr_query("update_host", 17, argv, NULL, NULL);
break;
case M_KERBEROS:
- argv[12] = "KERBEROS";
- status = mrcl_validate_kerberos_member(argv[13], &argv[13]);
+ argv[13] = "KERBEROS";
+ status = mrcl_validate_kerberos_member(argv[14], &argv[14]);
if (mrcl_get_message())
mrcl_com_err(whoami);
- status = wrap_mr_query("update_host", 16, argv, NULL, NULL);
+ status = wrap_mr_query("update_host", 17, argv, NULL, NULL);
break;
case M_NONE:
- argv[12] = "NONE";
- status = wrap_mr_query("update_host", 16, argv, NULL, NULL);
+ argv[13] = "NONE";
+ status = wrap_mr_query("update_host", 17, argv, NULL, NULL);
break;
}
}
else
- status = wrap_mr_query("update_host", 16, argv, NULL, NULL);
+ status = wrap_mr_query("update_host", 17, argv, NULL, NULL);
if (status)
com_err(whoami, status, "while updating host.");
show_host_info_unformatted(argv);
else
show_host_info(argv);
+ args[0] = argv[M_SUBNET];
+ status = wrap_mr_query("get_subnet", 1, args, store_host_info, argv);
+ if (status)
+ com_err(whoami, status, "while getting subnet information");
+ if (atoi(argv[SN_STATUS]) == SNET_STATUS_PRIVATE)
+ {
+ fprintf(stderr, "\nWarning: This host is on a private subnet.\n");
+ fprintf(stderr, "Billing information shown is superceded by billing information for the subnet.\n");
+ }
}
/* list cluster mappings if needed */
"-c | -contact contact");
fprintf(stderr, USAGE_OPTIONS_FORMAT, "-ac | -admcmt adm_cmt",
"-bc | -billingcontact billing_contact");
- fprintf(stderr, USAGE_OPTIONS_FORMAT, "-A | -address address",
- "-N | -network network");
- fprintf(stderr, USAGE_OPTIONS_FORMAT, "-am | -addmap cluster",
- "-dm | deletemap cluster");
- fprintf(stderr, USAGE_OPTIONS_FORMAT, "-acn | -addcontainer container",
- "-dcn | -deletecontainer container");
- fprintf(stderr, USAGE_OPTIONS_FORMAT, "-lm | -listmap",
- "-lcn | -listcontainer");
- fprintf(stderr, USAGE_OPTIONS_FORMAT, "-u | -unformatted",
- "-v | -verbose");
- fprintf(stderr, USAGE_OPTIONS_FORMAT, "-n | -noauth",
- "-db | -database host[:port]");
+ fprintf(stderr, USAGE_OPTIONS_FORMAT, "-an | -accountnumber account_number", "-A | -address address");
+ fprintf(stderr, USAGE_OPTIONS_FORMAT, "-N | -network network",
+ "-am | -addmap cluster");
+ fprintf(stderr, USAGE_OPTIONS_FORMAT, "-dm | deletemap cluster",
+ "-acn | -addcontainer container");
+ fprintf(stderr, USAGE_OPTIONS_FORMAT, "-dcn | -deletecontainer container",
+ "-lm | -listmap");
+ fprintf(stderr, USAGE_OPTIONS_FORMAT, "-lcn | -listcontainer",
+ "-u | -unformatted");
+ fprintf(stderr, USAGE_OPTIONS_FORMAT, "-v | -verbose",
+ "-n | -noauth");
+ fprintf(stderr, " %-39s\n" , "-db | -database host[:port]");
exit(1);
}
argv[M_CONTACT]);
printf("OS: %-16s Billing Contact: %s\n", argv[M_OS],
argv[M_BILL_CONTACT]);
- printf("\nOpt: %s\n", argv[M_USE]);
+ printf("Opt: %-16s Account Number: %s\n", argv[M_USE],
+ argv[M_ACCT_NUMBER]);
printf("\nAdm cmt: %s\n", argv[M_ACOMMENT]);
printf("Op cmt: %s\n", argv[M_OCOMMENT]);
printf("\n");
"inuse", "modtime", "modby", "modwith",
};
-static char *ghst_fields[] = {
+static char *ghst6_fields[] = {
"name", "address", "location", "network",
"name", "vendor", "model", "os", "location", "contact", "billing_contact",
"use", "status", "status_change", "network", "address", "ace_type",
"inuse", "modtime", "modby", "modwith",
};
-static char *ghbh_fields[] = {
+static char *ghbh6_fields[] = {
"hwaddr",
"name", "vendor", "model", "os", "location", "contact", "billing_contact",
"use", "status", "status_change", "network", "address", "ace_type",
"inuse", "modtime", "modby", "modwith",
};
+static char *ghst_fields[] = {
+ "name", "address", "location", "network",
+ "name", "vendor", "model", "os", "location", "contact", "billing_contact",
+ "account_number", "use", "status", "status_change", "network", "address",
+ "ace_type", "ace_name", "admin_comment", "ops_comment", "created", "creator",
+ "inuse", "modtime", "modby", "modwith",
+};
+
+static char *ghbh_fields[] = {
+ "hwaddr",
+ "name", "vendor", "model", "os", "location", "contact", "billing_contact",
+ "account_number", "use", "status", "status_change", "network", "address",
+ "ace_type", "ace_name", "admin_comment", "ops_comment", "created", "creator",
+ "inuse", "modtime", "modby", "modwith",
+};
+
+static char *ghba_fields[] = {
+ "account_number",
+ "name", "vendor", "model", "os", "location", "contact", "billing_contact",
+ "account_number", "use", "status", "status_change", "network", "address",
+ "ace_type", "ace_name", "admin_comment", "ops_comment", "created", "creator",
+ "inuse", "modtime", "modby", "modwith",
+};
+
static struct validate ghst_validate = {
0,
0,
set_uppercase_modtime,
};
-static char *ahst_fields[] = {
+static char *ahst6_fields[] = {
"name", "vendor", "model", "os", "location", "contact", "billing_contact",
"use", "status", "subnet", "address", "ace_type", "ace_name",
"admin_comment", "ops_comment",
};
-static struct valobj ahst_valobj[] = {
+static struct valobj ahst6_valobj[] = {
{V_CHAR, 0, MACHINE_TABLE, "name"},
{V_CHAR, 1, MACHINE_TABLE, "vendor"},
{V_CHAR, 2, MACHINE_TABLE, "model"},
{V_ID, 14, STRINGS_TABLE, "string", "string_id", MR_NO_MATCH},
};
+static struct validate ahst6_validate = {
+ ahst6_valobj,
+ 14,
+ "name",
+ "name = UPPER('%s')",
+ 1,
+ "mach_id",
+ access_host,
+ setup_ahst,
+ set_uppercase_modtime,
+};
+
+static char *ahst_fields[] = {
+ "name", "vendor", "model", "os", "location", "contact", "billing_contact",
+ "account_number", "use", "status", "subnet", "address", "ace_type",
+ "ace_name", "admin_comment", "ops_comment",
+};
+
+static struct valobj ahst_valobj[] = {
+ {V_CHAR, 0, MACHINE_TABLE, "name"},
+ {V_CHAR, 1, MACHINE_TABLE, "vendor"},
+ {V_CHAR, 2, MACHINE_TABLE, "model"},
+ {V_CHAR, 3, MACHINE_TABLE, "os"},
+ {V_CHAR, 4, MACHINE_TABLE, "location"},
+ {V_CHAR, 5, MACHINE_TABLE, "contact"},
+ {V_CHAR, 6, MACHINE_TABLE, "billing_contact"},
+ {V_CHAR, 7, MACHINE_TABLE, "account_number"},
+ {V_NUM, 8},
+ {V_NUM, 9},
+ {V_ID, 10, SUBNET_TABLE, "name", "snet_id", MR_SUBNET},
+ {V_TYPE, 12, 0, "ace_type", 0, MR_ACE},
+ {V_TYPEDATA, 13, 0, 0, 0, MR_ACE},
+ {V_ID, 14, STRINGS_TABLE, "string", "string_id", MR_NO_MATCH},
+ {V_ID, 15, STRINGS_TABLE, "string", "string_id", MR_NO_MATCH},
+};
+
static struct validate ahst_validate = {
ahst_valobj,
- 14,
+ 15,
"name",
"name = UPPER('%s')",
1,
set_modtime_by_id,
};
-static char *uhst_fields[] = {
+static char *uhst6_fields[] = {
"name",
"newname", "vendor", "model", "os", "location", "contact", "billing_contact",
"use", "status", "subnet", "address", "ace_type", "ace_name",
"admin_comment", "ops_comment",
};
-static struct valobj uhst_valobj[] = {
+static struct valobj uhst6_valobj[] = {
{V_CHAR, 0, MACHINE_TABLE, "name"},
{V_ID, 0, MACHINE_TABLE, "name", "mach_id", MR_MACHINE},
{V_RENAME, 1, MACHINE_TABLE, "name", "mach_id", MR_NOT_UNIQUE},
{V_ID, 15, STRINGS_TABLE, "string", "string_id", MR_NO_MATCH},
};
+static struct validate uhst6_validate = {
+ uhst6_valobj,
+ 16,
+ 0,
+ 0,
+ 0,
+ "mach_id",
+ access_host,
+ setup_ahst,
+ set_modtime_by_id,
+};
+
+static char *uhst_fields[] = {
+ "name",
+ "newname", "vendor", "model", "os", "location", "contact", "billing_contact",
+ "account_number", "use", "status", "subnet", "address", "ace_type",
+ "ace_name", "admin_comment", "ops_comment",
+};
+
+static struct valobj uhst_valobj[] = {
+ {V_CHAR, 0, MACHINE_TABLE, "name"},
+ {V_ID, 0, MACHINE_TABLE, "name", "mach_id", MR_MACHINE},
+ {V_RENAME, 1, MACHINE_TABLE, "name", "mach_id", MR_NOT_UNIQUE},
+ {V_CHAR, 2, MACHINE_TABLE, "vendor"},
+ {V_CHAR, 3, MACHINE_TABLE, "model"},
+ {V_CHAR, 4, MACHINE_TABLE, "os"},
+ {V_CHAR, 5, MACHINE_TABLE, "location"},
+ {V_CHAR, 6, MACHINE_TABLE, "contact"},
+ {V_CHAR, 7, MACHINE_TABLE, "billing_contact"},
+ {V_CHAR, 8, MACHINE_TABLE, "account_number"},
+ {V_NUM, 9},
+ {V_NUM, 10},
+ {V_ID, 11, SUBNET_TABLE, "name", "snet_id", MR_SUBNET},
+ {V_TYPE, 13, 0, "ace_type", 0, MR_ACE},
+ {V_TYPEDATA, 14, 0, 0, 0, MR_ACE},
+ {V_ID, 15, STRINGS_TABLE, "string", "string_id", MR_NO_MATCH},
+ {V_ID, 16, STRINGS_TABLE, "string", "string_id", MR_NO_MATCH},
+};
+
static struct validate uhst_validate = {
uhst_valobj,
- 16,
+ 17,
0,
0,
0,
0,
};
-static char *gsnt_fields[] = {
+static char *gsnt2_fields[] = {
"name",
"name", "description", "address", "mask", "low", "high", "prefix",
"ace_type", "ace_name", "modtime", "modby", "modwith"
};
+static char *gsnt_fields[] = {
+ "name",
+ "name", "description", "status", "contact", "account_number", "address",
+ "mask", "low", "high", "prefix", "ace_type", "ace_name", "modtime",
+ "modby", "modwith"
+};
+
static struct validate gsnt_validate = {
0,
0,
followup_gsnt,
};
-static char *asnt_fields[] = {
+static char *asnt2_fields[] = {
"name", "description", "address", "mask", "low", "high", "prefix",
"ace_type", "ace_name",
};
-static struct valobj asnt_valobj[] = {
+static struct valobj asnt2_valobj[] = {
{V_CHAR, 0, SUBNET_TABLE, "name"},
{V_LEN, 1, SUBNET_TABLE, "description"},
{V_NUM, 2},
{V_TYPEDATA, 8, 0, 0, 0, MR_ACE},
};
-static struct validate asnt_validate =
+static struct validate asnt2_validate =
{
- asnt_valobj,
+ asnt2_valobj,
9,
"name",
"name = UPPER('%s')",
set_uppercase_modtime,
};
-static char *usnt_fields[] = {
+static char *asnt_fields[] = {
+ "name", "description", "status", "contact", "account_number", "address",
+ "mask", "low", "high", "prefix", "ace_type", "ace_name",
+};
+
+static struct valobj asnt_valobj[] = {
+ {V_CHAR, 0, SUBNET_TABLE, "name"},
+ {V_LEN, 1, SUBNET_TABLE, "description"},
+ {V_NUM, 2},
+ {V_CHAR, 3, SUBNET_TABLE, "contact"},
+ {V_CHAR, 4, SUBNET_TABLE, "account_number"},
+ {V_NUM, 5},
+ {V_NUM, 6},
+ {V_NUM, 7},
+ {V_NUM, 8},
+ {V_LEN, 9, SUBNET_TABLE, "prefix"},
+ {V_TYPE, 10, 0, "ace_type", 0, MR_ACE},
+ {V_TYPEDATA, 11, 0, 0, 0, MR_ACE},
+};
+
+static struct validate asnt_validate =
+{
+ asnt_valobj,
+ 12,
+ "name",
+ "name = UPPER('%s')",
+ 1,
+ "snet_id",
+ 0,
+ setup_asnt,
+ set_uppercase_modtime,
+};
+
+static char *usnt2_fields[] = {
"name",
"newname", "description", "address", "mask", "low", "high", "prefix",
"ace_type", "ace_name",
};
-static struct valobj usnt_valobj[] = {
+static struct valobj usnt2_valobj[] = {
{V_ID, 0, SUBNET_TABLE, "name", "snet_id", MR_NO_MATCH},
{V_RENAME, 1, SUBNET_TABLE, "name", "snet_id", MR_NOT_UNIQUE},
{V_LEN, 2, SUBNET_TABLE, "description"},
{V_TYPEDATA, 9, 0, 0, 0, MR_ACE},
};
-static struct validate usnt_validate =
+static struct validate usnt2_validate =
{
- usnt_valobj,
+ usnt2_valobj,
10,
"name",
"snet_id = %d",
set_modtime_by_id,
};
+static char *usnt_fields[] = {
+ "name",
+ "newname", "description", "status", "contact", "account_number", "address",
+ "mask", "low", "high", "prefix", "ace_type", "ace_name",
+};
+
+static struct valobj usnt_valobj[] = {
+ {V_ID, 0, SUBNET_TABLE, "name", "snet_id", MR_NO_MATCH},
+ {V_RENAME, 1, SUBNET_TABLE, "name", "snet_id", MR_NOT_UNIQUE},
+ {V_LEN, 2, SUBNET_TABLE, "description"},
+ {V_NUM, 3},
+ {V_CHAR, 4, SUBNET_TABLE, "contact"},
+ {V_CHAR, 5, SUBNET_TABLE, "account_number"},
+ {V_NUM, 6},
+ {V_NUM, 7},
+ {V_NUM, 8},
+ {V_NUM, 9},
+ {V_LEN, 10, SUBNET_TABLE, "prefix"},
+ {V_TYPE, 11, 0, "ace_type", 0, MR_ACE},
+ {V_TYPEDATA, 12, 0, 0, 0, MR_ACE},
+};
+
+static struct validate usnt_validate =
+{
+ usnt_valobj,
+ 13,
+ "name",
+ "snet_id = %d",
+ 1,
+ "snet_id",
+ 0,
+ setup_asnt,
+ set_modtime_by_id,
+};
+
static char *dsnt_fields[] = {
"name",
};
"m",
MACHINE_TABLE,
"m.name, m.vendor, m.model, m.os, m.location, m.contact, m.billing_contact, m.use, m.status, TO_CHAR(m.statuschange, 'DD-mon-YYYY HH24:MI:SS'), s.name, m.address, m.owner_type, m.owner_id, m.acomment, m.ocomment, TO_CHAR(m.created, 'DD-mon-YYYY HH24:MI:SS'), m.creator, TO_CHAR(m.inuse, 'DD-mon-YYYY HH24:MI:SS'), TO_CHAR(m.modtime, 'DD-mon-YYYY HH24:MI:SS'), m.modby, m.modwith FROM machine m, subnet s",
- ghst_fields,
+ ghst6_fields,
22,
"m.name LIKE UPPER('%s') AND m.address LIKE '%s' AND m.location LIKE UPPER('%s') AND s.name LIKE UPPER('%s') AND m.mach_id != 0 AND s.snet_id = m.snet_id",
4,
&ghst_validate,
},
+ {
+ /* Q_GHST - GET_HOST, v8 */
+ "get_host",
+ "ghst",
+ 8,
+ RETRIEVE,
+ "m",
+ MACHINE_TABLE,
+ "m.name, m.vendor, m.model, m.os, m.location, m.contact, m.billing_contact, m.account_number, m.use, m.status, TO_CHAR(m.statuschange, 'DD-mon-YYYY HH24:MI:SS'), s.name, m.address, m.owner_type, m.owner_id, m.acomment, m.ocomment, TO_CHAR(m.created, 'DD-mon-YYYY HH24:MI:SS'), m.creator, TO_CHAR(m.inuse, 'DD-mon-YYYY HH24:MI:SS'), TO_CHAR(m.modtime, 'DD-mon-YYYY HH24:MI:SS'), m.modby, m.modwith FROM machine m, subnet s",
+ ghst_fields,
+ 23,
+ "m.name LIKE UPPER('%s') AND m.address LIKE '%s' AND m.location LIKE UPPER('%s') AND s.name LIKE UPPER('%s') AND m.mach_id != 0 AND s.snet_id = m.snet_id",
+ 4,
+ "m.name",
+ &ghst_validate,
+ },
+
{
/* Q_GHBH - GET_HOST_BY_HWADDR, v2 */
"get_host_by_hwaddr",
"m",
MACHINE_TABLE,
"m.name, m.vendor, m.model, m.os, m.location, m.contact, m.billing_contact, m.use, m.status, TO_CHAR(m.statuschange, 'DD-mon-YYYY HH24:MI:SS'), s.name, m.address, m.owner_type, m.owner_id, m.acomment, m.ocomment, TO_CHAR(m.created, 'DD-mon-YYYY HH24:MI:SS'), m.creator, TO_CHAR(m.inuse, 'DD-mon-YYYY HH24:MI:SS'), TO_CHAR(m.modtime, 'DD-mon-YYYY HH24:MI:SS'), m.modby, m.modwith FROM machine m, subnet s",
- ghbh_fields,
+ ghbh6_fields,
22,
"m.hwaddr LIKE LOWER('%s') AND m.mach_id != 0 AND s.snet_id = m.snet_id",
1,
&ghst_validate,
},
+ {
+ /* Q_GHBH - GET_HOST_BY_HWADDR, v8 */
+ "get_host_by_hwaddr",
+ "ghbh",
+ 8,
+ RETRIEVE,
+ "m",
+ MACHINE_TABLE,
+ "m.name, m.vendor, m.model, m.os, m.location, m.contact, m.billing_contact, m.account_number, m.use, m.status, TO_CHAR(m.statuschange, 'DD-mon-YYYY HH24:MI:SS'), s.name, m.address, m.owner_type, m.owner_id, m.acomment, m.ocomment, TO_CHAR(m.created, 'DD-mon-YYYY HH24:MI:SS'), m.creator, TO_CHAR(m.inuse, 'DD-mon-YYYY HH24:MI:SS'), TO_CHAR(m.modtime, 'DD-mon-YYYY HH24:MI:SS'), m.modby, m.modwith FROM machine m, subnet s",
+ ghbh_fields,
+ 23,
+ "m.hwaddr LIKE LOWER('%s') AND m.mach_id != 0 AND s.snet_id = m.snet_id",
+ 1,
+ "m.name",
+ &ghst_validate,
+ },
+
+ {
+ /* Q_GHBA - GET_HOST_BY_ACCOUNT_NUMBER, v8 */
+ "get_host_by_account_number",
+ "ghba",
+ 8,
+ RETRIEVE,
+ "m",
+ MACHINE_TABLE,
+ "m.name, m.vendor, m.model, m.os, m.location, m.contact, m.billing_contact, m.account_number, m.use, m.status, TO_CHAR(m.statuschange, 'DD-mon-YYYY HH24:MI:SS'), s.name, m.address, m.owner_type, m.owner_id, m.acomment, m.ocomment, TO_CHAR(m.created, 'DD-mon-YYYY HH24:MI:SS'), m.creator, TO_CHAR(m.inuse, 'DD-mon-YYYY HH24:MI:SS'), TO_CHAR(m.modtime, 'DD-mon-YYYY HH24:MI:SS'), m.modby, m.modwith FROM machine m, subnet s",
+ ghba_fields,
+ 23,
+ "m.account_number LIKE '%s' AND m.mach_id != 0 and s.snet_id = m.snet_id",
+ 1,
+ "m.name",
+ &ghst_validate,
+ },
+
{
/* Q_GHHA - GET_HOST_HWADDR */
"get_host_hwaddr",
"m",
MACHINE_TABLE,
"INTO machine (name, vendor, model, os, location, contact, billing_contact, use, status, statuschange, snet_id, address, owner_type, owner_id, acomment, ocomment, created, inuse, mach_id, creator) VALUES (UPPER('%s'), NVL(UPPER('%s'), CHR(0)), NVL(UPPER('%s'), CHR(0)), NVL(UPPER('%s'), CHR(0)), NVL(UPPER('%s'), CHR(0)), NVL('%s', CHR(0)), NVL('%s', CHR(0)), %s, %s, SYSDATE, %d, '%s', '%s', %d, %d, %d, SYSDATE, SYSDATE, %s, %s)",
- ahst_fields,
+ ahst6_fields,
15,
0,
0,
NULL,
+ &ahst6_validate,
+ },
+
+ {
+ /* Q_AHST - ADD_HOST, v8 */ /* Uses prefetch_value() for mach_id */
+ "add_host",
+ "ahst",
+ 8,
+ APPEND,
+ "m",
+ MACHINE_TABLE,
+ "INTO machine (name, vendor, model, os, location, contact, billing_contact, account_number, use, status, statuschange, snet_id, address, owner_type, owner_id, acomment, ocomment, created, inuse, mach_id, creator) VALUES (UPPER('%s'), NVL(UPPER('%s'), CHR(0)), NVL(UPPER('%s'), CHR(0)), NVL(UPPER('%s'), CHR(0)), NVL(UPPER('%s'), CHR(0)), NVL('%s', CHR(0)), NVL('%s', CHR(0)), NVL('%s', CHR(0)), %s, %s, SYSDATE, %d, '%s', '%s', %d, %d, %d, SYSDATE, SYSDATE, %s, %s)",
+ ahst_fields,
+ 16,
+ 0,
+ 0,
+ NULL,
&ahst_validate,
},
"m",
MACHINE_TABLE,
"machine SET name = NVL(UPPER('%s'), CHR(0)), vendor = NVL(UPPER('%s'), CHR(0)), model = NVL(UPPER('%s'), CHR(0)), os = NVL(UPPER('%s'), CHR(0)), location = NVL(UPPER('%s'), CHR(0)), contact = NVL('%s', CHR(0)), billing_contact = NVL('%s', CHR(0)), use = %s, status = %s, snet_id = %d, address = '%s', owner_type = '%s', owner_id = %d, acomment = %d, ocomment = %d",
- uhst_fields,
+ uhst6_fields,
15,
"mach_id = %d",
1,
NULL,
+ &uhst6_validate,
+ },
+
+ {
+ /* Q_UHST - UPDATE_HOST, v8 */
+ "update_host",
+ "uhst",
+ 8,
+ UPDATE,
+ "m",
+ MACHINE_TABLE,
+ "machine SET name = NVL(UPPER('%s'), CHR(0)), vendor = NVL(UPPER('%s'), CHR(0)), model = NVL(UPPER('%s'), CHR(0)), os = NVL(UPPER('%s'), CHR(0)), location = NVL(UPPER('%s'), CHR(0)), contact = NVL('%s', CHR(0)), billing_contact = NVL('%s', CHR(0)), account_number = NVL('%s', CHR(0)), use = %s, status = %s, snet_id = %d, address = '%s', owner_type = '%s', owner_id = %d, acomment = %d, ocomment = %d",
+ uhst_fields,
+ 16,
+ "mach_id = %d",
+ 1,
+ NULL,
&uhst_validate,
},
},
{
- /* Q_GSNT - GET_SUBNET */
+ /* Q_GSNT - GET_SUBNET, v2 */
"get_subnet",
"gsnt",
2,
"s",
SUBNET_TABLE,
"name, description, saddr, mask, low, high, prefix, owner_type, owner_id, TO_CHAR(modtime, 'DD-mon-YYYY HH24:MI:SS'), modby, modwith FROM subnet",
- gsnt_fields,
+ gsnt2_fields,
12,
"name LIKE UPPER('%s')",
1,
},
{
- /* Q_ASNT - ADD_SUBNET */
+ /* Q_GSNT - GET_SUBNET, v8 */
+ "get_subnet",
+ "gsnt",
+ 8,
+ RETRIEVE,
+ "s",
+ SUBNET_TABLE,
+ "name, description, status, contact, account_number, saddr, mask, low, high, prefix, owner_type, owner_id, TO_CHAR(modtime, 'DD-mon-YYYY HH24:MI:SS'), modby, modwith FROM subnet",
+ gsnt_fields,
+ 15,
+ "name LIKE UPPER('%s')",
+ 1,
+ "name",
+ &gsnt_validate,
+ },
+
+ {
+ /* Q_ASNT - ADD_SUBNET, v2 */
"add_subnet",
"asnt",
2,
"s",
SUBNET_TABLE,
"INTO subnet (name, description, saddr, mask, low, high, prefix, owner_type, owner_id, snet_id) VALUES (UPPER('%s'), NVL('%s', CHR(0)), %s, %s, %s, %s, NVL('%s', CHR(0)), '%s', %d, %s)",
- asnt_fields,
+ asnt2_fields,
9,
0,
0,
NULL,
+ &asnt2_validate,
+ },
+
+ {
+ /* Q_ASNT - ADD_SUBNET, v8 */
+ "add_subnet",
+ "asnt",
+ 8,
+ APPEND,
+ "s",
+ SUBNET_TABLE,
+ "INTO subnet (name, description, status, contact, account_number, saddr, mask, low, high, prefix, owner_type, owner_id, snet_id) VALUES (UPPER('%s'), NVL('%s', CHR(0)), %s, NVL('%s', CHR(0)), %s, %s, %s, %s, %s, NVL('%s', CHR(0)), '%s', %d, %s)",
+ asnt_fields,
+ 12,
+ 0,
+ 0,
+ NULL,
&asnt_validate,
},
{
- /* Q_USNT - UPDATE_SUBNET */
+ /* Q_USNT - UPDATE_SUBNET, v2 */
"update_subnet",
"usnt",
2,
"s",
SUBNET_TABLE,
"subnet SET name = UPPER('%s'), description = NVL('%s', CHR(0)), saddr = %s, mask = %s, low = %s, high = %s, prefix = NVL('%s', CHR(0)), owner_type = '%s', owner_id = %d",
- usnt_fields,
+ usnt2_fields,
9,
"snet_id = %d",
1,
NULL,
+ &usnt2_validate,
+ },
+
+ {
+ /* Q_USNT - UPDATE_SUBNET, v8 */
+ "update_subnet",
+ "usnt",
+ 8,
+ UPDATE,
+ "s",
+ SUBNET_TABLE,
+ "subnet SET name = UPPER('%s'), description = NVL('%s', CHR(0)), status = %s, contact = NVL('%s', CHR(0)), account_number = NVL('%s', CHR(0)), saddr = %s, mask = %s, low = %s, high = %s, prefix = NVL('%s', CHR(0)), owner_type = '%s', owner_id = %d",
+ usnt_fields,
+ 12,
+ "snet_id = %d",
+ 1,
+ NULL,
&usnt_validate,
},