def acquire(self): """ Gets data from AWS :rtype: pandas frame (:class:`pd.DataFramelist`) """ # Load kown accounts configuration # account configuration is dynamic self.logger.debug("in AWSSpotPrice acquire") account_dict = load_config.load(self.config_file, 5, 20, self.logger) sp_data = [] for account in account_dict: # pylint: disable=not-an-iterable for region, instances in account_dict[account].items(): # pylint: disable=unsubscriptable-object spot_price_info = AWSSpotPriceForRegion(region, profile_name=account) spot_price_info.init_query(instance_types=instances) spot_price_history = spot_price_info.get_price(self.logger) if spot_price_history: sp_data += spot_price_info.spot_price_summary( spot_price_history) sp_list = [i.data for i in sp_data] return {"provisioner_resource_spot_prices": pd.DataFrame(sp_list)}
def acquire(self): """ Gets data from AWS :rtype: pandas frame (:class:`pd.DataFramelist`) """ # Load kown accounts configuration self.account_dict = load_config.load(self.config_file, 5, 20) # account configuration is dynamic sp_data = [] for account in self.account_dict: for region, instances in self.account_dict[account].items(): spot_price_info = AWSSpotPriceForRegion(region, profile_name=account) spot_price_info.init_query(instance_types = instances) spot_price_history = spot_price_info.get_price() if spot_price_history: sp_data += spot_price_info.spot_price_summary(spot_price_history) sp_list = [i.data for i in sp_data] return {PRODUCES[0]: pd.DataFrame(sp_list)}
def acquire(self): """ Fills ``self.data`` with spot price data. :type spot_price_history: :obj:`list` :arg spot_price_history: list of spotprice data (:class:`SpotPriceData`) """ # Load known accounts configuration # account configuration is dynamic account_dict = load_config.load(self.config_file, 5, 20) occupancy_data = [] self.logger.debug('account_dict %s' % (self.account_dict, )) for account in account_dict: for region in account_dict[account]: occcupancy = OccupancyForRegion(region, profile_name=account) instances = occcupancy.get_ec2_instances() if instances: data = occcupancy.capacity(instances) if data: occupancy_data += data oc_list = [i.data for i in occupancy_data] return {'AWS_Occupancy': pd.DataFrame(oc_list)}