def _learn_sp_and_template_for_host(self, host_id): ucsm_ips = list(CONF.ml2_cisco_ucsm.ucsms) for ucsm_ip in ucsm_ips: with self.ucsm_connect_disconnect(ucsm_ip) as handle: try: sp_list_temp = handle.ConfigResolveClass('lsServer', None, inHierarchical=False) if sp_list_temp and sp_list_temp.OutConfigs is not None: sp_list = sp_list_temp.OutConfigs.GetChild() or [] for sp in sp_list: if sp.PnDn: server_name = self._get_server_name(handle, sp, ucsm_ip) LOG.debug('Server_name = %s', server_name) if server_name == host_id: self.ucsm_host_dict[server_name] = ucsm_ip LOG.debug('Found host %s with SP %s ' 'at UCSM %s', server_name, str(sp.Dn), ucsm_ip) LOG.debug('Server SP Template %s', sp.OperSrcTemplName) config.update_sp_template_config( host_id, ucsm_ip, sp.OperSrcTemplName) return ucsm_ip except Exception as e: # Raise a Neutron exception. Include a description of # the original exception. raise cexc.UcsmConfigReadFailed(ucsm_ip=ucsm_ip, exc=e)
def _learn_sp_and_template_for_host(self, host_id): ucsm_ips = list(CONF.ml2_cisco_ucsm.ucsms) for ucsm_ip in ucsm_ips: with self.ucsm_connect_disconnect(ucsm_ip) as handle: try: sp_list = handle.query_classid('lsServer') if sp_list is not None: for sp in sp_list: if sp.pn_dn: server_name = handle.query_dn(sp.pn_dn).name LOG.debug('Server_name = %s', server_name) if server_name == host_id: self.ucsm_host_dict[server_name] = ucsm_ip LOG.debug( 'Found host %s with SP %s ' 'at UCSM %s', server_name, str(sp.dn), ucsm_ip) LOG.debug('Server SP Template %s', sp.oper_src_templ_name) config.update_sp_template_config( host_id, ucsm_ip, sp.oper_src_templ_name) return ucsm_ip except Exception as e: # Raise a Neutron exception. Include a description of # the original exception. raise cexc.UcsmConfigReadFailed(ucsm_ip=ucsm_ip, exc=e)
def _create_ucsm_host_to_service_profile_mapping(self): """Reads list of Service profiles and finds associated Server.""" ucsm_ips = list(CONF.ml2_cisco_ucsm.ucsms) for ucsm_ip in ucsm_ips: with self.ucsm_connect_disconnect(ucsm_ip) as handle: try: sp_list_temp = handle.ConfigResolveClass( 'lsServer', None, inHierarchical=False) if sp_list_temp and sp_list_temp.OutConfigs is not None: sp_list = sp_list_temp.OutConfigs.GetChild() or [] for sp in sp_list: if sp.PnDn: server_name = self._get_server_name( handle, sp, ucsm_ip) if (server_name and not sp.OperSrcTemplName): LOG.debug( 'Server %s info retrieved ' 'from UCSM %s', server_name, ucsm_ip) key = (ucsm_ip, server_name) self.ucsm_sp_dict[key] = str(sp.Dn) self.ucsm_host_dict[server_name] = ucsm_ip except Exception as e: # Raise a Neutron exception. Include a description of # the original exception. raise cexc.UcsmConfigReadFailed(ucsm_ip=ucsm_ip, exc=e)
def _create_ucsm_host_to_service_profile_mapping(self): """Reads list of Service profiles and finds associated Server.""" # Get list of UCSMs without host list given in the config ucsm_ips = [ ip for ip, ucsm in CONF.ml2_cisco_ucsm.ucsms.items() if not ucsm.ucsm_host_list ] for ucsm_ip in ucsm_ips: with self.ucsm_connect_disconnect(ucsm_ip) as handle: try: sp_list = handle.query_classid('lsServer') if sp_list is not None: for sp in sp_list: if sp.pn_dn: server_name = handle.query_dn(sp.pn_dn).name if (server_name and not sp.oper_src_templ_name): LOG.debug( 'Server %s info retrieved ' 'from UCSM %s', server_name, ucsm_ip) key = (ucsm_ip, server_name) self.ucsm_sp_dict[key] = str(sp.dn) self.ucsm_host_dict[server_name] = ucsm_ip except Exception as e: # Raise a Neutron exception. Include a description of # the original exception. raise cexc.UcsmConfigReadFailed(ucsm_ip=ucsm_ip, exc=e)
def _get_server_name(self, handle, service_profile_mo, ucsm_ip): """Get the contents of the 'Name' field associated with UCS Server. When a valid connection hande to UCS Manager is handed in, the Name field associated with a UCS Server is returned. """ try: resolved_dest = handle.ConfigResolveDn(service_profile_mo.PnDn) server_list = resolved_dest.OutConfig.GetChild() if not server_list: return "" return server_list[0].Name except Exception as e: # Raise a Neutron exception. Include a description of # the original exception. raise cexc.UcsmConfigReadFailed(ucsm_ip=ucsm_ip, exc=e)