def test_server_name(): """Tests that changing the server name updates the about page""" flash_msg = 'Configuration settings saved for CFME Server "{}' navigate_to(current_appliance.server, 'Server') old_server_name = sel.value(BasicInformation.basic_information.appliance_name) new_server_name = old_server_name + "-CFME" settings_pg = BasicInformation(appliance_name=new_server_name) settings_pg.update() flash.assert_message_contain(flash_msg.format(new_server_name)) # CFME updates about box only after any navigation BZ(1408681) navigate_to(current_appliance.server, 'Dashboard') # if version.current_version() < '5.7': # current_server_name = InfoBlock('Session Information', 'Server Name').text # navigate_to(current_appliance.server, 'About') # else: current_server_name = get_detail('Server Name') close_button = sel.element('//div[contains(@class, "about-modal-pf")]//button[@class="close"]') close_button.click() assert new_server_name == current_server_name, \ "Server name in About section does not match the new name" clear_property_cache(store.current_appliance, 'configuration_details') settings_pg = BasicInformation(appliance_name=old_server_name) settings_pg.update() flash.assert_message_contain(flash_msg.format(old_server_name)) clear_property_cache(store.current_appliance, 'configuration_details')
def test_server_name(appliance): """Tests that changing the server name updates the about page""" flash_msg = 'Configuration settings saved for CFME Server "{}' navigate_to(appliance.server, 'Server') old_server_name = sel.value(BasicInformation.basic_information.appliance_name) new_server_name = old_server_name + "-CFME" settings_pg = BasicInformation(appliance_name=new_server_name) settings_pg.update() flash.assert_message_contain(flash_msg.format(new_server_name)) appliance.server.name = new_server_name # CFME updates about box only after any navigation BZ(1408681) - closed wontfix navigate_to(appliance.server, 'Dashboard') # opens and closes about modal current_server_name = about.get_detail(about.SERVER) assert new_server_name == current_server_name, \ "Server name in About section does not match the new name" clear_property_cache(appliance, 'configuration_details') settings_pg = BasicInformation(appliance_name=old_server_name) settings_pg.update() flash.assert_message_contain(flash_msg.format(old_server_name)) appliance.server.name = old_server_name clear_property_cache(appliance, 'configuration_details')
def test_server_name(appliance): """Tests that changing the server name updates the about page""" flash_msg = 'Configuration settings saved for CFME Server "{}' navigate_to(appliance.server, 'Server') old_server_name = sel.value( BasicInformation.basic_information.appliance_name) new_server_name = old_server_name + "-CFME" settings_pg = BasicInformation(appliance_name=new_server_name) settings_pg.update() flash.assert_message_contain(flash_msg.format(new_server_name)) appliance.server.name = new_server_name # CFME updates about box only after any navigation BZ(1408681) navigate_to(appliance.server, 'Dashboard') current_server_name = get_detail('Server Name') if version.current_version() >= '5.7': # New modal sel.click( '//div[contains(@class, "about-modal-pf")]//button[@class="close"]' ) assert new_server_name == current_server_name, \ "Server name in About section does not match the new name" clear_property_cache(store.current_appliance, 'configuration_details') settings_pg = BasicInformation(appliance_name=old_server_name) settings_pg.update() flash.assert_message_contain(flash_msg.format(old_server_name)) appliance.server.name = old_server_name clear_property_cache(store.current_appliance, 'configuration_details')
def enable_internal(self, region=0, key_address=None, db_password=None, ssh_password=None): """Enables internal database Args: region: Region number of the CFME appliance. key_address: Address of CFME appliance where key can be fetched. Note: If key_address is None, a new encryption key is generated for the appliance. """ self.logger.info('Enabling internal DB (region {}) on {}.'.format( region, self.address)) self.address = self.appliance.address clear_property_cache(self, 'client') client = self.ssh_client # Defaults db_password = db_password or conf.credentials['database']['password'] ssh_password = ssh_password or conf.credentials['ssh']['password'] if self.appliance.has_cli: # use the cli if key_address: status, out = client.run_command( 'appliance_console_cli --region {0} --internal --fetch-key {1} -p {2} -a {3}' .format(region, key_address, db_password, ssh_password)) else: status, out = client.run_command( 'appliance_console_cli --region {} --internal --force-key -p {}' .format(region, db_password)) else: # no cli, use the enable internal db script rbt_repl = { 'miq_lib': '/var/www/miq/lib', 'region': region, 'postgres_version': self.postgres_version } # Find and load our rb template with replacements rbt = datafile.data_path_for_filename('enable-internal-db.rbt', scripts_path.strpath) rb = datafile.load_data_file(rbt, rbt_repl) # sent rb file over to /tmp remote_file = '/tmp/{}'.format(fauxfactory.gen_alphanumeric()) client.put_file(rb.name, remote_file) # Run the rb script, clean it up when done status, out = client.run_command('ruby {}'.format(remote_file)) client.run_command('rm {}'.format(remote_file)) return status, out
def unlock(self): # Ensure this has correct data self.description details_page = navigate_to(self, 'Details') details_page.configuration.item_select('Unlock this Domain') details_page.flash.assert_no_error() details_page.flash.assert_message( 'The selected Automate Domain were marked as Unlocked') clear_property_cache(self, 'locked') assert not self.locked
def enable_internal(self, region=0, key_address=None, db_password=None, ssh_password=None): """Enables internal database Args: region: Region number of the CFME appliance. key_address: Address of CFME appliance where key can be fetched. Note: If key_address is None, a new encryption key is generated for the appliance. """ self.logger.info('Enabling internal DB (region {}) on {}.'.format(region, self.address)) self.address = self.appliance.address clear_property_cache(self, 'client') client = self.ssh_client # Defaults db_password = db_password or conf.credentials['database']['password'] ssh_password = ssh_password or conf.credentials['ssh']['password'] if self.appliance.has_cli: # use the cli if key_address: status, out = client.run_command( 'appliance_console_cli --region {0} --internal --fetch-key {1} -p {2} -a {3}' .format(region, key_address, db_password, ssh_password) ) else: status, out = client.run_command( 'appliance_console_cli --region {} --internal --force-key -p {}' .format(region, db_password) ) else: # no cli, use the enable internal db script rbt_repl = { 'miq_lib': '/var/www/miq/lib', 'region': region, 'postgres_version': self.postgres_version } # Find and load our rb template with replacements rbt = datafile.data_path_for_filename('enable-internal-db.rbt', scripts_path.strpath) rb = datafile.load_data_file(rbt, rbt_repl) # sent rb file over to /tmp remote_file = '/tmp/{}'.format(fauxfactory.gen_alphanumeric()) client.put_file(rb.name, remote_file) # Run the rb script, clean it up when done status, out = client.run_command('ruby {}'.format(remote_file)) client.run_command('rm {}'.format(remote_file)) return status, out
def test_server_name(): """Tests that changing the server name updates the about page""" flash_msg = 'Configuration settings saved for CFME Server "{}' sel.force_navigate('cfg_settings_currentserver_server') old_server_name = sel.value(BasicInformation.basic_information.appliance_name) new_server_name = old_server_name + "-CFME" settings_pg = BasicInformation(appliance_name=new_server_name) settings_pg.update() flash.assert_message_contain(flash_msg.format(new_server_name)) sel.force_navigate('about') assert new_server_name == InfoBlock('Session Information', 'Server Name').text,\ "Server name in About section does not match the new name" clear_property_cache(store.current_appliance, 'configuration_details') settings_pg = BasicInformation(appliance_name=old_server_name) settings_pg.update() flash.assert_message_contain(flash_msg.format(old_server_name)) clear_property_cache(store.current_appliance, 'configuration_details')
def enable_external(self, db_address, region=0, db_name=None, db_username=None, db_password=None): """Enables external database Args: db_address: Address of the external database region: Number of region to join db_name: Name of the external DB db_username: Username to access the external DB db_password: Password to access the external DB Returns a tuple of (exitstatus, script_output) for reporting, if desired """ self.logger.info('Enabling external DB (db_address {}, region {}) on {}.' .format(db_address, region, self.address)) # reset the db address and clear the cached db object if we have one self.address = db_address clear_property_cache(self, 'client') # default db_name = db_name or 'vmdb_production' db_username = db_username or conf.credentials['database']['username'] db_password = db_password or conf.credentials['database']['password'] client = self.ssh_client if self.appliance.has_cli: # copy v2 key master_client = client(hostname=self.address) rand_filename = "/tmp/v2_key_{}".format(fauxfactory.gen_alphanumeric()) master_client.get_file("/var/www/miq/vmdb/certs/v2_key", rand_filename) client.put_file(rand_filename, "/var/www/miq/vmdb/certs/v2_key") # enable external DB with cli status, out = client.run_command( 'appliance_console_cli ' '--hostname {0} --region {1} --dbname {2} --username {3} --password {4}'.format( self.address, region, db_name, db_username, db_password ) ) else: # no cli, use the enable external db script rbt_repl = { 'miq_lib': '/var/www/miq/lib', 'host': self.address, 'region': region, 'database': db_name, 'username': db_username, 'password': db_password } # Find and load our rb template with replacements rbt = datafile.data_path_for_filename('enable-internal-db.rbt', scripts_path.strpath) rb = datafile.load_data_file(rbt, rbt_repl) # Init SSH client and sent rb file over to /tmp remote_file = '/tmp/{}'.format(fauxfactory.gen_alphanumeric()) client.put_file(rb.name, remote_file) # Run the rb script, clean it up when done status, out = client.run_command('ruby {}'.format(remote_file)) client.run_command('rm {}'.format(remote_file)) if status != 0: self.logger.error('error enabling external db') self.logger.error(out) msg = ('Appliance {} failed to enable external DB running on {}' .format(self.appliance.address, db_address)) self.logger.error(msg) from . import ApplianceException raise ApplianceException(msg) return status, out
def __setattr__(self, attr, value): super(self.__class__, self).__setattr__(attr, value) if self._top is not None: self.logger.info("Invalidating lazy_cache ssh_client current_appliance object") clear_property_cache(self._top, 'ssh_client')