Fix remaining instances of userdata_template
This commit is contained in:
parent
a4ad58e64c
commit
8fea073b55
|
@ -650,7 +650,7 @@ def list_profile(limit, is_fuzzy=True):
|
||||||
profile_data['id'] = profile['id']
|
profile_data['id'] = profile['id']
|
||||||
profile_data['name'] = profile['name']
|
profile_data['name'] = profile['name']
|
||||||
# Parse the name of each subelement
|
# Parse the name of each subelement
|
||||||
for etype in 'system_template', 'network_template', 'storage_template', 'userdata_template', 'script':
|
for etype in 'system_template', 'network_template', 'storage_template', 'userdata', 'script':
|
||||||
query = 'SELECT name from {} WHERE id = %s'.format(etype)
|
query = 'SELECT name from {} WHERE id = %s'.format(etype)
|
||||||
args = (profile[etype],)
|
args = (profile[etype],)
|
||||||
cur.execute(query, args)
|
cur.execute(query, args)
|
||||||
|
@ -663,7 +663,7 @@ def list_profile(limit, is_fuzzy=True):
|
||||||
close_database(conn, cur)
|
close_database(conn, cur)
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def create_profile(name, system_template, network_template, storage_template, userdata_template, script, arguments=[]):
|
def create_profile(name, system_template, network_template, storage_template, userdata, script, arguments=[]):
|
||||||
if list_profile(name, is_fuzzy=False):
|
if list_profile(name, is_fuzzy=False):
|
||||||
retmsg = { 'message': 'The profile "{}" already exists'.format(name) }
|
retmsg = { 'message': 'The profile "{}" already exists'.format(name) }
|
||||||
retcode = 400
|
retcode = 400
|
||||||
|
@ -699,13 +699,13 @@ def create_profile(name, system_template, network_template, storage_template, us
|
||||||
retcode = 400
|
retcode = 400
|
||||||
return retmsg, retcode
|
return retmsg, retcode
|
||||||
|
|
||||||
userdata_templates = list_template_userdata(None)
|
userdatas = list_template_userdata(None)
|
||||||
userdata_template_id = None
|
userdata_id = None
|
||||||
for template in userdata_templates:
|
for template in userdatas:
|
||||||
if template['name'] == userdata_template:
|
if template['name'] == userdata:
|
||||||
userdata_template_id = template['id']
|
userdata_id = template['id']
|
||||||
if not userdata_template_id:
|
if not userdata_id:
|
||||||
retmsg = { 'message': 'The userdata template "{}" for profile "{}" does not exist'.format(userdata_template, name) }
|
retmsg = { 'message': 'The userdata template "{}" for profile "{}" does not exist'.format(userdata, name) }
|
||||||
retcode = 400
|
retcode = 400
|
||||||
return retmsg, retcode
|
return retmsg, retcode
|
||||||
|
|
||||||
|
@ -723,8 +723,8 @@ def create_profile(name, system_template, network_template, storage_template, us
|
||||||
|
|
||||||
conn, cur = open_database(config)
|
conn, cur = open_database(config)
|
||||||
try:
|
try:
|
||||||
query = "INSERT INTO profile (name, system_template, network_template, storage_template, userdata_template, script, arguments) VALUES (%s, %s, %s, %s, %s, %s, %s);"
|
query = "INSERT INTO profile (name, system_template, network_template, storage_template, userdata, script, arguments) VALUES (%s, %s, %s, %s, %s, %s, %s);"
|
||||||
args = (name, system_template_id, network_template_id, storage_template_id, userdata_template_id, script_id, arguments_formatted)
|
args = (name, system_template_id, network_template_id, storage_template_id, userdata_id, script_id, arguments_formatted)
|
||||||
cur.execute(query, args)
|
cur.execute(query, args)
|
||||||
retmsg = { "message": 'Created VM profile "{}"'.format(name) }
|
retmsg = { "message": 'Created VM profile "{}"'.format(name) }
|
||||||
retcode = 200
|
retcode = 200
|
||||||
|
|
|
@ -7,7 +7,7 @@ create table storage_template (id SERIAL PRIMARY KEY, name TEXT NOT NULL UNIQUE)
|
||||||
create table storage (id SERIAL PRIMARY KEY, storage_template INT REFERENCES storage_template(id), pool TEXT NOT NULL, disk_id TEXT NOT NULL, disk_size_gb INT NOT NULL, mountpoint TEXT, filesystem TEXT, filesystem_args TEXT);
|
create table storage (id SERIAL PRIMARY KEY, storage_template INT REFERENCES storage_template(id), pool TEXT NOT NULL, disk_id TEXT NOT NULL, disk_size_gb INT NOT NULL, mountpoint TEXT, filesystem TEXT, filesystem_args TEXT);
|
||||||
create table userdata (id SERIAL PRIMARY KEY, name TEXT NOT NULL UNIQUE, userdata TEXT NOT NULL);
|
create table userdata (id SERIAL PRIMARY KEY, name TEXT NOT NULL UNIQUE, userdata TEXT NOT NULL);
|
||||||
create table script (id SERIAL PRIMARY KEY, name TEXT NOT NULL UNIQUE, script TEXT NOT NULL);
|
create table script (id SERIAL PRIMARY KEY, name TEXT NOT NULL UNIQUE, script TEXT NOT NULL);
|
||||||
create table profile (id SERIAL PRIMARY KEY, name TEXT NOT NULL UNIQUE, system_template INT REFERENCES system_template(id), network_template INT REFERENCES network_template(id), storage_template INT REFERENCES storage_template(id), userdata_template INT REFERENCES userdata_template(id), script INT REFERENCES script(id), arguments text);
|
create table profile (id SERIAL PRIMARY KEY, name TEXT NOT NULL UNIQUE, system_template INT REFERENCES system_template(id), network_template INT REFERENCES network_template(id), storage_template INT REFERENCES storage_template(id), userdata INT REFERENCES userdata(id), script INT REFERENCES script(id), arguments text);
|
||||||
grant all privileges on database pvcprov to pvcprov;
|
grant all privileges on database pvcprov to pvcprov;
|
||||||
grant all privileges on all tables in schema public to pvcprov;
|
grant all privileges on all tables in schema public to pvcprov;
|
||||||
grant all privileges on all sequences in schema public to pvcprov;
|
grant all privileges on all sequences in schema public to pvcprov;
|
||||||
|
|
Loading…
Reference in New Issue