Beispiel #1
0
    def _do_migrate_nodes(self, migration_plan, delay):
        self.logger.info("Migration: starting with plan %s and delay %s."
                         % (migration_plan, delay))
        # TODO: use instead collections.Counter with Python 2.7
        clouds = [dest_cloud for (_node, dest_cloud) in migration_plan]
        new_vm_nb = collections.defaultdict(int)
        for cloud in clouds:
            new_vm_nb[cloud] += 1
        try:
            new_nodes = []
            # TODO: make it parallel
            for cloud, count in new_vm_nb.iteritems():
                self.controller.add_context_replacement(dict(mysql_username='******',
                                                             mysql_password=self.root_pass),
                                                        cloud=cloud)

                new_nodes.extend(self.controller.create_nodes(count,
                                                              agent.check_agent_process,
                                                              self.config.AGENT_PORT,
                                                              cloud))
                self._start_mysqld(new_nodes, cloud)
                self.config.addMySQLServiceNodes(new_nodes)
        except Exception, ex:
            # error happened: rolling back...
            for node in new_nodes:
                agent.stop(node.ip, self.config.AGENT_PORT)
            self.controller.delete_nodes(new_nodes)
            self.config.remove_nodes(new_nodes)
            self.logger.exception('_do_migrate_nodes: Could not'
                                  ' start nodes: %s' % ex)
            self.state_set(self.S_RUNNING)
            raise ex
Beispiel #2
0
 def _do_migrate_finalize(self, old_nodes):
     self.state_set(self.S_ADAPTING)
     for node in old_nodes:
         agent.stop(node.ip, self.config.AGENT_PORT)
     self.controller.delete_nodes(old_nodes)
     self.config.remove_nodes(old_nodes)
     self.state_set(self.S_RUNNING)
     self.logger.info("Migration: old nodes %s have been removed."
                      " END of migration." % old_nodes)
Beispiel #3
0
 def _do_remove_nodes(self, rm_reg_nodes, rm_glb_nodes):
     glb_nodes = self.config.get_glb_nodes()
     nodesIp = ["%s:%s" % (node.ip, self.config.MYSQL_PORT)  # FIXME: find real mysql port instead of default 3306
                      for node in rm_reg_nodes]
     for glb in glb_nodes:
             agent.remove_glbd_nodes(glb.ip, self.config.AGENT_PORT, nodesIp)
     nodes = rm_reg_nodes + rm_glb_nodes
     for node in nodes:
         agent.stop(node.ip, self.config.AGENT_PORT)
     self.config.remove_nodes(nodes)
     if (len(self.config.get_nodes()) +len(self.config.get_glb_nodes())==0 ):
         self.state_set(self.S_STOPPED)
     else:
         self.state_set(self.S_RUNNING)
     return nodes