Created
August 5, 2011 21:02
-
-
Save greenisus/1128520 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)pollUntilActive:(OpenStackAccount *)account withProgress:(ASIBasicBlock)progressBlock complete:(ASIBasicBlock)completeBlock { | |
if ([self shouldBePolled]) { | |
NSString *endpoint = [account loadBalancerEndpointForRegion:self.region]; | |
__block LoadBalancerRequest *request = [LoadBalancerRequest getLoadBalancerDetailsRequest:account loadBalancer:self endpoint:endpoint]; | |
request.delegate = self; | |
[request setCompletionBlock:^{ | |
if ([request isSuccess]) { | |
LoadBalancer *newLB = [request loadBalancer:account]; | |
self.status = newLB.status; | |
self.progress = newLB.progress; | |
// load LB stuff | |
NSLog(@"lb poll status: %@", self.status); | |
if ([self shouldBePolled]) { | |
if (progressBlock) { | |
progressBlock(); | |
} | |
[self pollUntilActive:account withProgress:nil complete:[[completeBlock copy] autorelease]]; | |
} else { | |
completeBlock(); | |
} | |
} | |
}]; | |
[request setFailedBlock:^{ | |
[self pollUntilActive:account withProgress:[[progressBlock copy] autorelease] complete:[[completeBlock copy] autorelease]]; | |
}]; | |
[request startAsynchronous]; | |
} else { | |
completeBlock(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment