コード例 #1
0
ファイル: Checker.py プロジェクト: MobileCloudNetworking/maas
 def check(action=None, alarm=None, flavor=None, image=None, key=None, network=None, policy=None, security_group=None,
           service=None, service_instance=None, service_type=None, topology=None, unit=None):
     try:
         if action:
             checkAction(action)
         if alarm:
             checkAlarm(alarm)
         if flavor:
             checkFlavor(flavor)
         if image:
             checkImage(image)
         if key:
             checkKey(key)
         if network:
             checkNetwork(network)
         if policy:
             checkPolicy(policy)
         if security_group:
             checkSecurityGroupUniqueness(security_group)
             checkSecurityGroup(security_group)
         if service:
             checkServiceUniqueness(service)
             checkService(service)
         if service_instance:
             checkServiceInstance(service_instance)
         if service_type:
             checkServiceType(service_type)
         if topology:
             checkTopolgoyUniqueness(topology)
             checkTopology(topology)
         if unit:
             checkUnit(unit)
     except Exception, exc:
         LOG.exception(exc)
         raise
コード例 #2
0
 def update_unit_state(self, unit, resource_details=None):
     if not resource_details:
         try:
             resource_details = self.heatclient.list_resources(self.topology.ext_id)
             LOG.debug('Resource details of %s: %s' % (self.topology.ext_name, resource_details))
         except HTTPNotFound, exc:
             self.topology.state='DELETED'
             return
         except Exception, exc:
             LOG.exception(exc)
             self.topology.state='ERROR'
コード例 #3
0
 def get_agent(module, cl, **kwargs):
     _package = "adapters"
     _module = module
     _class = cl
     LOG.debug("Instantiating %s from %s.%s"%(_class, _package,_module))
     try:
         _loaded_module = __import__(name='%s.%s' % (_package,_module), fromlist=[_module])
     except ImportError, exc:
         exc.message = 'FactoryServiceAdapter -> %s' % exc.message
         LOG.exception(exc)
         raise ImportError(exc.message)
コード例 #4
0
 def get_agent(agent, **kwargs):
     defs = agent.split('.')
     if len(defs) == 3:
         _package, _module, _class = defs
     else:
         raise ImportError('Wrong definition of the Class. Use \"package.module.class\".')
     try:
         _loaded_module = __import__(name='%s.%s' % (_package,_module), fromlist=[_module])
     except ImportError, exc:
         exc.message = 'FactoryAgent -> %s' % exc.message
         LOG.exception(exc)
         raise ImportError(exc.message)
コード例 #5
0
 def create(cls, topology_args):
     conf = sys_util().get_sys_conf()
     db = FactoryAgent().get_agent(conf['database_manager'])
     topology_manager = FactoryAgent().get_agent(conf['topology_manager'])
     try:
         topology = topology_manager.create(topology_args)
         checker = FactoryAgent().get_agent(conf['checker'])
         checker.check(topology=topology)
         db.persist(topology)
     except Exception, exc:
         LOG.exception(exc.message)
         raise
コード例 #6
0
ファイル: RuntimeAgent.py プロジェクト: Cloudxtreme/maas
 def update_unit_state(self, unit, resource_details=None):
     if not resource_details:
         try:
             resource_details = self.heatclient.list_resources(
                 self.topology.ext_id)
             LOG.debug('Resource details of %s: %s' %
                       (self.topology.ext_name, resource_details))
         except HTTPNotFound, exc:
             self.topology.state = 'DELETED'
             return
         except Exception, exc:
             LOG.exception(exc)
             self.topology.state = 'ERROR'
コード例 #7
0
 def get_agent(agent, **kwargs):
     defs = agent.split('.')
     if len(defs) == 3:
         _package, _module, _class = defs
     else:
         raise ImportError(
             'Wrong definition of the Class. Use \"package.module.class\".')
     try:
         _loaded_module = __import__(name='%s.%s' % (_package, _module),
                                     fromlist=[_module])
     except ImportError, exc:
         exc.message = 'FactoryAgent -> %s' % exc.message
         LOG.exception(exc)
         raise ImportError(exc.message)
コード例 #8
0
 def update_topology_state(self):
     #get stack details and set the topology state
     try:
         stack_details = self.heatclient.show(stack_id=self.topology.ext_id)
         LOG.debug('Stack details of %s: %s' % (self.topology.ext_name, stack_details))
         old_state = self.topology.state
         old_detailed_state = self.topology.detailed_state
         if stack_details:
             self.topology.state = translate(stack_details.get('stack_status'), HEAT_TO_EMM_STATE)
             self.topology.detailed_state = stack_details.get('stack_status_reason')
         if old_state != self.topology.state or old_detailed_state != self.topology.detailed_state:
             self.db.update(self.topology)
     except Exception, exc:
         LOG.exception(exc)
         self.topology.state='ERROR'
         raise
コード例 #9
0
ファイル: Checker.py プロジェクト: Cloudxtreme/maas
 def check(action=None,
           alarm=None,
           flavor=None,
           image=None,
           key=None,
           network=None,
           policy=None,
           security_group=None,
           service=None,
           service_instance=None,
           service_type=None,
           topology=None,
           unit=None):
     try:
         if action:
             checkAction(action)
         if alarm:
             checkAlarm(alarm)
         if flavor:
             checkFlavor(flavor)
         if image:
             checkImage(image)
         if key:
             checkKey(key)
         if network:
             checkNetwork(network)
         if policy:
             checkPolicy(policy)
         if security_group:
             checkSecurityGroupUniqueness(security_group)
             checkSecurityGroup(security_group)
         if service:
             checkServiceUniqueness(service)
             checkService(service)
         if service_instance:
             checkServiceInstance(service_instance)
         if service_type:
             checkServiceType(service_type)
         if topology:
             checkTopolgoyUniqueness(topology)
             checkTopology(topology)
         if unit:
             checkUnit(unit)
     except Exception, exc:
         LOG.exception(exc)
         raise
コード例 #10
0
ファイル: RuntimeAgent.py プロジェクト: Cloudxtreme/maas
 def update_topology_state(self):
     #get stack details and set the topology state
     try:
         stack_details = self.heatclient.show(stack_id=self.topology.ext_id)
         LOG.debug('Stack details of %s: %s' %
                   (self.topology.ext_name, stack_details))
         old_state = self.topology.state
         old_detailed_state = self.topology.detailed_state
         if stack_details:
             self.topology.state = translate(
                 stack_details.get('stack_status'), HEAT_TO_EMM_STATE)
             self.topology.detailed_state = stack_details.get(
                 'stack_status_reason')
         if old_state != self.topology.state or old_detailed_state != self.topology.detailed_state:
             self.db.update(self.topology)
     except Exception, exc:
         LOG.exception(exc)
         self.topology.state = 'ERROR'
         raise
コード例 #11
0
 def deploy(self, topology):
     #deploy only when the ext_id is None otherwise the topology is already deployed
     if topology.ext_id is None:
         LOG.debug("Start Deploying topology %s" % topology.name)
         _name = topology.ext_name
         _template = self.template_manager.get_template(topology)
         LOG.debug("Stack name: %s" % _name)
         LOG.debug("Template: %s" % _template)
         try:
             stack_details = self.heatclient.deploy(name=_name, template=_template)
             LOG.debug("stack details after deploy: %s" % stack_details)
             if stack_details:
                 topology.ext_id = stack_details['stack'].get('id')
                 LOG.debug("stack id: %s" % topology.ext_id)
             else:
                 raise Exception('Error during deployment on the testbed.')
         except Exception, exc:
             LOG.exception(exc)
             topology.state = 'ERROR'
             topology.ext_id = None
             raise
コード例 #12
0
    def update(cls, new_topology_args, old_topology):
        conf = sys_util().get_sys_conf()
        db = FactoryAgent().get_agent(conf['database_manager'])
        topology_manager = FactoryAgent().get_agent(conf['topology_manager'])
        checker = FactoryAgent().get_agent(conf['checker'])

        if old_topology.state in ['DEPLOYED','UPDATED']:
            old_topology.state = 'UPDATING'
        else:
            raise ActionInProgressException('Cannot update topology while another action is in progress. Topology state is \"%s\".' % old_topology.state)
        db.update(old_topology)

        try:
            new_topology = topology_manager.create(new_topology_args)
            checker.check(topology=new_topology)
            updated_topology = topology_manager.update(new_topology, old_topology)
            #checker.check(topology=updated_topology)
            db.update(updated_topology)
        except Exception, exc:
            LOG.exception(exc.message)
            raise exc
コード例 #13
0
 def deploy(self, topology):
     #deploy only when the ext_id is None otherwise the topology is already deployed
     if topology.ext_id is None:
         LOG.debug("Start Deploying topology %s" % topology.name)
         _name = topology.ext_name
         _template = self.template_manager.get_template(topology)
         LOG.debug("Stack name: %s" % _name)
         LOG.debug("Template: %s" % _template)
         try:
             stack_details = self.heatclient.deploy(name=_name,
                                                    template=_template)
             LOG.debug("stack details after deploy: %s" % stack_details)
             if stack_details:
                 topology.ext_id = stack_details['stack'].get('id')
                 LOG.debug("stack id: %s" % topology.ext_id)
             else:
                 raise Exception('Error during deployment on the testbed.')
         except Exception, exc:
             LOG.exception(exc)
             topology.state = 'ERROR'
             topology.ext_id = None
             raise
コード例 #14
0
ファイル: RuntimeAgent.py プロジェクト: Cloudxtreme/maas
        except Exception, exc:
            LOG.exception(exc)
            self.topology.state = 'ERROR'
            raise

        #Get details of resources and update state for each of them
        try:
            resource_details = self.heatclient.list_resources(
                self.topology.ext_id)
            LOG.debug('Resource details of %s: %s' %
                      (self.topology.ext_name, resource_details))
        except HTTPNotFound, exc:
            self.topology.state = 'DELETED'
            return
        except Exception, exc:
            LOG.exception(exc)
            self.topology.state = 'ERROR'

        #Update all service instance state down to all units
        for service_instance in self.topology.service_instances:
            self.update_service_instance_state(
                service_instance=service_instance,
                resource_details=resource_details)

        #Check topology state again and check also all service instances
        all_completed = False
        if self.topology.state in ['DEPLOYED', 'UPDATED']:
            topology_completed = True
        else:
            topology_completed = False
        #Assume that the topology deployment is completed
コード例 #15
0
            if old_state != self.topology.state or old_detailed_state != self.topology.detailed_state:
                self.db.update(self.topology)
        except Exception, exc:
            LOG.exception(exc)
            self.topology.state='ERROR'
            raise

        #Get details of resources and update state for each of them
        try:
            resource_details = self.heatclient.list_resources(self.topology.ext_id)
            LOG.debug('Resource details of %s: %s' % (self.topology.ext_name, resource_details))
        except HTTPNotFound, exc:
            self.topology.state='DELETED'
            return
        except Exception, exc:
            LOG.exception(exc)
            self.topology.state='ERROR'

        #Update all service instance state down to all units
        for service_instance in self.topology.service_instances:
            self.update_service_instance_state(service_instance=service_instance, resource_details=resource_details)

        #Check topology state again and check also all service instances
        all_completed = False
        if self.topology.state in ['DEPLOYED', 'UPDATED']:
            topology_completed = True
        else:
            topology_completed = False
        #Assume that the topology deployment is completed
        all_completed = topology_completed
        #Check if there are any errors downstairs
コード例 #16
0
            #update existing quotas
            for quotas in all_quotas:
                if new_quotas.tenant_id in all_quotas_tenants:
                    new_quotas.id = quotas.id
                    quotas = new_quotas
                    db.update(quotas)
                else:
                    try:
                        db.persist(new_quotas)
                    except IntegrityError, exc:
                        LOG.warning(
                            'Network \"%s\" are already persisted on the Database. Trigger update.'
                            % get_quotas())
                        db.update(get_quotas())
        except Exception, exc:
            LOG.exception(exc.message)
            raise

        # for port in get_ports():
        # db.persist(port)

        self.print_logo()

    def get_sys_conf(self):
        props = {}
        self._read_properties(props)
        return props


def get_networks():
    nc = NeutronClient(
コード例 #17
0
ファイル: SysUtil.py プロジェクト: MobileCloudNetworking/maas
            all_quotas_tenants = [quotas.tenant_id for quotas in all_quotas]
            new_quotas = get_quotas()
            #update existing quotas
            for quotas in all_quotas:
                if new_quotas.tenant_id in all_quotas_tenants:
                    new_quotas.id = quotas.id
                    quotas = new_quotas
                    db.update(quotas)
                else:
                    try:
                        db.persist(new_quotas)
                    except IntegrityError, exc:
                        LOG.warning('Network \"%s\" are already persisted on the Database. Trigger update.' % get_quotas())
                        db.update(get_quotas())
        except Exception, exc:
            LOG.exception(exc.message)
            raise

        # for port in get_ports():
        # db.persist(port)

        self.print_logo()

    def get_sys_conf(self):
        props = {}
        self._read_properties(props)
        return props


def get_networks():
    nc = NeutronClient(get_endpoint('network', region_name=sys_config.props['os_region_name']), get_token())