def change_glance_credentials(env, openstack_client, os_conn):
    """Change user and password for Glance"""

    config_api = '/etc/glance/glance-api.conf'
    config_swift = '/etc/glance/glance-swift.conf'

    def change_credentials(node):
        with node.ssh() as remote:
            with remote.open(config_api) as f:
                parser = configparser.RawConfigParser()
                parser.readfp(f)
            parser.set('keystone_authtoken', 'password', 'test')
            with remote.open(config_api, 'w') as f:
                parser.write(f)

            with remote.open(config_swift) as f:
                parser = configparser.RawConfigParser()
                parser.readfp(f)
            parser.set('ref1', 'key', 'test')
            with remote.open(config_swift, 'w') as f:
                parser.write(f)

            remote.check_call('service glance-api restart')

    controllers = env.get_nodes_by_role('controller')
    openstack_client.user_set_new_password('glance', 'test')
    for controller in controllers:
        change_credentials(controller)
    wait_for_glance_alive(os_conn)
def set_file_glance_storage_with_quota(env, os_conn):
    """Enable file storage and set storage quota to 604979776 Bytes"""

    config_api = '/etc/glance/glance-api.conf'

    def change_storage(node):
        with node.ssh() as remote:
            with remote.open(config_api) as f:
                parser = configparser.RawConfigParser()
                parser.readfp(f)
                parser.set('glance_store', 'stores', 'file,http')
                parser.set('glance_store', 'default_store', 'file')
                parser.set('DEFAULT', 'user_storage_quota', '604979776')
            with remote.open(config_api, 'w') as f:
                parser.write(f)

            remote.check_call('service glance-api restart')

    controllers = env.get_nodes_by_role('controller')
    for controller in controllers:
        change_storage(controller)
    wait_for_glance_alive(os_conn)