def configure_topology(self):
        for si in self.topology.service_instances:
            si.adapter_instance = FactoryServiceAdapter.get_agent(si.service_type, si.adapter)
            for unit in si.units:
                try:
                    config = {}
                    config['hostname'] = unit.hostname
                    config['ips'] = unit.ips
                    config['floating_ips'] = unit.floating_ips
                    config['hostname'] = unit.hostname
                except:
                    logging.debug("there was an issue getting the config for the vnf")

                try:
                    logging.info("sending requests to the adapter %s with config" % config)
                    si.adapter_instance.preinit(config)
                    si.adapter_instance.install(config)
                except Exception,e:
                    logging.error("error while configuring vnf %s" % e)

                # add relations
                for ext_service in si.relation:
                    service_list = self.db.get_by_name(ServiceInstance, ext_service.name)
                    if len(service_list) == 1:
                        ext_si = service_list[0]
                        for ext_unit in ext_si.units:
                            logging.info("sending request add_dependency to the adapter %s with config %s and ext_unit %s" % (si.service_type, config, ext_unit))
                            si.adapter_instance.add_dependency(config, ext_unit, ext_si)
                try:
                    # TODO add add_relation methods
                    si.adapter_instance.pre_start(config)
                    si.adapter_instance.start(config)
                except Exception,e:
                    logging.error("error while configuring vnf %s" % e)
 def remove_relations_after_scaling(self, unit):
     logging.info("removing relations after scaling %s" % self.service_instance.name)
     config = {}
     config["hostname"] = unit.hostname
     config["ips"] = unit.ips
     config["zabbix_ip"] = os.environ["ZABBIX_IP"]
     config["floating_ips"] = unit.floating_ips
     config["hostname"] = unit.hostname
     for ext_service in self.service_instance.relation:
         if ext_service.name == "dns" and self.is_dnsaas is True:
             self.dns_configurator.remove_record_hss(unit.ips["mgmt"], unit.hostname)
         else:
             service_list = self.db.get_by_name(ServiceInstance, ext_service.name)
             if len(service_list) == 1:
                 ext_si = service_list[0]
                 for ext_unit in ext_si.units:
                     ext_unit_config = {}
                     ext_unit_config["hostname"] = ext_unit.hostname
                     ext_unit_config["ips"] = ext_unit.ips
                     ext_unit_config["zabbix_ip"] = os.environ["ZABBIX_IP"]
                     ext_unit_config["floating_ips"] = ext_unit.floating_ips
                     ext_unit_config["hostname"] = ext_unit.hostname
                     self.service_instance.adapter_instance.remove_dependency(unit, ext_unit, ext_si)
                     ext_si.adapter_instance = FactoryServiceAdapter.get_agent(ext_si.service_type, ext_si.adapter)
                     ext_si.adapter_instance.remove_dependency(ext_unit_config, unit, self.service_instance)
 def add_relations_after_scaling(self, config, unit):
     logger.info("adding relations after scaling %s" % self.service_instance.name)
     for ext_service in self.service_instance.relation:
         logger.debug(
             "solving dependencies between si %s and external service %s"
             % (self.service_instance.name, ext_service.name)
         )
         if ext_service.name == "dns" and self.is_dnsaas is True:
             ext_unit = Unit(hostname=None, state="INITIALISING")
             ext_si = ServiceInstance(
                 name="dns", service_type="dns", state="INITIALISING", image="test", flavor="test", size={}
             )
             ext_unit.ips["mgmt"] = os.environ["DNSAAS_IP"]
             self.dns_configurator.configure_dns_entry(self.service_instance.service_type)(
                 unit.ips["mgmt"], unit.hostname
             )
             self.service_instance.adapter_instance.add_dependency(config, ext_unit, ext_si)
         else:
             service_list = self.db.get_by_name(ServiceInstance, ext_service.name)
             if len(service_list) == 1:
                 ext_si = service_list[0]
                 for ext_unit in ext_si.units:
                     ext_unit_config = {}
                     ext_unit_config["hostname"] = ext_unit.hostname
                     ext_unit_config["ips"] = ext_unit.ips
                     ext_unit_config["zabbix_ip"] = os.environ["ZABBIX_IP"]
                     ext_unit_config["floating_ips"] = ext_unit.floating_ips
                     ext_unit_config["hostname"] = ext_unit.hostname
                     logging.info(
                         "sending request add_dependency to the adapter %s with config %s and ext_unit %s"
                         % (self.service_instance.service_type, config, ext_unit)
                     )
                     self.service_instance.adapter_instance.add_dependency(config, ext_unit, ext_si)
                     ext_si.adapter_instance = FactoryServiceAdapter.get_agent(ext_si.service_type, ext_si.adapter)
                     ext_si.adapter_instance.add_dependency(ext_unit_config, unit, self.service_instance)
    def configure_topology(self):
        for si in self.topology.service_instances:
            si.adapter_instance = FactoryServiceAdapter.get_agent(si.service_type, si.adapter)
            for unit in si.units:
                try:
                    config = {}
                    config["hostname"] = unit.hostname
                    config["ips"] = unit.ips
                    config["zabbix_ip"] = os.environ["ZABBIX_IP"]
                    config["floating_ips"] = unit.floating_ips
                    config["hostname"] = unit.hostname
                except:
                    logging.error("there was an issue getting the config for the vnf")

                try:
                    logging.info("sending requests to the adapter %s with config" % config)
                    si.adapter_instance.preinit(config)
                    si.adapter_instance.install(config)
                except Exception, e:
                    logging.error("error while configuring vnf %s" % e)

                # add relations
                for ext_service in si.relation:
                    logger.info(
                        "solving dependencies between si %s and external service %s" % (si.name, ext_service.name)
                    )
                    if ext_service.name == "dns" and self.is_dnsaas is True:
                        ext_unit = Unit(hostname=None, state="INITIALISING")
                        ext_si = ServiceInstance(
                            name="dns", service_type="dns", state="INITIALISING", image="test", flavor="test", size={}
                        )
                        ext_unit.ips["mgmt"] = os.environ["DNSAAS_IP"]
                        self.dns_configurator.configure_dns_entry(si.service_type)(unit.ips["mgmt"], unit.hostname)
                        si.adapter_instance.add_dependency(config, ext_unit, ext_si)
                    else:
                        service_list = self.db.get_by_name(ServiceInstance, ext_service.name)
                        if len(service_list) == 1:
                            ext_si = service_list[0]
                            for ext_unit in ext_si.units:
                                logging.info(
                                    "sending request add_dependency to the adapter %s with config %s and ext_unit %s"
                                    % (si.service_type, config, ext_unit)
                                )
                                si.adapter_instance.add_dependency(config, ext_unit, ext_si)
                try:
                    si.adapter_instance.pre_start(config)
                    si.adapter_instance.start(config)
                except Exception, e:
                    logging.error("error while configuring vnf %s" % e)
Exemple #5
0
    def configure_topology(self):
        for si in self.topology.service_instances:
            si.adapter_instance = FactoryServiceAdapter.get_agent(
                si.service_type, si.adapter)
            for unit in si.units:
                try:
                    config = {}
                    config['hostname'] = unit.hostname
                    config['ips'] = unit.ips
                    config['floating_ips'] = unit.floating_ips
                    config['hostname'] = unit.hostname
                except:
                    logging.debug(
                        "there was an issue getting the config for the vnf")

                try:
                    logging.info(
                        "sending requests to the adapter %s with config" %
                        config)
                    si.adapter_instance.preinit(config)
                    si.adapter_instance.install(config)
                except Exception, e:
                    logging.error("error while configuring vnf %s" % e)

                # add relations
                for ext_service in si.relation:
                    service_list = self.db.get_by_name(ServiceInstance,
                                                       ext_service.name)
                    if len(service_list) == 1:
                        ext_si = service_list[0]
                        for ext_unit in ext_si.units:
                            logging.info(
                                "sending request add_dependency to the adapter %s with config %s and ext_unit %s"
                                % (si.service_type, config, ext_unit))
                            si.adapter_instance.add_dependency(
                                config, ext_unit, ext_si)
                try:
                    # TODO add add_relation methods
                    si.adapter_instance.pre_start(config)
                    si.adapter_instance.start(config)
                except Exception, e:
                    logging.error("error while configuring vnf %s" % e)