Hi...
Cost-Analytics in scalr 5.1 still doesn't work.
cep.value must be encryted but not in 5.1(current version).
first i tried... using cryptotool.encrypt_scalr() to change the value. but
I got different results from python and mysql data.
cryptotool.encrypt_scalr() :
AhtRtT6j1KYZgh1+bpKBfDXUT0Mhg9k1WuSoHYy9gA==
mysql data :
AhtRtT6j1KYZgh1+bpKBfDXUT0Mhg9k1WuSoHYy9gC4=
so i had another way like below. (i'm not good in python...)
*###### analytics_poller.py*
def sort_nodes(cloud_data, cred, envs_ids*, keke*):
platform = cred.platform
.
.
url = cred[url_key] if url_key else ''
* custom_url = keke*
.
.
.
if url:
query1 = (
"SELECT sp.server_id, sp.value AS instance_id,
s.env_id "
"FROM server_properties sp "
"JOIN servers s ON sp.server_id=s.server_id "
"JOIN client_environment_properties cep ON
s.env_id=cep.env_id "
"WHERE sp.name='{name}' "
"AND s.platform='{platform}' "
"AND s.cloud_location='{cloud_location}' "
"AND cep.name='{platform}.{url_key}' "
"AND cep.value='{url}' "
"AND sp.value IN ({value})"
).format(
name=analytics.Analytics.server_id_map[platform],
platform=platform,
cloud_location=cloud_location,
url_key=url_key,
* #url=url, *
* url=custom_url, *
value=str(chunk_ids)[1:-1])
query2 = (
"SELECT sp1.server_id, sp1.value AS instance_id,
s.env_id "
"FROM server_properties sp1 "
"JOIN server_properties sp2 ON
sp1.server_id=sp2.server_id "
"JOIN servers_history s ON
sp1.server_id=s.server_id "
"JOIN client_environment_properties cep ON
s.env_id=cep.env_id "
"WHERE s.platform='{platform}' "
"AND sp1.name='{name1}' "
"AND sp1.value IN ({value1}) "
"AND sp2.name='{name2}' "
"AND sp2.value='{value2}' "
"AND cep.name='{platform}.{url_key}' "
"AND cep.value='{url}'"
).format(
name1=analytics.Analytics.server_id_map[platform],
value1=str(chunk_ids)[1:-1],
name2=cloud_location_key,
value2=cloud_location,
platform=platform,
url_key=url_key,
* #url=url) ## <--*
* url=custom_url) ## <--*
.
.
.
def process_credential(cred, envs_ids=None):
if envs_ids is None:
envs_ids = [cred.env_id]
try:
* keke = app.hoho*
for k, v in cred.iteritems():
if k in cred.scheme[cred.platform]:
cred[k] = cryptotool.decrypt_scalr(app.crypto_key, v)
cloud_data = eval(cred.platform)(cred)
if cloud_data:
sorted_data = sort_nodes(cloud_data, cred, envs_ids*, keke*)
sorted_data_update(sorted_data)
db_update(sorted_data, envs_ids, cred)
except:
msg = 'platform: {platform}, environments: {envs}, reason: {error}'
msg = msg.format(platform=cred.platform, envs=envs_ids,
error=helper.exc_info())
LOG.error(msg)
def do_iteration(self):
for envs in self.analytics.load_envs(limit=500):
creds = self.analytics.load_creds(envs, platforms)
unique_creds = self.analytics.filter_creds(creds)
for _ in unique_creds:
envs_ids = _['env_id']
cred = _['cred']
* self.hoho = cred['keystone_url']*
while len(self.pool) > self.config['pool_size'] * 5 / 10:
gevent.sleep(0.1)
self.pool.apply_async(
process_credential,
args=(cred,), kwds={'envs_ids': envs_ids})
gevent.sleep(0) # force switch
self.pool.join()
On Monday, December 29, 2014 5:53:18 PM UTC+9, Thomas Orozco wrote:
>
> Hey there
>
> We recently released OSS Scalr 5.1, where those jobs have been thoroughly
> refactored, you might want to check whether they work properly in the
> updated version!
>
> Cheers,
>
> On Friday, December 26, 2014 5:26:53 AM UTC+1, Hee-Sung Kim wrote:
>>
>>
>> i have found out a work around...
>>
>> 1. install 5.1
>> 2. change analytics_poller.py
>>
>> ### /opt/scalr/current/app/python/scalrpy/analytics_poller.py
>>
>> for region_data in cloud_data:
>> cloud_location = region_data['region']
>> instances_ids = list(set(
>> str(node['instance_id'])
>> for node in region_data['nodes'] if node['instance_id'] or
>> node['instance_id'] == 0))
>> if not instances_ids:
>> continue
>> results = tuple()
>> i, chunk_size = 0, 200
>> while True:
>> chunk_ids = instances_ids[i*chunk_size:(i+1)*chunk_size]
>> #LOG.info(chunk_ids)
>> if not chunk_ids:
>> break
>> if url:
>> url = app.custom_url *# <-- add*
>> .
>> .
>> .
>> def do_iteration(self):
>> for envs in self.analytics.load_envs(limit=500):
>> creds = self.analytics.load_creds(envs, platforms)
>> unique_creds = self.analytics.filter_creds(creds)
>> for _ in unique_creds:
>> envs_ids = _['env_id']
>> cred = _['cred']
>> self.custom_url = creds[0]['keystone_url'] *# <-- add*
>> while len(self.pool) > self.config['pool_size'] * 5 / 10:
>> gevent.sleep(0.1)
>> self.pool.apply_async(
>> process_credential,
>> args=(cred,), kwds={'envs_ids': envs_ids})
>> gevent.sleep(0) # force switch
>> self.pool.join()
>>
>>
>> 2014년 12월 11일 목요일 오후 8시 59분 50초 UTC+9, Hee-Sung Kim 님의 말:
>>>
>>>
>>> I came across error after install "scalr v5.0.1" on centos 6.5.
>>>
>>> "cost analytics" doesn't work..
>>>
>>> - error message.
>>>
>>> /var/log/scalr/analytics-poller.log
>>>
>>> platform: openstack environments : 1 reason: TypeError: list indices
>>> must be integers, not str file : analytics_poller.py 541 line
>>>
>>
--
You received this message because you are subscribed to the Google Groups
"scalr-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.