def test_inventory_sync(self): si = connect.SmartConnectNoSSL(host='192.168.1.60', user='******', pwd='Abcd123$') mor_sync_interval = 300 vc_name = 'TestVcenter' instance_id = 'VCenterInstance' inventory_mgr = inventory.InventoryManager(si, mor_sync_interval, vc_name, instance_id) inventory_mgr.sync_inventory() current_inventory = inventory_mgr.current_inventory() self.assertIsNotNone(current_inventory) self.assertEqual(2, len(current_inventory['datacenter'])) self.assertEqual(1, len(current_inventory['cluster'])) self.assertEqual(2, len(current_inventory['host'])) self.assertEqual(2, len(current_inventory['vm']))
def __init__(self, config): """ Reads from configuration, connects to vCenter and starts inventory manager and metric manager threads. :param config: Configuration for the environment. """ self._host = config['host'] self._username = config['username'] self._password = config['password'] self._vc_name = config['Name'] self._ingest_token = config['IngestToken'] self._ingest_endpoint = config['IngestEndpoint'] self._ingest_timeout = config['IngestTimeout'] self._logger = logging.getLogger(self.get_instance_id()) self._si = None self._connect() if self._si is None: raise ValueError("Unable to connect to host") self._ingest = self._create_signalfx_ingest() if self._ingest is None: raise ValueError("Unable to create ingest client") self._additional_dims = config.get('dimensions', None) if 'MORSyncInterval' not in config: config['MORSyncInterval'] = constants.DEFAULT_MOR_SYNC_INTERVAL self._mor_sync_timeout = config.get('MORSyncTimeout', constants.DEFAULT_MOR_SYNC_TIMEOUT) self._metric_sync_timeout = config.get( 'MetricSyncTimeout', constants.DEFAULT_METRIC_SYNC_TIMEOUT) self._inventory_mgr = inventory.InventoryManager( self._si, config['MORSyncInterval'], config['Name'], self.get_instance_id()) self._inventory_mgr.start() if 'MetricSyncInterval' not in config: config[ 'MetricSyncInterval'] = constants.DEFAULT_METRIC_SYNC_INTERVAL self._metric_conf = self._get_metric_config(config) self._metric_mgr = metric_metadata.MetricManager( self._si, config['MetricSyncInterval'], self._metric_conf, config['Name'], self.get_instance_id()) self._metric_mgr.start() self._wait_for_sync()
def open_inventory_manager(self, event=None): inventory.InventoryManager(self)
def open_inventory_manager(self, event): inventory.InventoryManager(self.frame)
def plan_manager(): """ Defines the plan to play the game """ print("I'm the plan manager!") arenaManager = arena.ArenaManager(driver, secureHash) playerManager = player.PlayerManager(driver, secureHash) inventoryManager = inventory.InventoryManager(driver, secureHash) questManager = quest.QuestManager(driver, secureHash) workManager = work.WorkManager(driver, secureHash) expeditionManager = expedition.ExpeditionManager(driver, secureHash) # questsProcess = multiprocessing.Process(target = questManager.loop_quests, args = (False,)) # skip_timed_quests = False questsProcess = threading.Thread(target=questManager.loop_quests, args=(False, )) # skip_timed_quests ? questsProcess.daemon = True # This process should die along with the main one questsProcess.start() while True: print("********** Starting new cycle **********") # playerManager.go_training(skills_to_train = ['Charisma', 'Intelligence']) ### Spend action points #if playerManager.is_circus_ready(): arenaManager.go_circus_provinciarum() #if playerManager.is_dungeon_ready(): expeditionManager.go_dungeon_green_forest( difficulty=translation.dungeon_advanced_text, skip_boss=False) hp_percent = playerManager.get_hp_percentage() if hp_percent <= 45: print("I'm weak, i should eat something") if not inventoryManager.eat_food(): inventoryManager.collect_food() if not inventoryManager.eat_food(): print("Couldn't eat food :(, have none") """ print("No food at all, going to work") time_working = workManager.go_work() if time_working != -1: print(f"Working for {time_working} seconds...") time.sleep(time_working) """ hp_percent = playerManager.get_hp_percentage() #if playerManager.is_expedition_ready(): if hp_percent >= 45: expeditionManager.go_expedition(location=6, stage=4) #if playerManager.is_arena_ready(): if hp_percent >= 45: arenaManager.go_arena_provinciarum() ### Wait until next cycle time_working = settings.quest_time_cycle if time_working != -1: time_working = time_working + randrange(settings.quest_time_cycle) print(f"Sleeping for {time_working} seconds...") time.sleep(time_working) print("Finished sleeping!")