def process_hypervisors(self, switch_port): """ Searching for the switch ports, where one physical and many VPS servers. If hypervisor found on port, then set its role and link VPS servers. :param switch_port: :param dry_run: If True, then role is set for guessed hypervisor (when 1 physical + many VMs). :return: """ assert switch_port assert isinstance(switch_port, SwitchPort) result, pysical_srv, virtual_srv = CmdbAnalyzer.guess_hypervisor(switch_port) if result: logger.info("Found hypervisor: %s" % pysical_srv) pysical_srv.set_option('role', 'hypervisor') for virtual_server in virtual_srv: virtual_server.parent = pysical_srv virtual_server.save() logger.info(" virtual server %s is auto-linked to it" % virtual_server) else: logger.info("Switch port: %s" % switch_port) logger.info(" physicals: %s, virtuals: %s." % (len(pysical_srv), len(virtual_srv))) logger.info("Physical servers:") for server in pysical_srv: logger.info(unicode(server)) logger.info("Virtual servers:") for vserver in virtual_srv: logger.info(unicode(vserver))
def process_hypervisors(self, switch_port): """ Searching for the switch ports, where one physical and many VPS servers. If hypervisor found on port, then set its role and link VPS servers. :param switch_port: :param dry_run: If True, then role is set for guessed hypervisor (when 1 physical + many VMs). :return: """ assert switch_port assert isinstance(switch_port, SwitchPort) result, pysical_srv, virtual_srv = CmdbAnalyzer.guess_hypervisor( switch_port) if result: logger.info("Found hypervisor: %s" % pysical_srv) pysical_srv.set_option('role', 'hypervisor') for virtual_server in virtual_srv: virtual_server.parent = pysical_srv virtual_server.save() logger.info(" virtual server %s is auto-linked to it" % virtual_server) else: logger.info("Switch port: %s" % switch_port) logger.info(" physicals: %s, virtuals: %s." % (len(pysical_srv), len(virtual_srv))) logger.info("Physical servers:") for server in pysical_srv: logger.info(unicode(server)) logger.info("Virtual servers:") for vserver in virtual_srv: logger.info(unicode(vserver))
def _guess_hypervisor(self, switch_port, dry_run=False): """ Поиск портов, на которых 1 физический сервер и несколько виртуальных. Определяем его как потенциальный гипервизор. :param switch_port: :param dry_run: If True, then role is set for guessed hypervisor (when 1 physical + many VMs). :return: """ assert switch_port assert isinstance(switch_port, SwitchPort) result, pysical_srv, virtual_srv = CmdbAnalyzer.guess_hypervisor(switch_port) if result: logger.info("Found hypervisor: %s" % pysical_srv) if not dry_run: pysical_srv.set_option('role', 'hypervisor') for virtual_server in virtual_srv: virtual_server.parent = pysical_srv virtual_server.save() logger.warning(" role automatically set, virtual servers are linked to the hypervisor.") else: logger.info("Switch port: %s" % switch_port) logger.info(" physicals: %s, virtuals: %s." % (len(pysical_srv), len(virtual_srv))) logger.info("Physical servers:") for server in pysical_srv: logger.info(unicode(server)) logger.info("Virtual servers:") for vserver in virtual_srv: logger.info(unicode(vserver))
def _guess_hypervisor(self, switch_port, dry_run=False): """ Поиск портов, на которых 1 физический сервер и несколько виртуальных. Определяем его как потенциальный гипервизор. :param switch_port: :param dry_run: If True, then role is set for guessed hypervisor (when 1 physical + many VMs). :return: """ assert switch_port assert isinstance(switch_port, SwitchPort) result, pysical_srv, virtual_srv = CmdbAnalyzer.guess_hypervisor( switch_port) if result: logger.info("Found hypervisor: %s" % pysical_srv) if not dry_run: pysical_srv.set_option('role', 'hypervisor') for virtual_server in virtual_srv: virtual_server.parent = pysical_srv virtual_server.save() logger.warning( " role automatically set, virtual servers are linked to the hypervisor." ) else: logger.info("Switch port: %s" % switch_port) logger.info(" physicals: %s, virtuals: %s." % (len(pysical_srv), len(virtual_srv))) logger.info("Physical servers:") for server in pysical_srv: logger.info(unicode(server)) logger.info("Virtual servers:") for vserver in virtual_srv: logger.info(unicode(vserver))