[AU]: Add command to modify edge appliance size
$ nsxadmin -r edges -o nsx-update --property edge-id=edge-55 --property size=compact NSX Plugin in use: nsxv ==== [NSX] Update Edge ==== Updating NSXv edge: edge-55 with properties {'edge-id': 'edge-55', 'size': 'compact'} Change-Id: I004ec9c9ac480c28186d069e230878201283eb25
This commit is contained in:
parent
ad5908d923
commit
a7d261ce57
@ -824,6 +824,12 @@ class Vcns(object):
|
|||||||
uri += "?async=true"
|
uri += "?async=true"
|
||||||
return self.do_request(HTTP_PUT, uri, request_config)
|
return self.do_request(HTTP_PUT, uri, request_config)
|
||||||
|
|
||||||
|
def change_edge_appliance_size(self, edge_id, size):
|
||||||
|
"""Change the size of edge appliances."""
|
||||||
|
uri = ("/api/4.0/edges/%s/appliances/?size=%s" %
|
||||||
|
(edge_id, size))
|
||||||
|
return self.do_request(HTTP_POST, uri)
|
||||||
|
|
||||||
def upload_edge_certificate(self, edge_id, request):
|
def upload_edge_certificate(self, edge_id, request):
|
||||||
"""Creates a certificate on the specified Edge appliance."""
|
"""Creates a certificate on the specified Edge appliance."""
|
||||||
uri = '%s/%s/%s' % (TRUSTSTORE_PREFIX, CERTIFICATE, edge_id)
|
uri = '%s/%s/%s' % (TRUSTSTORE_PREFIX, CERTIFICATE, edge_id)
|
||||||
|
@ -28,6 +28,8 @@ from neutron.common import exceptions
|
|||||||
|
|
||||||
from vmware_nsx._i18n import _LE, _LI
|
from vmware_nsx._i18n import _LE, _LI
|
||||||
from vmware_nsx.db import nsxv_db
|
from vmware_nsx.db import nsxv_db
|
||||||
|
import vmware_nsx.plugins.nsx_v.vshield.common.constants as nsxv_constants
|
||||||
|
import vmware_nsx.plugins.nsx_v.vshield.common.exceptions as nsxv_exceptions
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
nsxv = utils.get_nsxv_client()
|
nsxv = utils.get_nsxv_client()
|
||||||
@ -116,6 +118,34 @@ def nsx_delete_orphaned_edges(resource, event, trigger, **kwargs):
|
|||||||
pprint.pformat(get_orphaned_edges()))
|
pprint.pformat(get_orphaned_edges()))
|
||||||
|
|
||||||
|
|
||||||
|
def change_edge_ha(properties):
|
||||||
|
ha = bool(properties.get('highavailability').lower() == "true")
|
||||||
|
request = {
|
||||||
|
'featureType': 'highavailability_4.0',
|
||||||
|
'enabled': ha}
|
||||||
|
try:
|
||||||
|
nsxv.enable_ha(properties.get('edge-id'), request, async=False)
|
||||||
|
except nsxv_exceptions.ResourceNotFound as e:
|
||||||
|
LOG.error(_LE("Edge %s not found"), properties.get('edge-id'))
|
||||||
|
except exceptions.NeutronException as e:
|
||||||
|
LOG.error(_LE("%s"), str(e))
|
||||||
|
|
||||||
|
|
||||||
|
def change_edge_appliance_size(properties):
|
||||||
|
size = properties.get('size')
|
||||||
|
if size not in nsxv_constants.ALLOWED_EDGE_SIZES:
|
||||||
|
LOG.error(_LE("Edge appliance size not in %(size)s"),
|
||||||
|
{'size': nsxv_constants.ALLOWED_EDGE_SIZES})
|
||||||
|
return
|
||||||
|
try:
|
||||||
|
nsxv.change_edge_appliance_size(
|
||||||
|
properties.get('edge-id'), size)
|
||||||
|
except nsxv_exceptions.ResourceNotFound as e:
|
||||||
|
LOG.error(_LE("Edge %s not found"), properties.get('edge-id'))
|
||||||
|
except exceptions.NeutronException as e:
|
||||||
|
LOG.error(_LE("%s"), str(e))
|
||||||
|
|
||||||
|
|
||||||
@admin_utils.output_header
|
@admin_utils.output_header
|
||||||
def nsx_update_edge(resource, event, trigger, **kwargs):
|
def nsx_update_edge(resource, event, trigger, **kwargs):
|
||||||
"""Update edge properties"""
|
"""Update edge properties"""
|
||||||
@ -132,14 +162,9 @@ def nsx_update_edge(resource, event, trigger, **kwargs):
|
|||||||
LOG.info(_LI("Updating NSXv edge: %(edge)s with properties\n%(prop)s"),
|
LOG.info(_LI("Updating NSXv edge: %(edge)s with properties\n%(prop)s"),
|
||||||
{'edge': properties.get('edge-id'), 'prop': properties})
|
{'edge': properties.get('edge-id'), 'prop': properties})
|
||||||
if properties.get('highavailability'):
|
if properties.get('highavailability'):
|
||||||
ha = bool(properties.get('highavailability').lower() == "true")
|
change_edge_ha(properties)
|
||||||
ha_request = {
|
elif properties.get('size'):
|
||||||
'featureType': 'highavailability_4.0',
|
change_edge_appliance_size(properties)
|
||||||
'enabled': ha}
|
|
||||||
try:
|
|
||||||
nsxv.enable_ha(properties.get('edge-id'), ha_request, async=False)
|
|
||||||
except exceptions.NeutronException as e:
|
|
||||||
LOG.error(_LE("%s"), str(e))
|
|
||||||
|
|
||||||
|
|
||||||
registry.subscribe(nsx_list_edges,
|
registry.subscribe(nsx_list_edges,
|
||||||
|
@ -1122,3 +1122,10 @@ class FakeVcns(object):
|
|||||||
}
|
}
|
||||||
response = ''
|
response = ''
|
||||||
return (header, response)
|
return (header, response)
|
||||||
|
|
||||||
|
def change_edge_appliance_size(self, edge_id, size):
|
||||||
|
header = {
|
||||||
|
'status': 204
|
||||||
|
}
|
||||||
|
response = {}
|
||||||
|
return (header, response)
|
||||||
|
Loading…
Reference in New Issue
Block a user