def _get_hostname_from_bridge_if(self): if self.environment[ohostedcons.CoreEnv.ANSIBLE_DEPLOYMENT]: # TODO: properly handle it without vdsm if not self.environment[ohostedcons.NetworkEnv.HOST_NAME]: self.environment[ ohostedcons.NetworkEnv.HOST_NAME] = socket.gethostname() if not self.environment[ohostedcons.EngineEnv.APP_HOST_NAME]: self.environment[ohostedcons.EngineEnv. APP_HOST_NAME] = socket.gethostname() else: ipaddr = None if self._enabled: # acquiring interface address configuration, status = vds_info.network( vds_info.capabilities( self.environment[ohostedcons.VDSMEnv.VDS_CLI]), self.environment[ohostedcons.NetworkEnv.BRIDGE_IF], ) self.logger.debug('Network info: {info}'.format(info=status)) if 'ipaddr' not in status: raise RuntimeError( _('Cannot acquire nic/bond/vlan address')) ipaddr = status['ipaddr'] else: # acquiring bridge address caps = vds_info.capabilities( self.environment[ohostedcons.VDSMEnv.VDS_CLI]) if 'networks' in caps: networks = caps['networks'] if self.environment[ ohostedcons.NetworkEnv.BRIDGE_NAME] in networks: bridge = networks[self.environment[ ohostedcons.NetworkEnv.BRIDGE_NAME]] if 'addr' in bridge: ipaddr = bridge['addr'] if not ipaddr: raise RuntimeError(_('Cannot acquire bridge address')) hostname, aliaslist, ipaddrlist = socket.gethostbyaddr(ipaddr) self.logger.debug( "hostname: '{h}', aliaslist: '{a}', ipaddrlist: '{i}'".format( h=hostname, a=aliaslist, i=ipaddrlist, )) if len(ipaddrlist) > 1: other_ip = set(ipaddrlist) - set([ipaddr]) raise RuntimeError( _("hostname '{h}' doesn't uniquely match the interface " "'{i}' selected for the management bridge; " "it matches also interface with IP {o}. " "Please make sure that the hostname got from " "the interface for the management network resolves " "only there.").format( h=hostname, i=self.environment[ohostedcons.NetworkEnv.BRIDGE_IF], o=other_ip, )) self.environment[ohostedcons.NetworkEnv.HOST_NAME] = hostname
def _misc(self): self.logger.info(_('Configuring the management bridge')) conn = self.environment[ohostedcons.VDSMEnv.VDS_CLI] networks = { self.environment[ohostedcons.NetworkEnv.BRIDGE_NAME]: vds_info.network( vds_info.capabilities(conn), self.environment[ohostedcons.NetworkEnv.BRIDGE_IF]) } _setupNetworks(conn, networks, {}, {'connectivityCheck': False}) _setSafeNetworkConfig(conn)
def _misc(self): self.logger.info(_('Configuring the management bridge')) conn = self.environment[ohostedcons.VDSMEnv.VDS_CLI] networks = { self.environment[ohostedcons.NetworkEnv.BRIDGE_NAME]: vds_info.network( vds_info.capabilities(conn), self.environment[ohostedcons.NetworkEnv.BRIDGE_IF] ) } _setupNetworks(conn, networks, {}, {'connectivityCheck': False}) _setSafeNetworkConfig(conn)
def _misc(self): self.logger.info(_('Configuring the management bridge')) conn = self.environment[ohostedcons.VDSMEnv.VDS_CLI] nconf, nstatus = vds_info.network( vds_info.capabilities(conn), self.environment[ohostedcons.NetworkEnv.BRIDGE_IF]) networks = { self.environment[ohostedcons.NetworkEnv.BRIDGE_NAME]: nconf } bonds = {} options = {'connectivityCheck': False} self.logger.debug('networks: {networks}'.format(networks=networks)) self.logger.debug('bonds: {bonds}'.format(bonds=bonds)) self.logger.debug('options: {options}'.format(options=options)) _setupNetworks(conn, networks, bonds, options) _setSafeNetworkConfig(conn)
def _misc(self): self.logger.info(_('Configuring the management bridge')) conn = self.environment[ohostedcons.VDSMEnv.VDS_CLI] nconf, nstatus = vds_info.network( vds_info.capabilities(conn), self.environment[ohostedcons.NetworkEnv.BRIDGE_IF] ) networks = { self.environment[ohostedcons.NetworkEnv.BRIDGE_NAME]: nconf } bonds = {} options = {'connectivityCheck': False} self.logger.debug('networks: {networks}'.format(networks=networks)) self.logger.debug('bonds: {bonds}'.format(bonds=bonds)) self.logger.debug('options: {options}'.format(options=options)) _setupNetworks(conn, networks, bonds, options) _setSafeNetworkConfig(conn)
def _get_hostname_from_bridge_if(self): ipaddr = None if self._enabled: # acquiring interface address configuration, status = vds_info.network( vds_info.capabilities( self.environment[ohostedcons.VDSMEnv.VDS_CLI] ), self.environment[ ohostedcons.NetworkEnv.BRIDGE_IF ], ) self.logger.debug('Network info: {info}'.format(info=status)) if 'ipaddr' not in status: raise RuntimeError(_('Cannot acquire nic/bond/vlan address')) ipaddr = status['ipaddr'] else: # acquiring bridge address cli = self.environment[ohostedcons.VDSMEnv.VDS_CLI] caps = cli.getVdsCapabilities() self.logger.debug(caps) if caps['status']['code'] != 0: raise RuntimeError( _('Failed getting VDSM capabilities: {msg}').format( msg=caps['status']['message'], ) ) if 'networks' in caps: networks = caps['networks'] if self.environment[ ohostedcons.NetworkEnv.BRIDGE_NAME ] in networks: bridge = networks[ self.environment[ ohostedcons.NetworkEnv.BRIDGE_NAME ] ] if 'addr' in bridge: ipaddr = bridge['addr'] if not ipaddr: raise RuntimeError(_('Cannot acquire bridge address')) hostname, aliaslist, ipaddrlist = socket.gethostbyaddr(ipaddr) self.logger.debug( "hostname: '{h}', aliaslist: '{a}', ipaddrlist: '{i}'".format( h=hostname, a=aliaslist, i=ipaddrlist, ) ) if len(ipaddrlist) > 1: other_ip = set(ipaddrlist) - set([ipaddr]) raise RuntimeError(_( "hostname '{h}' doesn't uniquely match the interface " "'{i}' selected for the management bridge; " "it matches also interface with IP {o}. " "Please make sure that the hostname got from " "the interface for the management network resolves " "only there." ).format( h=hostname, i=self.environment[ ohostedcons.NetworkEnv.BRIDGE_IF ], o=other_ip, )) self.environment[ ohostedcons.NetworkEnv.HOST_NAME ] = hostname