Ejemplo n.º 1
0
 def run(self):
     while not self.is_stopped:
         self.update_topology_state()
         if self.topology.state == "DELETED":
             TopologyOrchestrator.delete(self.topology)
             self.is_stopped = True
         for si in self.topology.service_instances:
             if not self.is_stopped:
                 for unit in si.units:
                     if len(unit.ports) == 0:
                         self.set_ips(unit)
         time.sleep(30)
Ejemplo n.º 2
0
 def dispose(self):
     """
     Dispose method
     """
     LOG.info("deleting topology with id %s " % self.stack_id)
     if self.stack_id is not None:
         topology = TopologyOrchestrator.get(self.stack_id)
         LOG.debug("topology to be deleted %s " % topology)
         self.deployer.dispose(topology)
         TopologyOrchestrator.delete(topology)
         self.stack_id = None
         if self.maas is not None:
             util.dispose_maas(self.token, self.maas)
Ejemplo n.º 3
0
 def dispose(self):
     """
     Dispose method
     """
     LOG.info("deleting topology with id %s " % self.stack_id)
     if self.stack_id is not None:
         topology = TopologyOrchestrator.get(self.stack_id)
         LOG.debug("topology to be deleted %s " % topology)
         self.deployer.dispose(topology)
         TopologyOrchestrator.delete(topology)
         self.stack_id = None
         if self.maas is not None:
             util.dispose_maas(self.token, self.maas)
Ejemplo n.º 4
0
 def run(self):
     while not self.is_stopped:
         self.update_topology_state()
         if self.topology.state == 'DELETED':
             TopologyOrchestrator.delete(self.topology)
             self.is_stopped = True
         for si in self.topology.service_instances:
             if not self.is_stopped:
                 for unit in si.units:
                     if len(unit.ports) == 0:
                         self.set_ips(unit)
         if self.topology.state == 'DEPLOYED' and not self.is_dns_configured:
             #self.configure_dns()
             self.configure_topology()
             self.is_dns_configured = True
         time.sleep(30)
Ejemplo n.º 5
0
 def run(self):
     while not self.is_stopped:
         self.update_topology_state()
         if self.topology.state == 'DELETED':
             TopologyOrchestrator.delete(self.topology)
             self.is_stopped = True
         for si in self.topology.service_instances:
             if not self.is_stopped:
                 for unit in si.units:
                     if len(unit.ports) == 0:
                         self.set_ips(unit)
         if self.topology.state == 'DEPLOYED' and not self.is_dns_configured:
             #self.configure_dns()
             self.configure_topology()
             self.is_dns_configured = True
         time.sleep(30)
Ejemplo n.º 6
0
    def state(self):
        """
        Report on state.
        """
        LOG.info("retrieving state of the running stack with id %s" %
                 self.stack_id)
        # LOG.info('Resolver state:')
        # LOG.info(resolver_state.__repr__())
        if self.stack_id is not None:
            topology = TopologyOrchestrator.get(self.stack_id)
            stk = self.deployer.details(topology.ext_id)
            res = {
                'state': stk['stack_status'],
                'name': stk['stack_name'],
                'id': stk['id']
            }
            if 'outputs' in stk:
                res['output'] = stk['outputs']
            output = ''
            try:
                output = res['output']
            except KeyError:
                pass

            LOG.debug(" state %s, output %s" % (res['state'], output))
            return res['state'], str(self.stack_id), output
        else:
            return 'CREATE_COMPLETE', 'N/A', ''
Ejemplo n.º 7
0
    def state(self):
        """
        Report on state.
        """
        LOG.info("retrieving state of the running stack with id %s" % self.stack_id)
        # LOG.info('Resolver state:')
        # LOG.info(resolver_state.__repr__())
        if self.stack_id is not None:
            topology = TopologyOrchestrator.get(self.stack_id)
            stk = self.deployer.details(topology.ext_id)
            res = {'state': stk['stack_status'],
               'name': stk['stack_name'],
               'id': stk['id']}
            if 'outputs' in stk:
                res['output'] = stk['outputs']
            output = ''
            try:
                output = res['output']
            except KeyError:
                pass

            LOG.debug(" state %s, output %s"%(res['state'],output))
            return res['state'], str(self.stack_id), output
        else:
            return 'CREATE_COMPLETE', 'N/A', ''
Ejemplo n.º 8
0
class SoExecution(service_orchestrator.Execution):
    """
    class docs
    """
    def __init__(self, token, tenant_name):
        """
        Constructor
        """
        super(SoExecution, self).__init__(token, tenant_name)
        # by default
        self.topology_type = "topology-maas-bern.json"
        self.token = token
        self.tenant_name = tenant_name
        self.stack_id = None
        self.maas = None
        self.location = 'bern'
        # make sure we can talk to deployer...
        LOG.debug("sending request to the url %s" % os.environ['DESIGN_URI'])

        self.conf = sys_util().get_sys_conf()
        LOG.debug("instantiating deployer %s" % self.conf['deployer'])
        self.deployer = None

    def deploy(self, attributes):
        """
        Deploy method
        """
        if self.stack_id is not None:
            pass
        parameters = {}
        # defining the location of the topology
        if 'maas.location' in attributes:
            self.location = parameters['location'] = os.environ[
                'location'] = attributes['maas.location']
            LOG.debug("location %s passed via OCCI Attribute" % self.location)

        self.deployer = FactoryAgent().get_agent(self.conf['deployer'])
        self.topology_type = topology_mapping[self.location]
        LOG.info("deploying template %s" % (self.topology_type, ))

        # read template...
        f = open(os.path.join(SO_DIR, 'data/topologies', self.topology_type))
        template = f.read()
        f.close()
        LOG.debug("content of the topology %s" % template)

        # extracting hot template
        try:
            config = yaml.load(template)
            LOG.debug(config)
        except yaml.YAMLError, exc:
            if hasattr(exc, 'problem_mark'):
                mark = exc.problem_mark
                LOG.error("Error in configuration file:", exc)
                LOG.error("Error position: (%s:%s)" %
                          (mark.line + 1, mark.column + 1))
            else:
                LOG.error("Error in configuration file:", exc)

        # creating the topology object
        try:
            topology = TopologyOrchestrator.create(config)
        except NotFoundException, msg:
            LOG.error(msg)
            return