def sales_rank(config, asin): ecs = ECS(config['access_key'], config['secret_key'], config['associate_tag']) doc = ecs.request({'Operation': 'ItemLookup', 'ItemId': asin, 'ResponseGroup': 'SalesRank'}) rank = doc.getElementsByTagName('SalesRank')[0] return int(rank.childNodes[0].nodeValue)
def create_task_definition(self, *args, **kwargs): task_definition = ECS.create_task_definition( self, family=self.app_name, containers=self.container_definitions, **kwargs) self.task_definition = task_definition['taskDefinitionArn'] return self.task_definition
def create_service(self, **kwargs): service = ECS.create_service(self, cluster=self.cluster_name, service_name=self.service_name, task_definition=self.task_definition, desired_count=self.desired_count, max_health=self.max_health, min_health=self.min_health, **kwargs) self.service = service return self.service
def define_container(self, image=None, name=None, **kwargs): if image is None: image = self.image if name is None: name = self.app_name container = ECS.define_container(self, image=image, name=name, **kwargs) self.container_definitions.append(container) return None
def clearup(self): return ECS.clearup_cluster(self, self.cluster_name)
def delete(self): return ECS.delete_cluster(self, cluster=self.cluster_name)
def delete_services(self, services, *args, **kwargs): return ECS.delete_services(self, cluster=self.cluster_name, services=services)
def set_count_services_zero(self, *args, **kwargs): return ECS.set_count_services_zero(self, cluster=self.cluster_name, services=self.list_services())
def describe_services(self): return ECS.describe_services(self, self.cluster_name)
def list_services(self, *args, **kwargs): return ECS.list_services(self, cluster=self.cluster_name)
def stop_tasks(self, *args, **kwargs): return ECS.stop_tasks(self, cluster=self.cluster_name)
def describe_tasks(self): return ECS.describe_tasks(self, self.cluster_name)
def list_tasks(self, *args, **kwargs): return ECS.list_tasks(self, self.cluster_name)
def list_task_definitions(self): return ECS.list_task_definitions(self, self.app_name)
def create_cluster(self): cluster = ECS.create_cluster(self, name=self.cluster_name) self._cluster = cluster['clusterArn'] return self.cluster