Skip to content

Instantly share code, notes, and snippets.

@kshailen
Created September 15, 2017 02:51
Show Gist options
  • Save kshailen/c95853f730af4c6df345d05380b1b3dd to your computer and use it in GitHub Desktop.
Save kshailen/c95853f730af4c6df345d05380b1b3dd to your computer and use it in GitHub Desktop.
Testing log file creation in /var/log/msi directory
import requests
import json
import os
import subprocess
import skycommon
class When_getting_machine_list_from_fleet_and_comparing_with_elastic_machine_list:
def __init__(self):
self.elastic_machine_list = []
self.fleet_machine_list = []
self.xfleetSectionList = ['MachineMetadata="dataplatform=true"']
self.mountVolumesList = ['/cvolumes/var/log/msi=/var/log/msi']
self.logTarget = "/var/log/msi/msi-vas/test/test1/test.log"
self.servicename = "emitter"
skycommon.sky_deployEmitterServiceViaFleet(1, 5, self.logTarget, self.mountVolumesList, self.xfleetSectionList)
self.requrl = 'http://elasticsearch.service.local:9200/test*/_search?pretty'
def when_fleet_machine_list(self):
res = requests.get(self.requrl, verify=False)
response_data = json.loads(str(res.content, 'utf-8'))
for i in response_data['hits']['hits']:
if i['_source']['hostname'] not in self.elastic_machine_list:
self.elastic_machine_list.append(i['_source']['hostname'])
print(self.elastic_machine_list)
def cleanup(self):
skycommon._destroyServiceViaFleet_(self.servicename)
skycommon.sky_deleteFleetServiceFile(sel.servicename)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment