当前位置: 首页>>代码示例>>Python>>正文


Python MarathonClient.delete_app方法代码示例

本文整理汇总了Python中marathon.MarathonClient.delete_app方法的典型用法代码示例。如果您正苦于以下问题:Python MarathonClient.delete_app方法的具体用法?Python MarathonClient.delete_app怎么用?Python MarathonClient.delete_app使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在marathon.MarathonClient的用法示例。


在下文中一共展示了MarathonClient.delete_app方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: rolling_replace_app

# 需要导入模块: from marathon import MarathonClient [as 别名]
# 或者: from marathon.MarathonClient import delete_app [as 别名]
def rolling_replace_app(service_name, app1_id, app2_id, app2_config, labels):
	print '    replacing '+app1_id+' with '+app2_id
	marathon_client = MarathonClient('http://' + str(marathon_host) + ':' + str(marathon_port))
	app1 = marathon_client.get_app(app1_id)
	old_tasks = app1.tasks
	# launcher.launch(group2.service.name, group2.encode_marathon_id, group2.config, instances = 0)
	launcher.launch_app(service_name, app2_id, app2_config, labels, instances = 0 )
	new_app = marathon_client.get_app(app2_id)
	for old_task in old_tasks:
		#
		# replace each old task with a new task of the new app
		#
		num_started = num_started_tasks(app2_id)
		new_instances = num_started+1
		# add 1 instance of new task
		launcher.update_app(app2_id, app2_config, new_instances)
		
		while num_started < new_instances:
			time.sleep(1)
			print 'waiting for app to start '+str(num_started)
			num_started = num_started_tasks(app2_id)
		#
		# take down old task
		#
		marathon_client.kill_task(app1_id, old_task.id, scale=True)
	marathon_client.delete_app(app1_id)
开发者ID:davidbliu,项目名称:theseus,代码行数:28,代码来源:replacer.py

示例2: servermarathon

# 需要导入模块: from marathon import MarathonClient [as 别名]
# 或者: from marathon.MarathonClient import delete_app [as 别名]
def servermarathon():
        APP = os.environ['APPNAME']    
#         STRING = os.environ['STRING']
#         content = STRING
#         contentlist = content.split('&')
#         list = []
#         for i in contentlist:
#             p = i.split('=')
#             p = p[1] 
#             l = list.append(p)
#         (maurl,mau,map) =tuple(list)
#         marathonip = maurl
#         user = mau
#         password = map
        c = MarathonClient(marathonip,username=user,password=password)
        buildFile=open('build.txt','r')
        dockerimage = buildFile.readline()
        buildFile.close()
        readed = json.load(open('temp.json', 'r'))
        readed['container']['docker']['image'] = dockerimage
        readed['id'] = APP
        json.dump(readed, open('app.json', 'w')) 
        
        try:
           c.delete_app(APP,force=True)
           print 'delete'
        except :
            pass
          
        sleep(3)
        u= user+':'+password
        cmd1 = os.system ('curl -u %s -X POST -H "Content-Type: application/json" %s/v2/apps [email protected]' %(u,marathonip))
开发者ID:guirenkeji,项目名称:guirentest,代码行数:34,代码来源:marathonapptask.py

示例3: MarathonDeployer

# 需要导入模块: from marathon import MarathonClient [as 别名]
# 或者: from marathon.MarathonClient import delete_app [as 别名]
class MarathonDeployer(object):


    def __init__(self, marathon_url):
        self.url = marathon_url
        self.client = MarathonClient(self.url)

    def deploy(self, task_chain, environment_name):
        deployed_chain = DeployedTaskChain(task_chain, environment_name)
        for task in deployed_chain.list_all_tasks():
            task_id = task['id']
            safe_name = task_id.lower()
            # safe_name = task['name'].replace('.', '').lower()
            try:
                if self.client.get_app(safe_name):
                    self.client.delete_app(safe_name)
                    time.sleep(2)
            except Exception:
                pass

            app = MarathonApp(cmd='/var/riversnake/invoke.py {0} {1} {2}'.format(
                        task_chain.flow_name,
                        environment_name,
                        task_id),
                    mem=16, cpus=1)

            self.client.create_app(safe_name, app)
开发者ID:jal648,项目名称:riversnake,代码行数:29,代码来源:deploy.py

示例4: send_to_marathon

# 需要导入模块: from marathon import MarathonClient [as 别名]
# 或者: from marathon.MarathonClient import delete_app [as 别名]
def send_to_marathon(request):
    try:
        if request.method == 'POST':
            action = request.POST.get('action', None)
            id = request.POST.get('id', None)
            mc = MarathonClient('http://{}:{}'.format(settings.MARATHON['host'], settings.MARATHON['port']))
            if action == 'stop':
                mc.scale_app(id, 0, force=True)
            elif action == 'start':
                mc.scale_app(id, 1)
            elif action == 'destroy':
                if request.user.has_perm("auth.can_init_app"):
                    mc.delete_app(id)
                else:
                    raise PermissionDenied
            elif action == 'restart':
                mc.restart_app(id)
            elif action == 'scale':
                mc.scale_app(id, int(request.POST.get('number_instance')))
            elif action == 'update':
                app = mc.get_app(id)
                app.cpus = float(request.POST.get('cpus'))
                app.mem = float(request.POST.get('mem'))
                app.container.docker.image = request.POST.get('version')
                mc.update_app(id, app)
            elif action  == "stop-deployment":
                mc.delete_deployment(id)
            result = '{"status":"success", "msg": "%(action)s success"}'%{"action":action}
    except Exception as e:
        result = '{"status":"error", "msg": "%(action)s fail: %(error)s" }'%{"action":action, "error": html.escape(str(e))}
    return HttpResponse(result)
开发者ID:huanpc,项目名称:mesos-admin,代码行数:33,代码来源:views.py

示例5: launch_elsa

# 需要导入模块: from marathon import MarathonClient [as 别名]
# 或者: from marathon.MarathonClient import delete_app [as 别名]
def launch_elsa(marathon, stats_file, scale_window):
    logging.info('Start monitoring the inbound traffic on topics using %s' %(stats_file))
    # make sure the stats file is properly initialized:
    if not os.path.exists(stats_file):
        f = open(stats_file, 'w')
        f.write('0')
        f.close()
    
    # launch the Elsa app via Marathon
    c = MarathonClient(marathon)
    c.create_app('elsa', MarathonApp(cmd='/home/vagrant/elsa/launch-elsa.sh', mem=200, cpus=1, user='vagrant'))
    # c.list_apps()
    
    print('ElSA is deployed and running, waiting now 5 sec before starting auto-scale ...')
    time.sleep(5) # allow time to deploy before autoscaling sets in
    
    # kick off traffic monitoring and trigger autoscaling:
    previous_topic_traffic = 0
    try:
        while True:
            with open(stats_file, 'r') as elsa_file:
                topic_traffic = int(elsa_file.read())
                topic_traffic_diff = topic_traffic - previous_topic_traffic
                print('Difference in traffic in the past %d seconds: %d' %(scale_window, topic_traffic_diff))
                previous_topic_traffic = topic_traffic
            
                current_instance_num = c.get_app('elsa').instances
            
                if topic_traffic_diff > TRAFFIC_INCREASE_THRESHOLD: # we see a surge of traffic above threshold ...
                    instance_multiplier = int(topic_traffic_diff / SCALE_FACTOR) # ... increase number of instances
                    c.scale_app('elsa', current_instance_num * instance_multiplier)
                    print('Increasing number of instances to %d' %(current_instance_num * instance_multiplier))
                elif topic_traffic_diff < 0: # negative, back off exponentially 
                    target_instance_num = int(current_instance_num/2)
                    if target_instance_num > 1:
                        c.scale_app('elsa', target_instance_num)
                        print('Decreasing number of instances to %d' %(target_instance_num))
                    else:
                        c.scale_app('elsa', 1)
                        print('Resetting number of instances to 1')
            time.sleep(scale_window)
    except KeyboardInterrupt:
        print('ElSA has been stopped by user, halting app and rolling back deployment. Thanks and bye!')
        c.delete_app('elsa', force=True)
开发者ID:SemanticBeeng,项目名称:elsa,代码行数:46,代码来源:autoscale.py

示例6: undeploy

# 需要导入模块: from marathon import MarathonClient [as 别名]
# 或者: from marathon.MarathonClient import delete_app [as 别名]
def undeploy(app_name):
    """Calls marathon API to undeploy application

    :param app_name:
    :return:
    """
    marathon_addresses = _addresses()
    cli = MarathonClient(marathon_addresses)
    if _is_deployed(cli, app_name):
        return cli.delete_app(app_name)
    else:
        return None
开发者ID:MavenCode,项目名称:saltstack-formulas,代码行数:14,代码来源:marathon_client.py

示例7: TestCreateApp

# 需要导入模块: from marathon import MarathonClient [as 别名]
# 或者: from marathon.MarathonClient import delete_app [as 别名]
class TestCreateApp(unittest.TestCase):
    """
    Test the creation of a Marathon app against a live endpoint. Configure MARATHON_SERVER in tests.config.
    """

    def setUp(self):
        self._app = get_app()  # Generate a random server configuration.
        self.client = MarathonClient(MARATHON_SERVER)
        self.client.create_app(app_id=self._app.id, app=self._app)
        time.sleep(2)  # Wait two seconds for the POST to be processed by Marathon.
        self.app = self.client.get_app(self._app.id)
        while not self.app.tasks_healthy:  # Wait until the app becomes healthy.
            self.app = self.client.get_app(self._app.id)
            time.sleep(1)

    def test_create(self):
        self.assertIsInstance(self.app, MarathonApp)
        self.assertIsInstance(self.app.upgrade_strategy, MarathonUpgradeStrategy)
        self.assertIsInstance(self.app.tasks.pop(), MarathonTask)
        self.assertIsInstance(self.app.health_checks.pop(), MarathonHealthCheck)

    def tearDown(self):
        self.client.delete_app(self.app.id, force=True)
开发者ID:keshavdv,项目名称:marathon-python,代码行数:25,代码来源:test_create_app.py

示例8: send_to_marathon

# 需要导入模块: from marathon import MarathonClient [as 别名]
# 或者: from marathon.MarathonClient import delete_app [as 别名]
def send_to_marathon(request):
    try:
        if request.method == "POST":
            action = request.POST.get("action", None)
            app_id = request.POST.get("id", None)
            mc = MarathonClient("http://{}:{}".format(settings.MARATHON["host"], settings.MARATHON["port"]))
            if action == "stop":
                mc.scale_app(app_id, 0)
            elif action == "start":
                mc.scale_app(app_id, 1)
            elif action == "destroy":
                mc.delete_app(app_id)
            elif action == "restart":
                pass
            elif action == "scale":
                mc.scale_app(app_id, int(request.POST.get("number_instance")))
            result = '{"status":"success", "msg": "%(action)s success"}' % {"action": action}
    except Exception as e:
        result = '{"status":"error", "msg": "%(action)s fail: %(error)s" }' % {
            "action": action,
            "error": html.escape(str(e)),
        }
    return HttpResponse(result)
开发者ID:ntk148v,项目名称:mesos-admin,代码行数:25,代码来源:views.py

示例9: OptionParser

# 需要导入模块: from marathon import MarathonClient [as 别名]
# 或者: from marathon.MarathonClient import delete_app [as 别名]
import time
from optparse import OptionParser
from marathon import MarathonClient
from marathon.models import MarathonApp

if __name__ == '__main__':
    usage = ('python %prog')
    parser = OptionParser(description='Simple marathon-python based master to launch apps',
                          version="0.1 ", usage=usage)
    (options, args) = parser.parse_args()
    if (len(args) != 0):
        parser.print_help()
        sys.exit(2)


    print "Initiating marathonclient..."
    c = MarathonClient('http://localhost:8080')
    app_cmd = "python /home/abdullah/cosmic-space/test-mesos/py-zmq/sub_client.py --server_ip_ports 10.10.0.2:5556"

    # launch app
    print "Initiating zmq-client app"
    c.create_app('zmq-client', MarathonApp(cmd=app_cmd, mem=16, cpus=0.01))

    # scale
    raw_input("scale_apps upto 400")
    c.scale_app('zmq-client', instances=400)

    # delete
    raw_input("delete apps")
    c.delete_app('zmq-client')
开发者ID:kratos7,项目名称:cosmic-space,代码行数:32,代码来源:marathon_zmq_master.py

示例10: MarathonHTTPClient

# 需要导入模块: from marathon import MarathonClient [as 别名]
# 或者: from marathon.MarathonClient import delete_app [as 别名]
class MarathonHTTPClient(object):

    def __init__(self, target, auth, options, pkey):
        self.target = settings.MARATHON_HOST
        self.auth = auth
        self.options = options
        self.pkey = pkey
        self.registry = settings.REGISTRY_HOST + ':' + settings.REGISTRY_PORT
        self.client = MarathonClient('http://'+self.target+':8180')
        self.fleet = FleetHTTPClient('/var/run/fleet.sock', auth, options, pkey)

    # helpers
    def _app_id(self, name):
        return name.replace('_', '.')

    # container api
    def create(self, name, image, command='', **kwargs):
        """Create a container"""
        app_id = self._app_id(name)
        l = locals().copy()
        l.update(re.match(MATCH, name).groupdict())
        image = self.registry + '/' + image
        mems = kwargs.get('memory', {}).get(l['c_type'])
        m = 0
        if mems:
            mems = mems.lower()
            if mems[-2:-1].isalpha() and mems[-1].isalpha():
                mems = mems[:-1]
            m = int(mems[:-1])
        c = 0.5
        cpu = kwargs.get('cpu', {}).get(l['c_type'])
        if cpu:
            c = cpu
        cmd = "docker run --name {name} -P {image} {command}".format(**locals())
        self.client.create_app(app_id, MarathonApp(cmd=cmd, mem=m, cpus=c))
        self.client.scale_app(app_id, 0, force=True)
        for _ in xrange(POLL_ATTEMPTS):
            if self.client.get_app(self._app_id(name)).tasks_running == 0:
                return
            time.sleep(1)

    def start(self, name):
        """Start a container"""
        self.client.scale_app(self._app_id(name), 1, force=True)
        for _ in xrange(POLL_ATTEMPTS):
            if self.client.get_app(self._app_id(name)).tasks_running == 1:
                break
            time.sleep(1)
        host = self.client.get_app(self._app_id(name)).tasks[0].host
        self._waitforcontainer(host, name)

    def stop(self, name):
        """Stop a container"""
        raise NotImplementedError

    def destroy(self, name):
        """Destroy a container"""
        try:
            host = self.client.get_app(self._app_id(name)).tasks[0].host
            self.client.delete_app(self._app_id(name), force=True)
            self._delete_container(host, name)
        except:
            self.client.delete_app(self._app_id(name), force=True)

    def _get_container_state(self, host, name):
        docker_cli = Client("tcp://{}:2375".format(host), timeout=1200, version='1.17')
        try:
            if docker_cli.inspect_container(name)['State']['Running']:
                return JobState.up
        except:
            return JobState.destroyed

    def _waitforcontainer(self, host, name):
        for _ in xrange(POLL_WAIT):
            if self._get_container_state(host, name) == JobState.up:
                return
            time.sleep(1)
        raise RuntimeError("App container Not Started")

    def _delete_container(self, host, name):
        docker_cli = Client("tcp://{}:2375".format(host), timeout=1200, version='1.17')
        if docker_cli.inspect_container(name)['State']:
            docker_cli.remove_container(name, force=True)

    def run(self, name, image, entrypoint, command):  # noqa
        """Run a one-off command"""
        return self.fleet.run(name, image, entrypoint, command)

    def state(self, name):
        try:
            for _ in xrange(POLL_ATTEMPTS):
                if self.client.get_app(self._app_id(name)).tasks_running == 1:
                    return JobState.up
                elif self.client.get_app(self._app_id(name)).tasks_running == 0:
                    return JobState.created
                time.sleep(1)
        except:
            return JobState.destroyed

    def attach(self, name):
#.........这里部分代码省略.........
开发者ID:Kazanz,项目名称:deis,代码行数:103,代码来源:mesos_marathon.py

示例11: MarathonIF

# 需要导入模块: from marathon import MarathonClient [as 别名]
# 或者: from marathon.MarathonClient import delete_app [as 别名]
class MarathonIF(object):
    def __init__(self, marathon_addr, my_addr, mesos):
        self.mcli = MarathonClient(marathon_addr)
        self.myAddr = my_addr
        self.mesos = mesos

    def get_apps(self):
        listapps = self.mcli.list_apps()
        return listapps

    def get_app(self, app_id):
        try:
            a = self.mcli.get_app(app_id)
        except marathon.exceptions.NotFoundError as e:  # NOQA
            return None
        return a

    def delete_app(self, app_id, force=False):
        return self.mcli.delete_app(app_id, force)

    def delete_deployment(self, dep_id):
        return self.mcli.delete_deployment(dep_id)

    def get_deployments(self):
        return self.mcli.list_deployments()

    def delete_app_ifexisting(self, app_id, trys=4):
        for idx in range(0, trys):
            try:
                a = self.get_app(app_id)
                if a:
                    return self.delete_app(app_id)
                return None
            except:
                e = sys.exc_info()[0]
                pprint("<p>Error: %s</p>" % e)
                time.sleep(10)
        raise

    @staticmethod
    def is_valid_app_id(app_id):
        # allowed: lowercase letters, digits, hyphens, slash, dot
        if re.match("^[A-Za-z0-9-/.]*$", app_id):
            return True
        return False

    def create_app(self, app_id, attr):
        """
            Create and start an app.
            :param app_id: (str) - Application ID
            :param attr: marathon.models.app.MarathonApp application to create.
            :return: the created app
        """
        # Validate that app_id conforms to allowed naming scheme.
        if not self.is_valid_app_id(app_id):
            l.error("Error: Only lowercase letters, digits, hyphens are allowed in app_id. %s" % app_id)
            raise Exception("Invalid app_id")

        for idx in range(0, 10):
            try:
                a = self.mcli.create_app(app_id, attr)
                return a
            except marathon.exceptions.MarathonHttpError as e:
                if str(e).find('App is locked by one or more deployments. Override with the option') >= 0:
                    time.sleep(1)
                else:
                    raise
        raise

    def wait_app_removal(self, app):
        cnt = 0
        while True:
            if not self.get_app(app):
                break
            time.sleep(0.2)
            cnt += 1
            if cnt > 0:
                l.info("Stuck waiting for %s to be deleted CNT=%d" % (app, cnt))
        return True

    def wait_app_ready(self, app, running_count):
        cnt = 0
        while True:
            a1 = self.get_app(app)
            if a1.tasks_running == running_count:
                return a1
            cnt += 1
            time.sleep(1)
            if (cnt % 30) == 29:
                l.info("[%d]Waiting for task to move to running stage, " % cnt +
                       "current stat staged=%d running=%d expected Running=%d" %
                       (a1.tasks_staged, a1.tasks_running, running_count))

    def scale_app(self, app, scale):
        return self.mcli.scale_app(app, scale)

    def ping(self):
        return self.mcli.ping()
开发者ID:annym,项目名称:hydra,代码行数:100,代码来源:mmapi.py

示例12: unlaunch_app

# 需要导入模块: from marathon import MarathonClient [as 别名]
# 或者: from marathon.MarathonClient import delete_app [as 别名]
def unlaunch_app(app_id):
	marathon_client = MarathonClient('http://' + str(marathon_host) + ':' + str(marathon_port))
	marathon_client.delete_app(app_id)
开发者ID:davidbliu,项目名称:theseus,代码行数:5,代码来源:launcher.py

示例13: MarathonIF

# 需要导入模块: from marathon import MarathonClient [as 别名]
# 或者: from marathon.MarathonClient import delete_app [as 别名]
class MarathonIF(object):
    def __init__(self, marathon_addr, my_addr, mesos):
        self.mcli = MarathonClient(marathon_addr)
        self.myAddr = my_addr
        self.mesos = mesos

    def get_apps(self):
        listapps = self.mcli.list_apps()
        return listapps

    def get_app(self, app_id):
        try:
            a = self.mcli.get_app(app_id)
        except marathon.exceptions.NotFoundError as e:  # NOQA
            return None
        return a

    def delete_app(self, app_id, force=False):
        return self.mcli.delete_app(app_id, force)

    def delete_deployment(self, dep_id):
        return self.mcli.delete_deployment(dep_id)

    def get_deployments(self):
        return self.mcli.list_deployments()

    def delete_app_ifexisting(self, app_id, trys=4):
        for idx in range(0, trys):
            try:
                a = self.get_app(app_id)
                if a:
                    return self.delete_app(app_id)
                return None
            except:
                e = sys.exc_info()[0]
                pprint("<p>Error: %s</p>" % e)
                time.sleep(10)
        raise

    def create_app(self, app_id, attr):
        for idx in range(0, 10):
            try:
                a = self.mcli.create_app(app_id, attr)
                return a
            except marathon.exceptions.MarathonHttpError as e:
                if str(e).find('App is locked by one or more deployments. Override with the option') >= 0:
                    time.sleep(1)
                else:
                    raise
        raise

    def wait_app_removal(self, app):
        cnt = 0
        while True:
            if not self.get_app(app):
                break
            time.sleep(0.2)
            cnt += 1
            if cnt > 0:
                l.info("Stuck waiting for %s to be deleted CNT=%d" % (app, cnt))
        return True

    def wait_app_ready(self, app, running_count):
        cnt = 0
        while True:
            a1 = self.get_app(app)
            if a1.tasks_running == running_count:
                return a1
            cnt += 1
            time.sleep(1)
            if (cnt % 30) == 29:
                l.info("[%d]Waiting for task to move to running stage, " % cnt +
                       "current stat staged=%d running=%d expected Running=%d" %
                       (a1.tasks_staged, a1.tasks_running, running_count))

    def scale_app(self, app, scale):
        return self.mcli.scale_app(app, scale)

    def ping(self):
        return self.mcli.ping()
开发者ID:lorenzodavid,项目名称:hydra,代码行数:82,代码来源:mmapi.py

示例14: MarathonIF

# 需要导入模块: from marathon import MarathonClient [as 别名]
# 或者: from marathon.MarathonClient import delete_app [as 别名]
class MarathonIF(object):
    def __init__(self, marathon_addr, my_addr, mesos):
        self.mcli = MarathonClient(marathon_addr)
        self.myAddr = my_addr
        self.mesos = mesos

    def get_apps(self):
        listapps = self.mcli.list_apps()
        return listapps

    def get_app(self, app_id, timeout=300):
        st_time = time.time()
        while(time.time() - st_time < timeout):
            try:
                try:
                    a = self.mcli.get_app(app_id)
                except marathon.exceptions.NotFoundError as e:  # NOQA
                    return None
                return a
            except:
                l.info("mcli: get_app returned error")
                l.info(traceback.format_exc())
                l.info("Retrying after 10 secs timeout=%d", timeout)
                time.sleep(10)
        raise Exception("mcli get_app timed out, possible zookeper/marathon/mesos malfunction")

    def delete_app(self, app_id, force=False, timeout=200):
        st_time = time.time()
        while(time.time() - st_time < timeout):
            try:
                self.mcli.delete_app(app_id, force)
                return
            except:
                l.info("mcli: delete_app returned error")
                l.info(traceback.format_exc())
                l.info("Retrying after 10 secs timeout=%d", timeout)
                time.sleep(10)
        raise Exception("mcli delete_app timed out, possible zookeper/marathon/mesos malfunction")

    def delete_deployment(self, dep_id):
        return self.mcli.delete_deployment(dep_id)

    def get_deployments(self):
        return self.mcli.list_deployments()

    def delete_app_ifexisting(self, app_id, trys=4):
        for idx in range(0, trys):
            try:
                a = self.get_app(app_id)
                if a:
                    return self.delete_app(app_id)
                return None
            except:
                e = sys.exc_info()[0]
                pprint("<p>Error: %s</p>" % e)
                time.sleep(10)
        raise

    @staticmethod
    def is_valid_app_id(app_id):
        # allowed: lowercase letters, digits, hyphens, slash, dot
        if re.match("^[A-Za-z0-9-/.]*$", app_id):
            return True
        return False

    def create_app(self, app_id, attr):
        """
            Create and start an app.
            :param app_id: (str) - Application ID
            :param attr: marathon.models.app.MarathonApp application to create.
            :return: the created app
        """
        # Validate that app_id conforms to allowed naming scheme.
        if not self.is_valid_app_id(app_id):
            l.error("Error: Only lowercase letters, digits, hyphens are allowed in app_id. %s" % app_id)
            raise Exception("Invalid app_id")

        for idx in range(0, 10):
            try:
                a = self.mcli.create_app(app_id, attr)
                return a
            except marathon.exceptions.MarathonHttpError as e:
                if str(e).find('App is locked by one or more deployments. Override with the option') >= 0:
                    time.sleep(1)
                else:
                    raise
        raise

    def wait_app_removal(self, app):
        cnt = 0
        while True:
            if not self.get_app(app):
                break
            time.sleep(0.2)
            cnt += 1
            if cnt > 0:
                l.info("Stuck waiting for %s to be deleted CNT=%d" % (app, cnt))
        return True

    def wait_app_ready(self, app, running_count, sleep_before_next_try=1):
#.........这里部分代码省略.........
开发者ID:kratos7,项目名称:hydra,代码行数:103,代码来源:mmapi.py

示例15: MarathonClient

# 需要导入模块: from marathon import MarathonClient [as 别名]
# 或者: from marathon.MarathonClient import delete_app [as 别名]
    parser = argparse.ArgumentParser()
    parser.add_argument("-m", "--marathon",
                        help="Marathon URL, on example "
                             "http://127.0.0.1:8080/marathon",
                        required=True)
    parser.add_argument("-e", "--execute", help="Operation execute",
                        choices=['delete', 'create'], required=True)
    parser.add_argument("-d", "--delete",
                        help="Delete all applications",
                        action="store_true")
    parser.add_argument("-c", "--concurrency",
                        help="Concurrency")
    parser.add_argument("-n", "--nodes",
                        help="Number of tasks per application")
    parser.add_argument("-s", "--silent",
                        help="Print only results",
                        action="store_true")
    args = parser.parse_args()
    cluster = MarathonClient(args.marathon, timeout=240)

    if args.execute == "delete":
        cluster = MarathonClient(args.marathon)
        all_apps = cluster.list_apps()
        for app in all_apps:
            print("Delete {}".format(app.id))
            cluster.delete_app(app.id, force=True)
    if args.execute == "create":
        concur = 1 if args.concurrency is None else args.concurrency
        nodes = 1 if args.nodes is None else args.nodes
        concur_create_apps(int(concur), int(nodes))
开发者ID:openstack,项目名称:performance-docs,代码行数:32,代码来源:application_managment_helper.py


注:本文中的marathon.MarathonClient.delete_app方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。