NSX|V3: AdminUtil updating server ip of md-proxy
New Admin utility to be used during upgrade if it is necessary to change the ip of the Nova server in the metadata proxy server. Usage: nsxadmin -r metadata-proxy -o nsx-update-ip --property server-ip=<server-ip> you can optionally add the availability zone: --property availability-zone=<name> Depends-on: I702398f254a1329299ec2cb82e214caf0ae59a9c Change-Id: I3b9b3cf3de7c0a5009da11abb69155b1d9c63eb7
This commit is contained in:
parent
1174c55424
commit
586bd4df40
@ -353,6 +353,10 @@ Metadata Proxy
|
||||
|
||||
nsxadmin -r metadata-proxy -o nsx-update --property metadata_proxy_uuid=<metadata_proxy_uuid>
|
||||
|
||||
- update the ip of the Nova server in the metadata proxy server on the nsx
|
||||
|
||||
nsxadmin -r metadata-proxy -o nsx-update-ip --property server-ip=<server-ip> --property availability-zone=<optional zone name>
|
||||
|
||||
DHCP Bindings
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
|
@ -12,18 +12,25 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import re
|
||||
|
||||
import netaddr
|
||||
|
||||
from neutron_lib.callbacks import registry
|
||||
from neutron_lib import constants as const
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
|
||||
from vmware_nsx.common import config # noqa
|
||||
from vmware_nsx.common import utils as nsx_utils
|
||||
from vmware_nsx.dhcp_meta import rpc as nsx_rpc
|
||||
from vmware_nsx.plugins.nsx_v3 import availability_zones as nsx_az
|
||||
from vmware_nsx.shell.admin.plugins.common import constants
|
||||
from vmware_nsx.shell.admin.plugins.common import formatters
|
||||
from vmware_nsx.shell.admin.plugins.common import utils as admin_utils
|
||||
from vmware_nsx.shell.admin.plugins.nsxv3.resources import utils
|
||||
import vmware_nsx.shell.resources as shell
|
||||
from vmware_nsxlib.v3 import exceptions as nsx_exc
|
||||
from vmware_nsxlib.v3 import nsx_constants
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
@ -126,9 +133,64 @@ def nsx_update_metadata_proxy(resource, event, trigger, **kwargs):
|
||||
network['id'])
|
||||
|
||||
|
||||
@admin_utils.output_header
|
||||
def nsx_update_metadata_proxy_server_ip(resource, event, trigger, **kwargs):
|
||||
"""Update Metadata proxy server ip on the nsx."""
|
||||
nsxlib = utils.get_connected_nsxlib()
|
||||
nsx_version = nsxlib.get_version()
|
||||
if not nsx_utils.is_nsx_version_1_1_0(nsx_version):
|
||||
LOG.error("This utility is not available for NSX version %s",
|
||||
nsx_version)
|
||||
return
|
||||
|
||||
server_ip = None
|
||||
az_name = nsx_az.DEFAULT_NAME
|
||||
if kwargs.get('property'):
|
||||
properties = admin_utils.parse_multi_keyval_opt(kwargs['property'])
|
||||
server_ip = properties.get('server-ip')
|
||||
az_name = properties.get('availability-zone', az_name)
|
||||
if not server_ip or not netaddr.valid_ipv4(server_ip):
|
||||
LOG.error("Need to specify a valid server-ip parameter")
|
||||
return
|
||||
|
||||
config.register_nsxv3_azs(cfg.CONF, cfg.CONF.nsx_v3.availability_zones)
|
||||
if (az_name != nsx_az.DEFAULT_NAME and
|
||||
az_name not in cfg.CONF.nsx_v3.availability_zones):
|
||||
LOG.error("Availability zone %s was not found in the configuration",
|
||||
az_name)
|
||||
return
|
||||
|
||||
az = nsx_az.NsxV3AvailabilityZones().get_availability_zone(az_name)
|
||||
az.translate_configured_names_to_uuids(nsxlib)
|
||||
|
||||
if (not az.metadata_proxy or
|
||||
not cfg.CONF.nsx_v3.native_dhcp_metadata):
|
||||
LOG.error("Native DHCP metadata is not enabled in the configuration "
|
||||
"of availability zone %s", az_name)
|
||||
return
|
||||
metadata_proxy_uuid = az._native_md_proxy_uuid
|
||||
|
||||
try:
|
||||
mdproxy = nsxlib.native_md_proxy.get(metadata_proxy_uuid)
|
||||
except nsx_exc.ResourceNotFound:
|
||||
LOG.error("metadata proxy %s not found", metadata_proxy_uuid)
|
||||
return
|
||||
|
||||
# update the IP in the URL
|
||||
url = mdproxy.get('metadata_server_url')
|
||||
url = re.sub(r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}', server_ip, url)
|
||||
LOG.info("Updating the URL of the metadata proxy server %(uuid)s to "
|
||||
"%(url)s", {'uuid': metadata_proxy_uuid, 'url': url})
|
||||
nsxlib.native_md_proxy.update(metadata_proxy_uuid, server_url=url)
|
||||
LOG.info("Done.")
|
||||
|
||||
|
||||
registry.subscribe(list_metadata_networks,
|
||||
constants.METADATA_PROXY,
|
||||
shell.Operations.LIST.value)
|
||||
registry.subscribe(nsx_update_metadata_proxy,
|
||||
constants.METADATA_PROXY,
|
||||
shell.Operations.NSX_UPDATE.value)
|
||||
registry.subscribe(nsx_update_metadata_proxy_server_ip,
|
||||
constants.METADATA_PROXY,
|
||||
shell.Operations.NSX_UPDATE_IP.value)
|
||||
|
@ -49,6 +49,7 @@ class Operations(enum.Enum):
|
||||
NSX_UPDATE_ALL = 'nsx-update-all'
|
||||
NSX_UPDATE_SECRET = 'nsx-update-secret'
|
||||
NSX_UPDATE_RULES = 'nsx-update-rules'
|
||||
NSX_UPDATE_IP = 'nsx-update-ip'
|
||||
NSX_RECREATE = 'nsx-recreate'
|
||||
NSX_REORDER = 'nsx-reorder'
|
||||
NSX_TAG_DEFAULT = 'nsx-tag-default'
|
||||
@ -100,7 +101,8 @@ nsxv3_resources = {
|
||||
Operations.NSX_UPDATE.value]),
|
||||
constants.METADATA_PROXY: Resource(constants.METADATA_PROXY,
|
||||
[Operations.LIST.value,
|
||||
Operations.NSX_UPDATE.value]),
|
||||
Operations.NSX_UPDATE.value,
|
||||
Operations.NSX_UPDATE_IP.value]),
|
||||
constants.ORPHANED_DHCP_SERVERS: Resource(constants.ORPHANED_DHCP_SERVERS,
|
||||
[Operations.NSX_LIST.value,
|
||||
Operations.NSX_CLEAN.value]),
|
||||
|
Loading…
x
Reference in New Issue
Block a user