Example #1
0
	def start(self, namespace, application):
		from upscale.master.balancer import get_containers

		print namespace, application,
		(hosts, containers) = get_containers()

		# also weighted hosts, so one in static host, one on spot instance
		min_host = None
		for host in containers:
			if (not min_host or len(containers[host])<len(containers[min_host])):
				# check if it already contains project
				min_host_applications = set([(b.split('_')[0], b.split('_')[1]) for b in containers[host] if len(b.split('_'))==3])
				if ((namespace, application) in min_host_applications):
					continue

				min_host=host

		if not min_host:
			raise Exception('No host available')

		print 'Starting on host {0}.'.format(min_host)
		# start container on min host
		# check minhost
		with Worker("tcp://{0}:10000/".format(hosts[min_host])) as h:
			#h.start(namespace, application).get(timeout=5)
			print ('Starting new container')
			h.start(namespace, application)

		self.reload_all()

		# health checks, does namespace, application exist
		#enqueue(wrapper, )
		return (True)
Example #2
0
	def destroy(self, namespace, website):
		# get all containers for project and destroy them
		print namespace, application,
		(hosts, containers) = get_containers()
		for host in containers:
			for container in containers[host]:
				pass
Example #3
0
 def destroy(self, namespace, website):
     # get all containers for project and destroy them
     print namespace, application,
     (hosts, containers) = get_containers()
     for host in containers:
         for container in containers[host]:
             pass
Example #4
0
    def start(self, namespace, application):
        from upscale.master.balancer import get_containers

        print namespace, application,
        (hosts, containers) = get_containers()

        # also weighted hosts, so one in static host, one on spot instance
        min_host = None
        for host in containers:
            if (not min_host
                    or len(containers[host]) < len(containers[min_host])):
                # check if it already contains project
                min_host_applications = set([(b.split('_')[0], b.split('_')[1])
                                             for b in containers[host]
                                             if len(b.split('_')) == 3])
                if ((namespace, application) in min_host_applications):
                    continue

                min_host = host

        if not min_host:
            raise Exception('No host available')

        print 'Starting on host {0}.'.format(min_host)
        # start container on min host
        # check minhost
        with Worker("tcp://{0}:10000/".format(hosts[min_host])) as h:
            #h.start(namespace, application).get(timeout=5)
            print('Starting new container')
            h.start(namespace, application)

        self.reload_all()

        # health checks, does namespace, application exist
        #enqueue(wrapper, )
        return (True)