def validate_config_present(self, appliance_profile): """ Raises an exception if the config is not present :param appliance_profile: The appliance profile name :return: None """ if not self.is_config_present(appliance_profile): if DEFAULT_PROFILE == appliance_profile: raise exceptions.InvalidConfig('Cannot find appliance config. Appliance not initialized') else: raise exceptions.InvalidConfig( 'Cannot find appliance config for profile %s since it was not initialized' % appliance_profile)
def delete_config(self, appliance_profile): """ Deletes the appliance profile :param appliance_profile: The appliance profile name :return: None """ if not self.is_config_present(appliance_profile): raise exceptions.InvalidConfig('The profile {} does not exist'.format(appliance_profile)) try: shutil.rmtree(self.get_config_dir(appliance_profile)) except IOError as e: click.FileError('Failed to delete appliance config for profile {}. ' 'Make sure the permissions are set correctly for this path...' .format(appliance_profile)) raise e