More gracefully handle none selectors
Allow selection of "none" as the node selector, and handle this by always using the cluster default instead of writing it in.
This commit is contained in:
@ -1102,7 +1102,7 @@ class API_VM_Root(Resource):
|
||||
@RequestParser([
|
||||
{'name': 'limit'},
|
||||
{'name': 'node'},
|
||||
{'name': 'selector', 'choices': ('mem', 'vcpus', 'load', 'vms'), 'helptext': "A valid selector must be specified"},
|
||||
{'name': 'selector', 'choices': ('mem', 'vcpus', 'load', 'vms', 'none'), 'helptext': "A valid selector must be specified"},
|
||||
{'name': 'autostart'},
|
||||
{'name': 'migration_method', 'choices': ('live', 'shutdown', 'none'), 'helptext': "A valid migration_method must be specified"},
|
||||
{'name': 'xml', 'required': True, 'helptext': "A Libvirt XML document must be specified"},
|
||||
@ -1172,7 +1172,7 @@ class API_VM_Root(Resource):
|
||||
reqargs.get('xml'),
|
||||
reqargs.get('node', None),
|
||||
reqargs.get('limit', None),
|
||||
reqargs.get('selector', 'mem'),
|
||||
reqargs.get('selector', 'none'),
|
||||
bool(strtobool(reqargs.get('autostart', 'false'))),
|
||||
reqargs.get('migration_method', 'none')
|
||||
)
|
||||
@ -1206,7 +1206,7 @@ class API_VM_Element(Resource):
|
||||
@RequestParser([
|
||||
{'name': 'limit'},
|
||||
{'name': 'node'},
|
||||
{'name': 'selector', 'choices': ('mem', 'vcpus', 'load', 'vms'), 'helptext': "A valid selector must be specified"},
|
||||
{'name': 'selector', 'choices': ('mem', 'vcpus', 'load', 'vms', 'none'), 'helptext': "A valid selector must be specified"},
|
||||
{'name': 'autostart'},
|
||||
{'name': 'migration_method', 'choices': ('live', 'shutdown', 'none'), 'helptext': "A valid migration_method must be specified"},
|
||||
{'name': 'xml', 'required': True, 'helptext': "A Libvirt XML document must be specified"},
|
||||
@ -1247,6 +1247,7 @@ class API_VM_Element(Resource):
|
||||
- vcpus
|
||||
- load
|
||||
- vms
|
||||
- none (cluster default)
|
||||
- in: query
|
||||
name: autostart
|
||||
type: boolean
|
||||
@ -1278,7 +1279,7 @@ class API_VM_Element(Resource):
|
||||
reqargs.get('xml'),
|
||||
reqargs.get('node', None),
|
||||
reqargs.get('limit', None),
|
||||
reqargs.get('selector', 'mem'),
|
||||
reqargs.get('selector', 'none'),
|
||||
bool(strtobool(reqargs.get('autostart', 'false'))),
|
||||
reqargs.get('migration_method', 'none')
|
||||
)
|
||||
@ -1407,7 +1408,7 @@ class API_VM_Metadata(Resource):
|
||||
|
||||
@RequestParser([
|
||||
{'name': 'limit'},
|
||||
{'name': 'selector', 'choices': ('mem', 'vcpus', 'load', 'vms'), 'helptext': "A valid selector must be specified"},
|
||||
{'name': 'selector', 'choices': ('mem', 'vcpus', 'load', 'vms', 'none'), 'helptext': "A valid selector must be specified"},
|
||||
{'name': 'autostart'},
|
||||
{'name': 'profile'},
|
||||
{'name': 'migration_method', 'choices': ('live', 'shutdown', 'none'), 'helptext': "A valid migration_method must be specified"},
|
||||
|
@ -53,9 +53,6 @@ def initialize_cluster(zkhandler, overwrite=False):
|
||||
# Delete the existing keys; ignore any errors
|
||||
status = zkhandler.delete([
|
||||
'/config'
|
||||
'/config/primary_node',
|
||||
'/config/upstream_ip',
|
||||
'/config/maintenance',
|
||||
'/nodes',
|
||||
'/domains',
|
||||
'/networks',
|
||||
@ -81,6 +78,7 @@ def initialize_cluster(zkhandler, overwrite=False):
|
||||
('/config/primary_node', 'none'),
|
||||
('/config/upstream_ip', 'none'),
|
||||
('/config/maintenance', 'False'),
|
||||
('/config/migration_target_selector', 'none'),
|
||||
('/nodes', ''),
|
||||
('/domains', ''),
|
||||
('/networks', ''),
|
||||
|
@ -219,6 +219,9 @@ def create_template_system(name, vcpu_count, vram_mb, serial=False, vnc=False, v
|
||||
retcode = 400
|
||||
return retmsg, retcode
|
||||
|
||||
if node_selector == 'none':
|
||||
node_selector = None
|
||||
|
||||
query = "INSERT INTO system_template (name, vcpu_count, vram_mb, serial, vnc, vnc_bind, node_limit, node_selector, node_autostart, migration_method, ova) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s);"
|
||||
args = (name, vcpu_count, vram_mb, serial, vnc, vnc_bind, node_limit, node_selector, node_autostart, migration_method, ova)
|
||||
|
||||
@ -414,6 +417,9 @@ def modify_template_system(name, vcpu_count=None, vram_mb=None, serial=None, vnc
|
||||
fields.append({'field': 'node_limit', 'data': node_limit})
|
||||
|
||||
if node_selector is not None:
|
||||
if node_selector == 'none':
|
||||
node_selector = 'None'
|
||||
|
||||
fields.append({'field': 'node_selector', 'data': node_selector})
|
||||
|
||||
if node_autostart is not None:
|
||||
|
Reference in New Issue
Block a user