def stop_service(cls, options): """Instructs AppScale to stop the named service. This is applicable for services using manual scaling. Args: options: A Namespace that has fields for each parameter that can be passed in via the command-line interface. Raises: AppScaleException: If the named service isn't running in this AppScale cloud, or if stop is not valid for the service. """ if not options.confirm: response = raw_input( 'Are you sure you want to stop this service? (y/N) ') if response.lower() not in ['y', 'yes']: raise AppScaleException("Cancelled service stop.") load_balancer_ip = LocalState.get_host_with_role( options.keyname, 'load_balancer') secret = LocalState.get_secret_key(options.keyname) admin_client = AdminClient(load_balancer_ip, secret) version = Version(None, None) version.project_id = options.project_id version.service_id = options.service_id or DEFAULT_SERVICE version.id = DEFAULT_VERSION version.serving_status = 'STOPPED' admin_client.patch_version(version, ['servingStatus']) AppScaleLogger.success('Stop requested for {}.'.format(options.project_id))
def start_service(cls, options): """Instructs AppScale to start the named service. This is applicable for services using manual scaling. Args: options: A Namespace that has fields for each parameter that can be passed in via the command-line interface. Raises: AppScaleException: If the named service isn't running in this AppScale cloud, or if start is not valid for the service. """ load_balancer_ip = LocalState.get_host_with_role( options.keyname, 'load_balancer') secret = LocalState.get_secret_key(options.keyname) admin_client = AdminClient(load_balancer_ip, secret) version = Version(None, None) version.project_id = options.project_id version.service_id = options.service_id or DEFAULT_SERVICE version.id = DEFAULT_VERSION version.serving_status = 'SERVING' admin_client.patch_version(version, ['servingStatus']) AppScaleLogger.success('Start requested for {}.'.format(options.project_id))