Admin utility: add in ability to update edge reservations
There may be certain cases when an admin wants to update the edge reservations she/he can do it as follows: 1. Use the admin utility to update cpu reservetsions - use resource cpu 2. Use the admin utility to update memory reservations - use resource memory The following can be set: limits, shares, reservations. Change-Id: Ib14cc70bc162aae1b7bc0afdff1872b021d9a0c9
This commit is contained in:
parent
f0a960274b
commit
e927fbefcf
@ -48,6 +48,10 @@ Edges
|
||||
|
||||
nsxadmin -o nsx-update -r edges -p edge-id=edge-55 --property syslog-server=none
|
||||
|
||||
- Update reservations of an edge::
|
||||
|
||||
nsxadmin -o nsx-update -r edges -p edge-id=edge-55 --property resource=<cpu|memory> --property limit=<limit> --property reservation=<reservation> --property shares=<shares>
|
||||
|
||||
Orphaned Edges
|
||||
~~~~~~~~~~~~~~
|
||||
|
||||
|
@ -279,6 +279,40 @@ def change_edge_appliance(edge_id):
|
||||
change_edge_ha(az.edge_ha, edge_id)
|
||||
|
||||
|
||||
def change_edge_appliance_reservations(properties):
|
||||
reservations = {}
|
||||
res = {}
|
||||
if properties.get('limit'):
|
||||
res['limit'] = properties.get('limit')
|
||||
if properties.get('reservation'):
|
||||
res['reservation'] = properties.get('reservation')
|
||||
if properties.get('shares'):
|
||||
res['shares'] = properties.get('shares')
|
||||
resource = properties.get('resource')
|
||||
if not res:
|
||||
LOG.error(_LE("Please configure reservations"))
|
||||
return
|
||||
if resource == 'cpu':
|
||||
reservations['cpuReservation'] = res
|
||||
elif resource == 'memory':
|
||||
reservations['memoryReservation'] = res
|
||||
else:
|
||||
LOG.error(_LE("Please configure resource"))
|
||||
return
|
||||
edge_id = properties.get('edge-id')
|
||||
h, edge = nsxv.get_edge(edge_id)
|
||||
appliances = edge['appliances']['appliances']
|
||||
for appliance in appliances:
|
||||
appliance.update(reservations)
|
||||
request = {'appliances': appliances}
|
||||
try:
|
||||
nsxv.change_edge_appliance(edge_id, request)
|
||||
except nsxv_exceptions.ResourceNotFound as e:
|
||||
LOG.error(_LE("Edge %s not found"), edge_id)
|
||||
except exceptions.NeutronException as e:
|
||||
LOG.error(_LE("%s"), str(e))
|
||||
|
||||
|
||||
@admin_utils.output_header
|
||||
def nsx_update_edge(resource, event, trigger, **kwargs):
|
||||
"""Update edge properties"""
|
||||
@ -288,7 +322,12 @@ def nsx_update_edge(resource, event, trigger, **kwargs):
|
||||
"--property size=<size> or --property appliances=True. "
|
||||
"For syslog, add --property syslog-server=<ip>|none and "
|
||||
"(optional) --property syslog-server2=<ip> and/or "
|
||||
"(optional) --property syslog-proto=[tcp/udp]")
|
||||
"(optional) --property syslog-proto=[tcp/udp] "
|
||||
"For edge reservations, add "
|
||||
"--property resource=cpu|memory and "
|
||||
"(optional) --property limit=<limit> and/or "
|
||||
"(optional) --property shares=<shares> and/or "
|
||||
"(optional) --property reservation=<reservation>")
|
||||
if not kwargs.get('property'):
|
||||
LOG.error(usage_msg)
|
||||
return
|
||||
@ -312,6 +351,8 @@ def nsx_update_edge(resource, event, trigger, **kwargs):
|
||||
delete_edge_syslog(properties['edge-id'])
|
||||
else:
|
||||
change_edge_syslog(properties)
|
||||
elif properties.get('resource'):
|
||||
change_edge_appliance_reservations(properties)
|
||||
else:
|
||||
# no attribute was specified
|
||||
LOG.error(usage_msg)
|
||||
|
Loading…
x
Reference in New Issue
Block a user