Updating meniscus supporting classes after more product changes
Change-Id: Ic08deed1eb0cab879f4c7d0a624a676bd18f7420
This commit is contained in:
parent
7c663ab20a
commit
904f36e581
@ -101,66 +101,6 @@ class TenantConfig(ConfigSectionInterface):
|
|||||||
return self.get("profile_name")
|
return self.get("profile_name")
|
||||||
|
|
||||||
|
|
||||||
class PairingConfig(ConfigSectionInterface):
|
|
||||||
SECTION_NAME = 'meniscus-pairing'
|
|
||||||
|
|
||||||
@property
|
|
||||||
def hostname(self):
|
|
||||||
return self.get('hostname')
|
|
||||||
|
|
||||||
@property
|
|
||||||
def coordinator_base_url(self):
|
|
||||||
return self.get('coordinator_base_url')
|
|
||||||
|
|
||||||
@property
|
|
||||||
def worker_base_url(self):
|
|
||||||
return self.get('worker_base_url')
|
|
||||||
|
|
||||||
@property
|
|
||||||
def callback(self):
|
|
||||||
return self.get('callback')
|
|
||||||
|
|
||||||
@property
|
|
||||||
def ip_v4(self):
|
|
||||||
return self.get('ip_address_v4')
|
|
||||||
|
|
||||||
@property
|
|
||||||
def ip_v6(self):
|
|
||||||
return self.get('ip_address_v6')
|
|
||||||
|
|
||||||
@property
|
|
||||||
def os_type(self):
|
|
||||||
return self.get('os_type')
|
|
||||||
|
|
||||||
@property
|
|
||||||
def memory_mb(self):
|
|
||||||
return int(self.get('memory_mb'))
|
|
||||||
|
|
||||||
@property
|
|
||||||
def arch(self):
|
|
||||||
return self.get('arch')
|
|
||||||
|
|
||||||
@property
|
|
||||||
def api_secret(self):
|
|
||||||
return self.get('api_secret')
|
|
||||||
|
|
||||||
@property
|
|
||||||
def personality(self):
|
|
||||||
return self.get('personality')
|
|
||||||
|
|
||||||
@property
|
|
||||||
def cpu_cores(self):
|
|
||||||
return int(self.get('cpu_cores'))
|
|
||||||
|
|
||||||
@property
|
|
||||||
def load_average(self):
|
|
||||||
return json_to_dict(self.get('load_average'))
|
|
||||||
|
|
||||||
@property
|
|
||||||
def disks(self):
|
|
||||||
return json_to_dict(self.get('disks'))
|
|
||||||
|
|
||||||
|
|
||||||
class CorrelationConfig(ConfigSectionInterface):
|
class CorrelationConfig(ConfigSectionInterface):
|
||||||
SECTION_NAME = 'meniscus-correlation'
|
SECTION_NAME = 'meniscus-correlation'
|
||||||
|
|
||||||
|
@ -57,8 +57,10 @@ class PublishingBehaviors(object):
|
|||||||
if tenant_id is None:
|
if tenant_id is None:
|
||||||
tenant_id = self.tenant_id
|
tenant_id = self.tenant_id
|
||||||
|
|
||||||
resp = self.storage_client.find_term(name='time', value=timestamp,
|
resp = self.storage_client.wait_for_messages(name='time',
|
||||||
size=num_messages)
|
value=timestamp,
|
||||||
|
num=num_messages,
|
||||||
|
max_wait=2)
|
||||||
|
|
||||||
# Copying all of the models into a fresh list
|
# Copying all of the models into a fresh list
|
||||||
return [model for model in resp]
|
return [model for model in resp]
|
||||||
|
@ -1,57 +0,0 @@
|
|||||||
"""
|
|
||||||
Copyright 2013 Rackspace
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
"""
|
|
||||||
from datetime import datetime
|
|
||||||
from cafe.engine.behaviors import BaseBehavior
|
|
||||||
|
|
||||||
|
|
||||||
class StatusAPIBehaviors(BaseBehavior):
|
|
||||||
|
|
||||||
def __init__(self, status_client, pairing_config):
|
|
||||||
super(StatusAPIBehaviors, self).__init__()
|
|
||||||
self.status_client = status_client
|
|
||||||
self.pairing_config = pairing_config
|
|
||||||
|
|
||||||
def update_load_average(self, worker_id, worker_token,
|
|
||||||
one, five, fifteen):
|
|
||||||
response = self.status_client.update_status(
|
|
||||||
worker_id=worker_id, worker_token=worker_token,
|
|
||||||
status='new',
|
|
||||||
os_type=self.pairing_config.os_type,
|
|
||||||
memory_mb=self.pairing_config.memory_mb,
|
|
||||||
architecture=self.pairing_config.arch,
|
|
||||||
cpu_cores=self.pairing_config.cpu_cores,
|
|
||||||
timestamp=datetime.now().isoformat(),
|
|
||||||
one=one, five=five, fifteen=fifteen,
|
|
||||||
disks={})
|
|
||||||
return response
|
|
||||||
|
|
||||||
def update_status_from_config(self, worker_id, worker_token, status=None,
|
|
||||||
os_type=None, memory_mb=None,
|
|
||||||
architecture=None, cpu_cores=None,
|
|
||||||
timestamp=None, one=None, five=None,
|
|
||||||
fifteen=None, disks=None):
|
|
||||||
|
|
||||||
response = self.status_client.update_status(
|
|
||||||
worker_id=worker_id, worker_token=worker_token,
|
|
||||||
status=status or 'new',
|
|
||||||
os_type=os_type or self.pairing_config.os_type,
|
|
||||||
memory_mb=memory_mb or self.pairing_config.memory_mb,
|
|
||||||
architecture=architecture or self.pairing_config.arch,
|
|
||||||
cpu_cores=cpu_cores or self.pairing_config.cpu_cores,
|
|
||||||
timestamp=timestamp or datetime.now().isoformat(),
|
|
||||||
one=one or 0.0, five=five or 0.0, fifteen=fifteen or 0.0,
|
|
||||||
disks=disks or {})
|
|
||||||
return response
|
|
@ -34,35 +34,6 @@ class WorkerStatusClient(AutoMarshallingRestClient):
|
|||||||
base=self.url, version=self.api_version, worker_id=worker_id)
|
base=self.url, version=self.api_version, worker_id=worker_id)
|
||||||
return url
|
return url
|
||||||
|
|
||||||
def update_status(self, worker_id, worker_token, status=None,
|
|
||||||
os_type=None, memory_mb=None, architecture=None,
|
|
||||||
cpu_cores=None, timestamp=None, one=None,
|
|
||||||
five=None, fifteen=None, disks=None):
|
|
||||||
|
|
||||||
url = self._get_remote_url(worker_id)
|
|
||||||
disk_usage = WorkerDiskUsage._dict_to_obj(disks)
|
|
||||||
load_average = WorkerLoadAverage(one, five, fifteen)
|
|
||||||
system_info = SystemInfo(
|
|
||||||
disk_usage=disk_usage,
|
|
||||||
os_type=os_type,
|
|
||||||
memory_mb=memory_mb,
|
|
||||||
architecture=architecture,
|
|
||||||
cpu_cores=cpu_cores,
|
|
||||||
load_average=load_average,
|
|
||||||
timestamp=timestamp)
|
|
||||||
|
|
||||||
req_obj = WorkerStatusUpdate(status=status, system_info=system_info)
|
|
||||||
headers = {'WORKER-TOKEN': worker_token}
|
|
||||||
resp = self.request('PUT', url, headers=headers,
|
|
||||||
request_entity=req_obj)
|
|
||||||
return resp
|
|
||||||
|
|
||||||
def direct_update(self, worker_id, worker_token, body):
|
|
||||||
"""Allows direct access for negative testing ONLY!"""
|
|
||||||
url = self._get_remote_url(worker_id)
|
|
||||||
headers = {'WORKER-TOKEN': worker_token}
|
|
||||||
return self.request('PUT', url, headers=headers)
|
|
||||||
|
|
||||||
def get_worker_status(self, worker_id):
|
def get_worker_status(self, worker_id):
|
||||||
url = '{base}/{version}/worker/{worker_id}/status'.format(
|
url = '{base}/{version}/worker/{worker_id}/status'.format(
|
||||||
base=self.url, version=self.api_version, worker_id=worker_id)
|
base=self.url, version=self.api_version, worker_id=worker_id)
|
||||||
|
@ -13,13 +13,15 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
"""
|
"""
|
||||||
|
from cafe.engine.behaviors import BaseBehavior
|
||||||
from cloudcafe.common.tools.datagen import random_int
|
from cloudcafe.common.tools.datagen import random_int
|
||||||
from cloudcafe.meniscus.common.tools import RequestUtilities
|
from cloudcafe.meniscus.common.tools import RequestUtilities
|
||||||
|
|
||||||
|
|
||||||
class TenantBehaviors(object):
|
class TenantBehaviors(BaseBehavior):
|
||||||
|
|
||||||
def __init__(self, tenant_client, db_client, tenant_config, es_client):
|
def __init__(self, tenant_client, db_client, tenant_config, es_client):
|
||||||
|
super(TenantBehaviors, self).__init__()
|
||||||
self.tenant_client = tenant_client
|
self.tenant_client = tenant_client
|
||||||
self.db_client = db_client
|
self.db_client = db_client
|
||||||
self.tenant_config = tenant_config
|
self.tenant_config = tenant_config
|
||||||
@ -31,8 +33,12 @@ class TenantBehaviors(object):
|
|||||||
self.db_client.auth()
|
self.db_client.auth()
|
||||||
for tenant_id in self.tenant_ids:
|
for tenant_id in self.tenant_ids:
|
||||||
self.db_client.remove_tenant(tenant_id)
|
self.db_client.remove_tenant(tenant_id)
|
||||||
self.es_client.wait_for_index(tenant_id)
|
self.es_client.wait_for_index(tenant_id, wait=1)
|
||||||
self.es_client.delete_index(tenant_id)
|
if self.es_client.has_index(tenant_id):
|
||||||
|
self.es_client.delete_index(tenant_id)
|
||||||
|
else:
|
||||||
|
self._log.info('Couldn\'t find ES index to delete.')
|
||||||
|
|
||||||
self.db_client.disconnect()
|
self.db_client.disconnect()
|
||||||
self.tenant_ids = []
|
self.tenant_ids = []
|
||||||
|
|
||||||
|
@ -23,21 +23,6 @@ producer_durable=true
|
|||||||
producer_encrypted=false
|
producer_encrypted=false
|
||||||
profile_name=appservers-1
|
profile_name=appservers-1
|
||||||
|
|
||||||
[meniscus-pairing]
|
|
||||||
hostname=testhost
|
|
||||||
coordinator_base_url=<coordinator_base_url>
|
|
||||||
worker_base_url=<worker_base_url>
|
|
||||||
ip_address_v4=127.0.0.1
|
|
||||||
ip_address_v6=::1
|
|
||||||
os_type=Linux
|
|
||||||
memory_mb=1024
|
|
||||||
arch=x86_64
|
|
||||||
api_secret=<api_secret>
|
|
||||||
personality=worker
|
|
||||||
cpu_cores=4
|
|
||||||
load_average={"1": 0.2,"5": 1,"15": 0.9}
|
|
||||||
disks=[{"device":"/dev/sda1", "total": 313764528, "used": 112512436}]
|
|
||||||
|
|
||||||
[meniscus-correlation]
|
[meniscus-correlation]
|
||||||
correlator_base_url=<correlator_base_url>
|
correlator_base_url=<correlator_base_url>
|
||||||
syslog_endpoint=<syslog_endpoint>
|
syslog_endpoint=<syslog_endpoint>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user